@blocklet/pages-kit-block-studio 0.5.27 → 0.5.28

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.
@@ -128,6 +128,11 @@ function Layout({ loadState, loadedData }) {
128
128
  const location = useLocation();
129
129
  const navigate = useNavigate();
130
130
  const staticData = useStaticData();
131
+ // 获取当前URL参数判断是否是在iframe内
132
+ const isInsideIframe = useMemo(() => {
133
+ const url = new URL(window.location.href);
134
+ return url.searchParams.get('simulator') === '1';
135
+ }, [window.location.href]);
131
136
  useUpdateEffect(() => {
132
137
  const iframe = document.querySelector('#preview-iframe');
133
138
  if (iframe && iframe.contentWindow) {
@@ -225,8 +230,9 @@ function Layout({ loadState, loadedData }) {
225
230
  }
226
231
  }, { wait: 500 });
227
232
  useEffect(() => {
228
- debouncedUpdateMetadata.run(state.metadata);
229
- }, [state.metadata, debouncedUpdateMetadata]);
233
+ if (!isInsideIframe)
234
+ debouncedUpdateMetadata.run(state.metadata);
235
+ }, [state.metadata, debouncedUpdateMetadata, isInsideIframe]);
230
236
  const mergedAllBlocks = useMemo(() => {
231
237
  // Add all staticData code and importPath mappings
232
238
  if (import.meta.env.DEV) {
@@ -319,11 +325,6 @@ function Layout({ loadState, loadedData }) {
319
325
  url.searchParams.set('locale', locale || defaultLocale || 'en');
320
326
  return url.toString();
321
327
  }, [window.location.href, state.metadata.id, locale, defaultLocale]);
322
- // 获取当前URL参数判断是否是在iframe内
323
- const isInsideIframe = useMemo(() => {
324
- const url = new URL(window.location.href);
325
- return url.searchParams.get('simulator') === '1';
326
- }, [window.location.href]);
327
328
  // 添加消息事件监听
328
329
  useEffect(() => {
329
330
  const handleMessage = (event) => {