From 016489150f0f3b759b312967e2439883c8bff4b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9A=81=E4=BB=99?= Date: Wed, 8 May 2024 10:55:03 +0800 Subject: [PATCH] =?UTF-8?q?doc:=20=E6=9B=B4=E6=96=B0=E7=A4=BA=E4=BE=8B=20d?= =?UTF-8?q?emo=20=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo-general/src/preview.tsx | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/demo-general/src/preview.tsx b/demo-general/src/preview.tsx index 97d8c0a4..6a877b8b 100644 --- a/demo-general/src/preview.tsx +++ b/demo-general/src/preview.tsx @@ -7,14 +7,19 @@ import { buildComponents, assetBundle, AssetLevel, AssetLoader } from '@alilc/lo import ReactRenderer from '@alilc/lowcode-react-renderer'; import { injectComponents } from '@alilc/lowcode-plugin-inject'; import appHelper from './appHelper'; -import { getProjectSchemaFromLocalStorage, getPackagesFromLocalStorage, getPreviewLocale, setPreviewLocale } from './services/mockService'; +import { + getProjectSchemaFromLocalStorage, + getPackagesFromLocalStorage, + getPreviewLocale, + setPreviewLocale, +} from './services/mockService'; const getScenarioName = function () { if (location.search) { return new URLSearchParams(location.search.slice(1)).get('scenarioName') || 'general'; } return 'general'; -} +}; const SamplePreview = () => { const [data, setData] = useState({}); @@ -51,8 +56,11 @@ const SamplePreview = () => { // TODO asset may cause pollution const assetLoader = new AssetLoader(); await assetLoader.load(libraryAsset); - const components = await injectComponents(buildComponents(libraryMap, componentsMap)); - + + // injectComponents 的使用一般在开发环境做调试注入使用(详细见文档),一般纯净的预览环境是不依赖此插件 + // 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. + // const components = await injectComponents(buildComponents(libraryMap, componentsMap)); + const components = buildComponents(libraryMap, componentsMap); setData({ schema: pageSchema, components, @@ -72,7 +80,8 @@ const SamplePreview = () => { if (!(window as any).setPreviewLocale) { // for demo use only, can use this in console to switch language for i18n test // 在控制台 window.setPreviewLocale('en-US') 或 window.setPreviewLocale('zh-CN') 查看切换效果 - (window as any).setPreviewLocale = (locale:string) => setPreviewLocale(getScenarioName(), locale); + (window as any).setPreviewLocale = (locale: string) => + setPreviewLocale(getScenarioName(), locale); } function customizer(objValue: [], srcValue: []) {