@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.
|
@@ -8,12 +8,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
8
8
|
import { createAuthServiceSessionContext } from '@arcblock/did-connect/lib/Session';
|
|
9
9
|
import { useConfig } from '@arcblock/ux/lib/Config';
|
|
10
10
|
import { LocaleProvider, useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
11
|
-
import { ThemeProvider } from '@arcblock/ux/lib/Theme';
|
|
12
11
|
import Toast, { ToastProvider } from '@arcblock/ux/lib/Toast';
|
|
13
12
|
import { createAxios } from '@blocklet/js-sdk';
|
|
14
|
-
import {
|
|
15
|
-
// PageProvider,
|
|
16
|
-
DashboardProvider, } from '@blocklet/pages-kit-inner-components/theme';
|
|
13
|
+
import { PagesKitThemeProvider } from '@blocklet/pages-kit-inner-components/theme';
|
|
17
14
|
// @ts-ignore
|
|
18
15
|
import { BasicInfo, ParametersConfig, PropertiesConfig } from '@blocklet/pages-kit-runtime/components';
|
|
19
16
|
// @ts-ignore
|
|
@@ -55,6 +52,14 @@ const api = createAxios({
|
|
|
55
52
|
componentDid: PAGES_KIT_BLOCK_STUDIO_BLOCKLET_DID,
|
|
56
53
|
});
|
|
57
54
|
const { SessionProvider, SessionContext } = createAuthServiceSessionContext();
|
|
55
|
+
function useIsInsideIframe() {
|
|
56
|
+
const location = useLocation();
|
|
57
|
+
const isInsideIframe = useMemo(() => {
|
|
58
|
+
const url = new URL(window.location.href);
|
|
59
|
+
return url.searchParams.get('simulator') === '1';
|
|
60
|
+
}, [location.href]);
|
|
61
|
+
return isInsideIframe;
|
|
62
|
+
}
|
|
58
63
|
function useSessionContext() {
|
|
59
64
|
const info = useContext(SessionContext);
|
|
60
65
|
return info;
|
|
@@ -274,10 +279,7 @@ function Layout({ loadState, loadedData }) {
|
|
|
274
279
|
const navigate = useNavigate();
|
|
275
280
|
const staticData = useStaticData();
|
|
276
281
|
// 获取当前URL参数判断是否是在iframe内
|
|
277
|
-
const isInsideIframe =
|
|
278
|
-
const url = new URL(window.location.href);
|
|
279
|
-
return url.searchParams.get('simulator') === '1';
|
|
280
|
-
}, [window.location.href]);
|
|
282
|
+
const isInsideIframe = useIsInsideIframe();
|
|
281
283
|
useUpdateEffect(() => {
|
|
282
284
|
const iframe = document.querySelector('#preview-iframe');
|
|
283
285
|
if (iframe && iframe.contentWindow) {
|
|
@@ -639,11 +641,11 @@ function Layout({ loadState, loadedData }) {
|
|
|
639
641
|
const url = new URL(window.location.href);
|
|
640
642
|
const initialComponentId = url.searchParams.get('componentId') || state.metadata.id;
|
|
641
643
|
const initialLocale = url.searchParams.get('locale') || locale || 'en';
|
|
642
|
-
return (_jsx(Box, { className: "custom-component-root", sx: { height: '100vh', width: '100vw', overflow: 'auto' }, children: _jsx(
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
644
|
+
return (_jsx(Box, { className: "custom-component-root", sx: { height: '100vh', width: '100vw', overflow: 'auto' }, children: _jsx(CustomComponentRenderer, { locale: initialLocale, componentId: initialComponentId || state.metadata.id, dev: {
|
|
645
|
+
mode: 'draft',
|
|
646
|
+
components: mergedAllBlocks,
|
|
647
|
+
defaultLocale,
|
|
648
|
+
}, properties: mergedPropertiesValues }, `custom-${renderComponentTrigger}`) }));
|
|
647
649
|
}
|
|
648
650
|
// 没有匹配到路由,使用欢迎页面
|
|
649
651
|
if (notSelectedBlock) {
|
|
@@ -1128,7 +1130,8 @@ const StyledDashboard = styled(Dashboard) `
|
|
|
1128
1130
|
}
|
|
1129
1131
|
`;
|
|
1130
1132
|
function LayoutWrapper({ loadState, loadedData, ...rest }) {
|
|
1131
|
-
|
|
1133
|
+
const isInsideIframe = useIsInsideIframe();
|
|
1134
|
+
return (_jsx(StyledEngineProvider, { injectFirst: true, children: _jsx(PagesKitThemeProvider, { isDashboard: isInsideIframe, children: _jsx(ToastProvider, { children: _jsx(LocaleProvider, { translations: translations, fallbackLocale: "en", children: _jsx(SessionProvider, { serviceHost: basename, protectedRoutes: [`${basename}/*`], children: _jsx(Layout, { loadState: loadState, loadedData: loadedData }) }) }) }) }) }));
|
|
1132
1135
|
}
|
|
1133
1136
|
export default LayoutWrapper;
|
|
1134
1137
|
function CreateResource({ open, onClose }) {
|