@blocklet/pages-kit 0.5.53 → 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.
|
@@ -34,6 +34,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
34
34
|
const css_1 = require("@emotion/css");
|
|
35
35
|
const material_1 = require("@mui/material");
|
|
36
36
|
const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
|
|
37
|
+
const omit_1 = __importDefault(require("lodash/omit"));
|
|
37
38
|
const set_1 = __importDefault(require("lodash/set"));
|
|
38
39
|
const react_1 = require("react");
|
|
39
40
|
const react_helmet_1 = require("react-helmet");
|
|
@@ -323,21 +324,25 @@ function usePreloadComponent({ instanceId, componentId, properties, locale, dev
|
|
|
323
324
|
const realLocale = getRealLocale(locale);
|
|
324
325
|
const result = getComponentByComponentId({ componentId, locale: realLocale, instanceId });
|
|
325
326
|
if (result) {
|
|
326
|
-
|
|
327
|
+
// 只缓存 props 以外的数据,props 会跟随语言动态更新
|
|
328
|
+
previousRef.current = (0, omit_1.default)(result, 'props');
|
|
327
329
|
return result;
|
|
328
330
|
}
|
|
329
331
|
if (instanceId) {
|
|
330
332
|
const key = [instanceId, realLocale].join('-');
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
.
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
333
|
+
const componentState = (0, exports.customComponentStates)().getState();
|
|
334
|
+
COMPONENT_LOADER_MAP[key] ??=
|
|
335
|
+
Promise.resolve(componentState.getComponent({ componentId, locale: realLocale ?? dev?.defaultLocale ?? 'en' })) ??
|
|
336
|
+
componentState.loadComponents({
|
|
337
|
+
mode: dev?.mode,
|
|
338
|
+
projectId: dev?.projectId ?? window.__PROJECT_ID__,
|
|
339
|
+
locale: realLocale,
|
|
340
|
+
instances: [{ id: instanceId, component: { id: componentId }, properties }],
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
// 如果前置 preload 已经触发过了,直接返回,不再触发下面的 /preload 逻辑
|
|
344
|
+
if (previousRef.current) {
|
|
345
|
+
return previousRef.current;
|
|
341
346
|
}
|
|
342
347
|
return null;
|
|
343
348
|
}
|