mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-11 02:12:56 +00:00
refactor: defaultViewType renamed to defaultViewName
This commit is contained in:
parent
8117b450ba
commit
89b666dab8
@ -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 {
|
||||
|
||||
@ -8,8 +8,14 @@ export interface IPublicResourceTypeConfig {
|
||||
/** 资源 icon 标识 */
|
||||
icon?: React.ReactElement;
|
||||
|
||||
/**
|
||||
* 默认视图类型
|
||||
* @deprecated
|
||||
*/
|
||||
defaultViewType?: string;
|
||||
|
||||
/** 默认视图类型 */
|
||||
defaultViewType: string;
|
||||
defaultViewName: string;
|
||||
|
||||
/** 资源视图 */
|
||||
editorViews: IPublicTypeEditorView[];
|
||||
|
||||
@ -16,7 +16,7 @@ export interface IBaseResource<T> extends IBaseModelResource<T> {
|
||||
|
||||
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) {
|
||||
|
||||
@ -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<IPublicModelWindow<IResource>, '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)!;
|
||||
|
||||
|
||||
@ -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];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user