Skip to content

Commit c3d75b2

Browse files
liujupingJackLian
authored andcommitted
feat(workspace): add config for resource shell model
1 parent 5b14230 commit c3d75b2

File tree

8 files changed

+26
-3
lines changed

8 files changed

+26
-3
lines changed

packages/designer/src/plugin/plugin-context.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import {
1717
IPublicTypePluginDeclaration,
1818
IPublicApiCanvas,
1919
IPublicApiWorkspace,
20+
IPublicEnumPluginRegisterLevel,
21+
IPublicModelWindow,
2022
} from '@alilc/lowcode-types';
2123
import {
2224
IPluginContextOptions,
@@ -41,6 +43,8 @@ export default class PluginContext implements
4143
pluginEvent: IPublicApiEvent;
4244
canvas: IPublicApiCanvas;
4345
workspace: IPublicApiWorkspace;
46+
registerLevel: IPublicEnumPluginRegisterLevel;
47+
editorWindow: IPublicModelWindow;
4448

4549
constructor(
4650
options: IPluginContextOptions,

packages/shell/src/model/resource.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ export class Resource implements IPublicModelResource {
2525
return this[resourceSymbol].resourceType.name;
2626
}
2727

28+
get config() {
29+
return this[resourceSymbol].config;
30+
}
31+
2832
get type() {
2933
return this[resourceSymbol].resourceType.type;
3034
}

packages/shell/src/model/window.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ export class Window implements IPublicModelWindow {
4444
}
4545

4646
get currentEditorView() {
47-
return new EditorView(this[windowSymbol].editorView).toProxy() as any;
47+
if (this[windowSymbol].editorView) {
48+
return new EditorView(this[windowSymbol].editorView).toProxy() as any;
49+
}
50+
return null;
4851
}
4952

5053
get editorViews() {

packages/types/src/shell/model/resource.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ export interface IBaseModelResource<
1818
get children(): Resource[];
1919

2020
get viewName(): string | undefined;
21+
22+
get config(): {
23+
disableBehaviors?: ('copy' | 'remove')[];
24+
} | undefined;
2125
}
2226

2327
export type IPublicModelResource = IBaseModelResource<IPublicModelResource>;

packages/types/src/shell/model/window.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export interface IPublicModelWindow<
2323
* 窗口当前视图
2424
* @since v1.1.7
2525
*/
26-
currentEditorView: IPublicModelEditorView;
26+
currentEditorView: IPublicModelEditorView | null;
2727

2828
/**
2929
* 窗口全部视图实例

packages/types/src/shell/type/resource-list.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ export interface IPublicResourceData {
2424

2525
/** 资源子元素 */
2626
children?: IPublicResourceData[];
27+
28+
config?: {
29+
disableBehaviors?: ('copy' | 'remove')[];
30+
};
2731
}
2832

2933
export type IPublicResourceList = IPublicResourceData[];

packages/workspace/src/context/base-context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export class BasicContext implements IBasicContext {
101101
preference: IPluginPreferenceMananger;
102102
workspace: IWorkspace;
103103

104-
constructor(innerWorkspace: IWorkspace, viewName: string, registerLevel: IPublicEnumPluginRegisterLevel, public editorWindow?: IEditorWindow) {
104+
constructor(innerWorkspace: IWorkspace, viewName: string, readonly registerLevel: IPublicEnumPluginRegisterLevel, public editorWindow?: IEditorWindow) {
105105
const editor = new Editor(viewName, true);
106106

107107
const innerSkeleton = new InnerSkeleton(editor, viewName);

packages/workspace/src/resource.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ export class Resource implements IResource {
7474
return this.resourceData?.children?.map(d => new Resource(d, this.workspace.getResourceType(d.resourceName || this.resourceType.name), this.workspace)) || [];
7575
}
7676

77+
get config() {
78+
return this.resourceData.config;
79+
}
80+
7781
constructor(readonly resourceData: IPublicResourceData, readonly resourceType: IResourceType, readonly workspace: IWorkspace) {
7882
this.context = new BasicContext(workspace, `resource-${resourceData.resourceName || resourceType.name}`, IPublicEnumPluginRegisterLevel.Resource);
7983
this.resourceTypeInstance = resourceType.resourceTypeModel(this.context.innerPlugins._getLowCodePluginContext({

0 commit comments

Comments
 (0)