@blocklet/pages-kit-block-studio 0.5.54 → 0.5.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -46,7 +46,6 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
46
46
|
const Session_1 = require("@arcblock/did-connect/lib/Session");
|
|
47
47
|
const Config_1 = require("@arcblock/ux/lib/Config");
|
|
48
48
|
const context_1 = require("@arcblock/ux/lib/Locale/context");
|
|
49
|
-
const Theme_1 = require("@arcblock/ux/lib/Theme");
|
|
50
49
|
const Toast_1 = __importStar(require("@arcblock/ux/lib/Toast"));
|
|
51
50
|
const js_sdk_1 = require("@blocklet/js-sdk");
|
|
52
51
|
const theme_1 = require("@blocklet/pages-kit-inner-components/theme");
|
|
@@ -91,6 +90,14 @@ const api = (0, js_sdk_1.createAxios)({
|
|
|
91
90
|
componentDid: PAGES_KIT_BLOCK_STUDIO_BLOCKLET_DID,
|
|
92
91
|
});
|
|
93
92
|
const { SessionProvider, SessionContext } = (0, Session_1.createAuthServiceSessionContext)();
|
|
93
|
+
function useIsInsideIframe() {
|
|
94
|
+
const location = (0, react_router_dom_1.useLocation)();
|
|
95
|
+
const isInsideIframe = (0, react_1.useMemo)(() => {
|
|
96
|
+
const url = new URL(window.location.href);
|
|
97
|
+
return url.searchParams.get('simulator') === '1';
|
|
98
|
+
}, [location.href]);
|
|
99
|
+
return isInsideIframe;
|
|
100
|
+
}
|
|
94
101
|
function useSessionContext() {
|
|
95
102
|
const info = (0, react_1.useContext)(SessionContext);
|
|
96
103
|
return info;
|
|
@@ -310,10 +317,7 @@ function Layout({ loadState, loadedData }) {
|
|
|
310
317
|
const navigate = (0, react_router_dom_1.useNavigate)();
|
|
311
318
|
const staticData = (0, client_1.useStaticData)();
|
|
312
319
|
// 获取当前URL参数判断是否是在iframe内
|
|
313
|
-
const isInsideIframe = (
|
|
314
|
-
const url = new URL(window.location.href);
|
|
315
|
-
return url.searchParams.get('simulator') === '1';
|
|
316
|
-
}, [window.location.href]);
|
|
320
|
+
const isInsideIframe = useIsInsideIframe();
|
|
317
321
|
(0, ahooks_2.useUpdateEffect)(() => {
|
|
318
322
|
const iframe = document.querySelector('#preview-iframe');
|
|
319
323
|
if (iframe && iframe.contentWindow) {
|
|
@@ -675,11 +679,11 @@ function Layout({ loadState, loadedData }) {
|
|
|
675
679
|
const url = new URL(window.location.href);
|
|
676
680
|
const initialComponentId = url.searchParams.get('componentId') || state.metadata.id;
|
|
677
681
|
const initialLocale = url.searchParams.get('locale') || locale || 'en';
|
|
678
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Box, { className: "custom-component-root", sx: { height: '100vh', width: '100vw', overflow: 'auto' }, children: (0, jsx_runtime_1.jsx)(
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
682
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Box, { className: "custom-component-root", sx: { height: '100vh', width: '100vw', overflow: 'auto' }, children: (0, jsx_runtime_1.jsx)(components_2.CustomComponentRenderer, { locale: initialLocale, componentId: initialComponentId || state.metadata.id, dev: {
|
|
683
|
+
mode: 'draft',
|
|
684
|
+
components: mergedAllBlocks,
|
|
685
|
+
defaultLocale,
|
|
686
|
+
}, properties: mergedPropertiesValues }, `custom-${renderComponentTrigger}`) }));
|
|
683
687
|
}
|
|
684
688
|
// 没有匹配到路由,使用欢迎页面
|
|
685
689
|
if (notSelectedBlock) {
|
|
@@ -1164,7 +1168,8 @@ const StyledDashboard = (0, material_1.styled)(studio_ui_1.Dashboard) `
|
|
|
1164
1168
|
}
|
|
1165
1169
|
`;
|
|
1166
1170
|
function LayoutWrapper({ loadState, loadedData, ...rest }) {
|
|
1167
|
-
|
|
1171
|
+
const isInsideIframe = useIsInsideIframe();
|
|
1172
|
+
return ((0, jsx_runtime_1.jsx)(material_1.StyledEngineProvider, { injectFirst: true, children: (0, jsx_runtime_1.jsx)(theme_1.PagesKitThemeProvider, { isDashboard: isInsideIframe, children: (0, jsx_runtime_1.jsx)(Toast_1.ToastProvider, { children: (0, jsx_runtime_1.jsx)(context_1.LocaleProvider, { translations: locales_1.translations, fallbackLocale: "en", children: (0, jsx_runtime_1.jsx)(SessionProvider, { serviceHost: basename, protectedRoutes: [`${basename}/*`], children: (0, jsx_runtime_1.jsx)(Layout, { loadState: loadState, loadedData: loadedData }) }) }) }) }) }));
|
|
1168
1173
|
}
|
|
1169
1174
|
exports.default = LayoutWrapper;
|
|
1170
1175
|
function CreateResource({ open, onClose }) {
|