diff --git a/packages/editor-core/src/config.ts b/packages/editor-core/src/config.ts index c325c2bb8..85e609780 100644 --- a/packages/editor-core/src/config.ts +++ b/packages/editor-core/src/config.ts @@ -155,6 +155,10 @@ const VALID_ENGINE_OPTIONS = { description: '是否开启应用级设计模式', default: false, }, + workspaceEmptyComponent: { + type: 'function', + description: '应用级设计模式下,窗口为空时展示的占位组件', + }, }; const getStrictModeValue = (engineOptions: IPublicTypeEngineOptions, defaultValue: boolean): boolean => { diff --git a/packages/workspace/src/layouts/workbench.tsx b/packages/workspace/src/layouts/workbench.tsx index 0c69f9717..08d6dc1a9 100644 --- a/packages/workspace/src/layouts/workbench.tsx +++ b/packages/workspace/src/layouts/workbench.tsx @@ -1,5 +1,5 @@ import { Component } from 'react'; -import { TipContainer, observer } from '@alilc/lowcode-editor-core'; +import { TipContainer, engineConfig, observer } from '@alilc/lowcode-editor-core'; import { WindowView } from '../view/window-view'; import classNames from 'classnames'; import TopArea from './top-area'; @@ -21,17 +21,29 @@ export class Workbench extends Component<{ components?: PluginClassSet; className?: string; topAreaItemClassName?: string; +}, { + workspaceEmptyComponent: any; }> { constructor(props: any) { super(props); const { config, components, workspace } = this.props; const { skeleton } = workspace; skeleton.buildFromConfig(config, components); + engineConfig.onGot('workspaceEmptyComponent', (workspaceEmptyComponent) => { + this.setState({ + workspaceEmptyComponent, + }); + }); + this.state = { + workspaceEmptyComponent: engineConfig.get('workspaceEmptyComponent'), + }; } render() { const { workspace, className, topAreaItemClassName } = this.props; const { skeleton } = workspace; + const WorkspaceEmptyComponent = this.state.workspaceEmptyComponent; + return (
@@ -53,6 +65,10 @@ export class Workbench extends Component<{ /> )) } + + { + !workspace.windows.length && WorkspaceEmptyComponent ? : null + }
diff --git a/packages/workspace/src/workspace.ts b/packages/workspace/src/workspace.ts index bedae8680..6c35d8b35 100644 --- a/packages/workspace/src/workspace.ts +++ b/packages/workspace/src/workspace.ts @@ -199,7 +199,7 @@ export class Workspace implements IWorkspace { this.windows.splice(index, 1); if (this.window === window) { this.window = this.windows[index] || this.windows[index + 1] || this.windows[index - 1]; - if (this.window.sleep) { + if (this.window?.sleep) { this.window.init(); } this.emitChangeActiveWindow();