feat(workspace): add config for resource shell model

This commit is contained in:
liujuping 2023-04-26 10:24:17 +08:00 committed by 林熠
parent 5b1423068e
commit c3d75b27da
8 changed files with 26 additions and 3 deletions

View File

@ -17,6 +17,8 @@ import {
IPublicTypePluginDeclaration, IPublicTypePluginDeclaration,
IPublicApiCanvas, IPublicApiCanvas,
IPublicApiWorkspace, IPublicApiWorkspace,
IPublicEnumPluginRegisterLevel,
IPublicModelWindow,
} from '@alilc/lowcode-types'; } from '@alilc/lowcode-types';
import { import {
IPluginContextOptions, IPluginContextOptions,
@ -41,6 +43,8 @@ export default class PluginContext implements
pluginEvent: IPublicApiEvent; pluginEvent: IPublicApiEvent;
canvas: IPublicApiCanvas; canvas: IPublicApiCanvas;
workspace: IPublicApiWorkspace; workspace: IPublicApiWorkspace;
registerLevel: IPublicEnumPluginRegisterLevel;
editorWindow: IPublicModelWindow;
constructor( constructor(
options: IPluginContextOptions, options: IPluginContextOptions,

View File

@ -25,6 +25,10 @@ export class Resource implements IPublicModelResource {
return this[resourceSymbol].resourceType.name; return this[resourceSymbol].resourceType.name;
} }
get config() {
return this[resourceSymbol].config;
}
get type() { get type() {
return this[resourceSymbol].resourceType.type; return this[resourceSymbol].resourceType.type;
} }

View File

@ -44,8 +44,11 @@ export class Window implements IPublicModelWindow {
} }
get currentEditorView() { get currentEditorView() {
if (this[windowSymbol].editorView) {
return new EditorView(this[windowSymbol].editorView).toProxy() as any; return new EditorView(this[windowSymbol].editorView).toProxy() as any;
} }
return null;
}
get editorViews() { get editorViews() {
return Array.from(this[windowSymbol].editorViews.values()).map(d => new EditorView(d).toProxy() as any); return Array.from(this[windowSymbol].editorViews.values()).map(d => new EditorView(d).toProxy() as any);

View File

@ -18,6 +18,10 @@ export interface IBaseModelResource<
get children(): Resource[]; get children(): Resource[];
get viewName(): string | undefined; get viewName(): string | undefined;
get config(): {
disableBehaviors?: ('copy' | 'remove')[];
} | undefined;
} }
export type IPublicModelResource = IBaseModelResource<IPublicModelResource>; export type IPublicModelResource = IBaseModelResource<IPublicModelResource>;

View File

@ -23,7 +23,7 @@ export interface IPublicModelWindow<
* *
* @since v1.1.7 * @since v1.1.7
*/ */
currentEditorView: IPublicModelEditorView; currentEditorView: IPublicModelEditorView | null;
/** /**
* *

View File

@ -24,6 +24,10 @@ export interface IPublicResourceData {
/** 资源子元素 */ /** 资源子元素 */
children?: IPublicResourceData[]; children?: IPublicResourceData[];
config?: {
disableBehaviors?: ('copy' | 'remove')[];
};
} }
export type IPublicResourceList = IPublicResourceData[]; export type IPublicResourceList = IPublicResourceData[];

View File

@ -101,7 +101,7 @@ export class BasicContext implements IBasicContext {
preference: IPluginPreferenceMananger; preference: IPluginPreferenceMananger;
workspace: IWorkspace; workspace: IWorkspace;
constructor(innerWorkspace: IWorkspace, viewName: string, registerLevel: IPublicEnumPluginRegisterLevel, public editorWindow?: IEditorWindow) { constructor(innerWorkspace: IWorkspace, viewName: string, readonly registerLevel: IPublicEnumPluginRegisterLevel, public editorWindow?: IEditorWindow) {
const editor = new Editor(viewName, true); const editor = new Editor(viewName, true);
const innerSkeleton = new InnerSkeleton(editor, viewName); const innerSkeleton = new InnerSkeleton(editor, viewName);

View File

@ -74,6 +74,10 @@ export class Resource implements IResource {
return this.resourceData?.children?.map(d => new Resource(d, this.workspace.getResourceType(d.resourceName || this.resourceType.name), this.workspace)) || []; return this.resourceData?.children?.map(d => new Resource(d, this.workspace.getResourceType(d.resourceName || this.resourceType.name), this.workspace)) || [];
} }
get config() {
return this.resourceData.config;
}
constructor(readonly resourceData: IPublicResourceData, readonly resourceType: IResourceType, readonly workspace: IWorkspace) { constructor(readonly resourceData: IPublicResourceData, readonly resourceType: IResourceType, readonly workspace: IWorkspace) {
this.context = new BasicContext(workspace, `resource-${resourceData.resourceName || resourceType.name}`, IPublicEnumPluginRegisterLevel.Resource); this.context = new BasicContext(workspace, `resource-${resourceData.resourceName || resourceType.name}`, IPublicEnumPluginRegisterLevel.Resource);
this.resourceTypeInstance = resourceType.resourceTypeModel(this.context.innerPlugins._getLowCodePluginContext({ this.resourceTypeInstance = resourceType.resourceTypeModel(this.context.innerPlugins._getLowCodePluginContext({