Skip to content

Commit aa1bb1c

Browse files
liujupingJackLian
authored andcommitted
feat: add config.workspaceEmptyComponent
1 parent 2d98f1c commit aa1bb1c

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

packages/editor-core/src/config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ const VALID_ENGINE_OPTIONS = {
155155
description: '是否开启应用级设计模式',
156156
default: false,
157157
},
158+
workspaceEmptyComponent: {
159+
type: 'function',
160+
description: '应用级设计模式下,窗口为空时展示的占位组件',
161+
},
158162
};
159163

160164
const getStrictModeValue = (engineOptions: IPublicTypeEngineOptions, defaultValue: boolean): boolean => {

packages/workspace/src/layouts/workbench.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component } from 'react';
2-
import { TipContainer, observer } from '@alilc/lowcode-editor-core';
2+
import { TipContainer, engineConfig, observer } from '@alilc/lowcode-editor-core';
33
import { WindowView } from '../view/window-view';
44
import classNames from 'classnames';
55
import TopArea from './top-area';
@@ -21,17 +21,29 @@ export class Workbench extends Component<{
2121
components?: PluginClassSet;
2222
className?: string;
2323
topAreaItemClassName?: string;
24+
}, {
25+
workspaceEmptyComponent: any;
2426
}> {
2527
constructor(props: any) {
2628
super(props);
2729
const { config, components, workspace } = this.props;
2830
const { skeleton } = workspace;
2931
skeleton.buildFromConfig(config, components);
32+
engineConfig.onGot('workspaceEmptyComponent', (workspaceEmptyComponent) => {
33+
this.setState({
34+
workspaceEmptyComponent,
35+
});
36+
});
37+
this.state = {
38+
workspaceEmptyComponent: engineConfig.get('workspaceEmptyComponent'),
39+
};
3040
}
3141

3242
render() {
3343
const { workspace, className, topAreaItemClassName } = this.props;
3444
const { skeleton } = workspace;
45+
const WorkspaceEmptyComponent = this.state.workspaceEmptyComponent;
46+
3547
return (
3648
<div className={classNames('lc-workspace-workbench', className)}>
3749
<SkeletonContext.Provider value={skeleton}>
@@ -53,6 +65,10 @@ export class Workbench extends Component<{
5365
/>
5466
))
5567
}
68+
69+
{
70+
!workspace.windows.length && WorkspaceEmptyComponent ? <WorkspaceEmptyComponent /> : null
71+
}
5672
</div>
5773
</div>
5874
<MainArea area={skeleton.mainArea} />

packages/workspace/src/workspace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ export class Workspace implements IWorkspace {
199199
this.windows.splice(index, 1);
200200
if (this.window === window) {
201201
this.window = this.windows[index] || this.windows[index + 1] || this.windows[index - 1];
202-
if (this.window.sleep) {
202+
if (this.window?.sleep) {
203203
this.window.init();
204204
}
205205
this.emitChangeActiveWindow();

0 commit comments

Comments
 (0)