feat: add config.workspaceEmptyComponent

This commit is contained in:
liujuping 2023-07-12 18:01:45 +08:00 committed by 林熠
parent 2d98f1c9b5
commit aa1bb1c0d7
3 changed files with 22 additions and 2 deletions

View File

@ -155,6 +155,10 @@ const VALID_ENGINE_OPTIONS = {
description: '是否开启应用级设计模式',
default: false,
},
workspaceEmptyComponent: {
type: 'function',
description: '应用级设计模式下,窗口为空时展示的占位组件',
},
};
const getStrictModeValue = (engineOptions: IPublicTypeEngineOptions, defaultValue: boolean): boolean => {

View File

@ -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 (
<div className={classNames('lc-workspace-workbench', className)}>
<SkeletonContext.Provider value={skeleton}>
@ -53,6 +65,10 @@ export class Workbench extends Component<{
/>
))
}
{
!workspace.windows.length && WorkspaceEmptyComponent ? <WorkspaceEmptyComponent /> : null
}
</div>
</div>
<MainArea area={skeleton.mainArea} />

View File

@ -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();