Skip to content

Commit

Permalink
feat: update workspace demo
Browse files Browse the repository at this point in the history
  • Loading branch information
liujuping committed Jan 15, 2024
1 parent 8ff5ca5 commit 7519129
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 11 deletions.
2 changes: 1 addition & 1 deletion demo-workspace/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@alilc/lowcode-react-renderer": "^1.1.2",
"@alilc/lowcode-setter-behavior": "^1.0.0",
"@alilc/lowcode-setter-title": "^1.0.2",
"@alilc/lowcode-types": "latest",
"@alilc/lowcode-types": "^1.3.0",
"antd": "^4.21.4",
"moment": "^2.29.3",
"uuid": "^8.3.2"
Expand Down
41 changes: 36 additions & 5 deletions demo-workspace/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import DefaultSettersDialogRegistryPlugin from './plugins/plugin-default-setters

import appHelper from './appHelper';
import './global.scss';
import { IPublicModelPluginContext } from '@alilc/lowcode-types';
import { IPublicModelPluginContext, IPublicModelResource, IPublicModelWindow, IPublicTypeContextMenuAction } from '@alilc/lowcode-types';

(async function main() {
// 注册应用级资源类型
Expand Down Expand Up @@ -71,28 +71,59 @@ import { IPublicModelPluginContext } from '@alilc/lowcode-types';
await workspace.plugins.register(pluginResourceTabs, {
appKey: 'general',
shape: 'text',
tabContextMenuActions: (ctx: IPublicModelPluginContext, resource: IPublicModelResource): IPublicTypeContextMenuAction[] => {
return [
{
name: 'close',
title: '关闭',
action: () => {
ctx.workspace.removeEditorWindow(resource);
},
},
{
name: 'closeOthers',
title: '关闭其他',
action: () => {
workspace.windows.forEach((editorWindow: IPublicModelWindow) => {
if (editorWindow.resource?.id !== resource.id) {
editorWindow.resource && ctx.workspace.removeEditorWindow(editorWindow.resource);
}
});
},
disabled: () => workspace.windows.length <= 1,
}
]
}
});

// 设计器区域多语言切换
await workspace.plugins.register(SimulatorLocalePlugin);

// 应用级左侧面板
await workspace.plugins.register(pluginViewManagerPane, {
init: controller.init,
contextMenuActions: (ctx: IPublicModelPluginContext) => ([
{
name: 'add',
title: '添加页面',
action: controller.onAddPage,
},
]),
resourceContextMenuActions: (ctx: IPublicModelPluginContext) => ([
resourceContextMenuActions: (ctx: IPublicModelPluginContext, resource: IPublicModelResource) => ([
{
name: 'delete',
title: '删除页面',
action: controller.onDeletePage,
action: () => {
controller.onDeletePage(resource);
},
}
]),
skeletonConfig: {
panelProps: {
width: '200px',
area: 'leftFixedArea',
}
])
},
showIconText: false,
});

init(document.getElementById('lce-container')!, {
Expand Down
7 changes: 2 additions & 5 deletions demo-workspace/src/viewController.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import React from 'react';
import { Dialog, Form, Input, Button } from '@alifd/next';
import * as pluginContext from "@alilc/lowcode-engine";
import { IPublicModelPluginContext, IPublicModelResource } from '@alilc/lowcode-types';

class Controller {
pluginContext?: IPublicModelPluginContext;

init = (ctx: IPublicModelPluginContext) => {
this.pluginContext = ctx;
}
pluginContext?: IPublicModelPluginContext = pluginContext;

onAddPage = () => {
const dialog = Dialog.show({
Expand Down

0 comments on commit 7519129

Please sign in to comment.