From bdfd6e9f135a09fb9ec1aa274822b1cb2d8e57e8 Mon Sep 17 00:00:00 2001 From: liujuping Date: Thu, 17 Nov 2022 20:49:59 +0800 Subject: [PATCH] fix: init --- src/scenarios/index/index.ts | 21 +++++++++++---------- src/universal/plugin.tsx | 8 +++++--- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/scenarios/index/index.ts b/src/scenarios/index/index.ts index 2c69d61..6ee9f9c 100644 --- a/src/scenarios/index/index.ts +++ b/src/scenarios/index/index.ts @@ -2,26 +2,26 @@ import { init, plugins, workSpace } from '@alilc/lowcode-engine'; import { createFetchHandler } from '@alilc/lowcode-datasource-fetch-handler' import registerPlugins from '../../universal/plugin'; -import ComponentsPane from '@alilc/lowcode-plugin-components-pane'; +// import ComponentsPane from '@alilc/lowcode-plugin-components-pane'; import { scenarioSwitcher, viewSwitcher } from '../../sample-plugins/scenario-switcher'; // import Logo from '../sample-plugins/logo'; -import ZhEnPlugin from '@alilc/lowcode-plugin-zh-en'; -import UndoRedoPlugin from '@alilc/lowcode-plugin-undo-redo'; +// import ZhEnPlugin from '@alilc/lowcode-plugin-zh-en'; +// import UndoRedoPlugin from '@alilc/lowcode-plugin-undo-redo'; import '../../universal/global.scss'; (async function main() { - // await plugins.register(scenarioSwitcher); - // await registerPlugins(); - const ViewA = { name: 'editorViewA', // 资源初始化 async init(ctx: any) { // 注册 plugin - ctx.plugins.register(UndoRedoPlugin); + // ctx.plugins.register(UndoRedoPlugin); ctx.plugins.register(viewSwitcher, { switchTo: 'editorViewB' }); + await ctx.plugins.register(scenarioSwitcher); + await registerPlugins(ctx); + // ctx.plugins.register(scenarioSwitcher); }, async save(resource: any) {}, } @@ -36,6 +36,7 @@ import '../../universal/global.scss'; ctx.plugins.register(viewSwitcher, { switchTo: 'editorViewA' }); + await registerPlugins(ctx); }, async save(resource: any) {}, } @@ -50,8 +51,8 @@ import '../../universal/global.scss'; // 资源初始化 async init(ctx: any) { // 注册 plugin - ctx.plugins.register(ComponentsPane); - ctx.skeleton.add() + // ctx.plugins.register(ComponentsPane); + // ctx.skeleton.add() }, async dispose() {}, }); @@ -72,6 +73,6 @@ import '../../universal/global.scss'; fetch: createFetchHandler() }, // @ts-ignore - // enableWorkspaceMode: true, + enableWorkspaceMode: true, }); })(); diff --git a/src/universal/plugin.tsx b/src/universal/plugin.tsx index 2a80edc..1bc21f3 100644 --- a/src/universal/plugin.tsx +++ b/src/universal/plugin.tsx @@ -1,8 +1,8 @@ import React from 'react'; import { ILowCodePluginContext, - plugins, - project, + // plugins, + // project, } from '@alilc/lowcode-engine'; import AliLowCodeEngineExt from '@alilc/lowcode-engine-ext'; import { Button } from '@alifd/next'; @@ -34,7 +34,9 @@ import { import assets from './assets.json' import { registerRefProp } from 'src/sample-plugins/set-ref-prop'; -export default async function registerPlugins() { +export default async function registerPlugins(ctx: any) { + const project = ctx.project; + const plugins = ctx.plugins; await plugins.register(ManualPlugin); await plugins.register(Inject);