Skip to content

Commit 0164891

Browse files
author
暁仙
committedMay 8, 2024·
doc: 更新示例 demo 说明
1 parent ed072f0 commit 0164891

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed
 

‎demo-general/src/preview.tsx

+14-5
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,19 @@ import { buildComponents, assetBundle, AssetLevel, AssetLoader } from '@alilc/lo
77
import ReactRenderer from '@alilc/lowcode-react-renderer';
88
import { injectComponents } from '@alilc/lowcode-plugin-inject';
99
import appHelper from './appHelper';
10-
import { getProjectSchemaFromLocalStorage, getPackagesFromLocalStorage, getPreviewLocale, setPreviewLocale } from './services/mockService';
10+
import {
11+
getProjectSchemaFromLocalStorage,
12+
getPackagesFromLocalStorage,
13+
getPreviewLocale,
14+
setPreviewLocale,
15+
} from './services/mockService';
1116

1217
const getScenarioName = function () {
1318
if (location.search) {
1419
return new URLSearchParams(location.search.slice(1)).get('scenarioName') || 'general';
1520
}
1621
return 'general';
17-
}
22+
};
1823

1924
const SamplePreview = () => {
2025
const [data, setData] = useState({});
@@ -51,8 +56,11 @@ const SamplePreview = () => {
5156
// TODO asset may cause pollution
5257
const assetLoader = new AssetLoader();
5358
await assetLoader.load(libraryAsset);
54-
const components = await injectComponents(buildComponents(libraryMap, componentsMap));
55-
59+
60+
// injectComponents 的使用一般在开发环境做调试注入使用(详细见文档),一般纯净的预览环境是不依赖此插件
61+
// The use of injectComponents is generally used for debugging and injection in the development environment (see the documentation for details). The generally destroyed preview environment does not rely on this plug-in.
62+
// const components = await injectComponents(buildComponents(libraryMap, componentsMap));
63+
const components = buildComponents(libraryMap, componentsMap);
5664
setData({
5765
schema: pageSchema,
5866
components,
@@ -72,7 +80,8 @@ const SamplePreview = () => {
7280
if (!(window as any).setPreviewLocale) {
7381
// for demo use only, can use this in console to switch language for i18n test
7482
// 在控制台 window.setPreviewLocale('en-US') 或 window.setPreviewLocale('zh-CN') 查看切换效果
75-
(window as any).setPreviewLocale = (locale:string) => setPreviewLocale(getScenarioName(), locale);
83+
(window as any).setPreviewLocale = (locale: string) =>
84+
setPreviewLocale(getScenarioName(), locale);
7685
}
7786

7887
function customizer(objValue: [], srcValue: []) {

0 commit comments

Comments
 (0)
Please sign in to comment.