mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-11 10:34:02 +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) {
|
changeViewType(viewName: string) {
|
||||||
this[windowSymbol].changeViewType(viewName, false);
|
this[windowSymbol].changeViewName(viewName, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
onChangeViewType(fun: (viewName: string) => void): IPublicTypeDisposable {
|
onChangeViewType(fun: (viewName: string) => void): IPublicTypeDisposable {
|
||||||
|
|||||||
@ -8,8 +8,14 @@ export interface IPublicResourceTypeConfig {
|
|||||||
/** 资源 icon 标识 */
|
/** 资源 icon 标识 */
|
||||||
icon?: React.ReactElement;
|
icon?: React.ReactElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认视图类型
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
defaultViewType?: string;
|
||||||
|
|
||||||
/** 默认视图类型 */
|
/** 默认视图类型 */
|
||||||
defaultViewType: string;
|
defaultViewName: string;
|
||||||
|
|
||||||
/** 资源视图 */
|
/** 资源视图 */
|
||||||
editorViews: IPublicTypeEditorView[];
|
editorViews: IPublicTypeEditorView[];
|
||||||
|
|||||||
@ -16,7 +16,7 @@ export interface IBaseResource<T> extends IBaseModelResource<T> {
|
|||||||
|
|
||||||
get editorViews(): IPublicTypeEditorView[];
|
get editorViews(): IPublicTypeEditorView[];
|
||||||
|
|
||||||
get defaultViewType(): string;
|
get defaultViewName(): string | undefined;
|
||||||
|
|
||||||
getEditorView(name: string): IPublicTypeEditorView | undefined;
|
getEditorView(name: string): IPublicTypeEditorView | undefined;
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ export class Resource implements IResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get viewName() {
|
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() {
|
get description() {
|
||||||
@ -116,8 +116,8 @@ export class Resource implements IResource {
|
|||||||
return this.resourceTypeInstance.editorViews;
|
return this.resourceTypeInstance.editorViews;
|
||||||
}
|
}
|
||||||
|
|
||||||
get defaultViewType() {
|
get defaultViewName() {
|
||||||
return this.resourceTypeInstance.defaultViewType;
|
return this.resourceTypeInstance.defaultViewName || this.resourceTypeInstance.defaultViewType;
|
||||||
}
|
}
|
||||||
|
|
||||||
getEditorView(name: string) {
|
getEditorView(name: string) {
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import { IPublicModelWindow, IPublicTypeDisposable } from '@alilc/lowcode-types'
|
|||||||
interface IWindowCOnfig {
|
interface IWindowCOnfig {
|
||||||
title: string | undefined;
|
title: string | undefined;
|
||||||
options?: Object;
|
options?: Object;
|
||||||
viewType?: string | undefined;
|
viewName?: string | undefined;
|
||||||
sleep?: boolean;
|
sleep?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ export interface IEditorWindow extends Omit<IPublicModelWindow<IResource>, 'chan
|
|||||||
|
|
||||||
editorView: IViewContext;
|
editorView: IViewContext;
|
||||||
|
|
||||||
changeViewType: (name: string, ignoreEmit?: boolean) => void;
|
changeViewName: (name: string, ignoreEmit?: boolean) => void;
|
||||||
|
|
||||||
initReady: boolean;
|
initReady: boolean;
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ export class EditorWindow implements IEditorWindow {
|
|||||||
this.workspace.emitWindowRendererReady();
|
this.workspace.emitWindowRendererReady();
|
||||||
});
|
});
|
||||||
this.url = await this.resource.url();
|
this.url = await this.resource.url();
|
||||||
this.setDefaultViewType();
|
this.setDefaultViewName();
|
||||||
this.initReady = true;
|
this.initReady = true;
|
||||||
this.workspace.checkWindowQueue();
|
this.workspace.checkWindowQueue();
|
||||||
this.sleep = false;
|
this.sleep = false;
|
||||||
@ -146,7 +146,7 @@ export class EditorWindow implements IEditorWindow {
|
|||||||
const name = editorViews[i].viewName;
|
const name = editorViews[i].viewName;
|
||||||
await this.initViewType(name);
|
await this.initViewType(name);
|
||||||
if (!this.editorView) {
|
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++) {
|
for (let i = 0; i < editorViews.length; i++) {
|
||||||
const name = editorViews[i].viewName;
|
const name = editorViews[i].viewName;
|
||||||
this.changeViewType(name);
|
this.changeViewName(name);
|
||||||
await this.editorViews.get(name)?.init();
|
await this.editorViews.get(name)?.init();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
setDefaultViewType = () => {
|
setDefaultViewName = () => {
|
||||||
this.changeViewType(this.config.viewType ?? this.resource.defaultViewType);
|
this.changeViewName(this.config.viewName ?? this.resource.defaultViewName!);
|
||||||
};
|
};
|
||||||
|
|
||||||
get resourceType() {
|
get resourceType() {
|
||||||
@ -188,7 +188,7 @@ export class EditorWindow implements IEditorWindow {
|
|||||||
this.editorViews.set(name, editorView);
|
this.editorViews.set(name, editorView);
|
||||||
};
|
};
|
||||||
|
|
||||||
changeViewType = (name: string, ignoreEmit: boolean = true) => {
|
changeViewName = (name: string, ignoreEmit: boolean = true) => {
|
||||||
this.editorView?.setActivate(false);
|
this.editorView?.setActivate(false);
|
||||||
this.editorView = this.editorViews.get(name)!;
|
this.editorView = this.editorViews.get(name)!;
|
||||||
|
|
||||||
|
|||||||
@ -95,7 +95,7 @@ export class Workspace implements IWorkspace {
|
|||||||
name: string;
|
name: string;
|
||||||
title: string;
|
title: string;
|
||||||
options: Object;
|
options: Object;
|
||||||
viewType?: string;
|
viewName?: string;
|
||||||
}[] = [];
|
}[] = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@ -114,7 +114,7 @@ export class Workspace implements IWorkspace {
|
|||||||
|
|
||||||
const windowInfo = this.windowQueue.shift();
|
const windowInfo = this.windowQueue.shift();
|
||||||
if (windowInfo) {
|
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);
|
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) {
|
if (this.window && !this.window?.initReady && !sleep) {
|
||||||
this.windowQueue.push({
|
this.windowQueue.push({
|
||||||
name, title, options, viewType,
|
name, title, options, viewName,
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -261,7 +261,7 @@ export class Workspace implements IWorkspace {
|
|||||||
const window = new EditorWindow(resource, this, {
|
const window = new EditorWindow(resource, this, {
|
||||||
title,
|
title,
|
||||||
options,
|
options,
|
||||||
viewType,
|
viewName,
|
||||||
sleep,
|
sleep,
|
||||||
});
|
});
|
||||||
this.windows = [...this.windows, window];
|
this.windows = [...this.windows, window];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user