diff --git a/packages/shell/src/model/window.ts b/packages/shell/src/model/window.ts index 3e6bd6450..2b5e0dd8c 100644 --- a/packages/shell/src/model/window.ts +++ b/packages/shell/src/model/window.ts @@ -32,7 +32,7 @@ export class Window implements IPublicModelWindow { } changeViewType(viewName: string) { - this[windowSymbol].changeViewType(viewName, false); + this[windowSymbol].changeViewName(viewName, false); } onChangeViewType(fun: (viewName: string) => void): IPublicTypeDisposable { diff --git a/packages/types/src/shell/type/resource-type-config.ts b/packages/types/src/shell/type/resource-type-config.ts index e47afb53d..474987b52 100644 --- a/packages/types/src/shell/type/resource-type-config.ts +++ b/packages/types/src/shell/type/resource-type-config.ts @@ -8,8 +8,14 @@ export interface IPublicResourceTypeConfig { /** 资源 icon 标识 */ icon?: React.ReactElement; + /** + * 默认视图类型 + * @deprecated + */ + defaultViewType?: string; + /** 默认视图类型 */ - defaultViewType: string; + defaultViewName: string; /** 资源视图 */ editorViews: IPublicTypeEditorView[]; diff --git a/packages/workspace/src/resource.ts b/packages/workspace/src/resource.ts index 1d328b6c6..a7ecc59b2 100644 --- a/packages/workspace/src/resource.ts +++ b/packages/workspace/src/resource.ts @@ -16,7 +16,7 @@ export interface IBaseResource extends IBaseModelResource { get editorViews(): IPublicTypeEditorView[]; - get defaultViewType(): string; + get defaultViewName(): string | undefined; getEditorView(name: string): IPublicTypeEditorView | undefined; @@ -41,7 +41,7 @@ export class Resource implements IResource { } get viewName() { - return this.resourceData.viewName || (this.resourceData as any).viewType || this.defaultViewType; + return this.resourceData.viewName || (this.resourceData as any).viewType || this.defaultViewName; } get description() { @@ -116,8 +116,8 @@ export class Resource implements IResource { return this.resourceTypeInstance.editorViews; } - get defaultViewType() { - return this.resourceTypeInstance.defaultViewType; + get defaultViewName() { + return this.resourceTypeInstance.defaultViewName || this.resourceTypeInstance.defaultViewType; } getEditorView(name: string) { diff --git a/packages/workspace/src/window.ts b/packages/workspace/src/window.ts index b6e345f19..2c670346f 100644 --- a/packages/workspace/src/window.ts +++ b/packages/workspace/src/window.ts @@ -8,7 +8,7 @@ import { IPublicModelWindow, IPublicTypeDisposable } from '@alilc/lowcode-types' interface IWindowCOnfig { title: string | undefined; options?: Object; - viewType?: string | undefined; + viewName?: string | undefined; sleep?: boolean; } @@ -19,7 +19,7 @@ export interface IEditorWindow extends Omit, 'chan editorView: IViewContext; - changeViewType: (name: string, ignoreEmit?: boolean) => void; + changeViewName: (name: string, ignoreEmit?: boolean) => void; initReady: boolean; @@ -130,7 +130,7 @@ export class EditorWindow implements IEditorWindow { this.workspace.emitWindowRendererReady(); }); this.url = await this.resource.url(); - this.setDefaultViewType(); + this.setDefaultViewName(); this.initReady = true; this.workspace.checkWindowQueue(); this.sleep = false; @@ -146,7 +146,7 @@ export class EditorWindow implements IEditorWindow { const name = editorViews[i].viewName; await this.initViewType(name); if (!this.editorView) { - this.changeViewType(name); + this.changeViewName(name); } } }; @@ -166,13 +166,13 @@ export class EditorWindow implements IEditorWindow { } for (let i = 0; i < editorViews.length; i++) { const name = editorViews[i].viewName; - this.changeViewType(name); + this.changeViewName(name); await this.editorViews.get(name)?.init(); } }; - setDefaultViewType = () => { - this.changeViewType(this.config.viewType ?? this.resource.defaultViewType); + setDefaultViewName = () => { + this.changeViewName(this.config.viewName ?? this.resource.defaultViewName!); }; get resourceType() { @@ -188,7 +188,7 @@ export class EditorWindow implements IEditorWindow { this.editorViews.set(name, editorView); }; - changeViewType = (name: string, ignoreEmit: boolean = true) => { + changeViewName = (name: string, ignoreEmit: boolean = true) => { this.editorView?.setActivate(false); this.editorView = this.editorViews.get(name)!; diff --git a/packages/workspace/src/workspace.ts b/packages/workspace/src/workspace.ts index e180d4a2f..41be09fcf 100644 --- a/packages/workspace/src/workspace.ts +++ b/packages/workspace/src/workspace.ts @@ -95,7 +95,7 @@ export class Workspace implements IWorkspace { name: string; title: string; options: Object; - viewType?: string; + viewName?: string; }[] = []; constructor( @@ -114,7 +114,7 @@ export class Workspace implements IWorkspace { const windowInfo = this.windowQueue.shift(); if (windowInfo) { - this.openEditorWindow(windowInfo.name, windowInfo.title, windowInfo.options, windowInfo.viewType); + this.openEditorWindow(windowInfo.name, windowInfo.title, windowInfo.options, windowInfo.viewName); } } @@ -228,10 +228,10 @@ export class Workspace implements IWorkspace { this.window?.updateState(WINDOW_STATE.active); } - async openEditorWindow(name: string, title: string, options: Object, viewType?: string, sleep?: boolean) { + async openEditorWindow(name: string, title: string, options: Object, viewName?: string, sleep?: boolean) { if (this.window && !this.window?.initReady && !sleep) { this.windowQueue.push({ - name, title, options, viewType, + name, title, options, viewName, }); return; } @@ -261,7 +261,7 @@ export class Workspace implements IWorkspace { const window = new EditorWindow(resource, this, { title, options, - viewType, + viewName, sleep, }); this.windows = [...this.windows, window];