feat(workspace): update removeEditorWindow api

This commit is contained in:
liujuping 2023-08-23 14:20:08 +08:00 committed by 林熠
parent 14d294c92c
commit 547bbf4ddc
4 changed files with 43 additions and 5 deletions

View File

@ -107,7 +107,16 @@ openEditorWindowById(id: string): void;
移除视图窗口
```typescript
/**
* 移除视图窗口
* @deprecated
*/
removeEditorWindow(resourceName: string, id: string): void;
/**
* 移除视图窗口
*/
removeEditorWindow(resource: Resource): void;
```
### removeEditorWindowById

View File

@ -76,8 +76,12 @@ export class Workspace implements IPublicApiWorkspace {
this[workspaceSymbol].openEditorWindowById(id);
}
removeEditorWindow(resourceName: string, id: string) {
this[workspaceSymbol].removeEditorWindow(resourceName, id);
removeEditorWindow() {
if (typeof arguments[0] === 'string') {
this[workspaceSymbol].removeEditorWindow(arguments[0], arguments[1]);
} else {
this[workspaceSymbol].removeEditorWindowByResource(arguments[0]?.[resourceSymbol]);
}
}
removeEditorWindowById(id: string) {

View File

@ -42,9 +42,17 @@ export interface IPublicApiWorkspace<
/** 通过视图 id 打开窗口 */
openEditorWindowById(id: string): void;
/** 移除视图窗口 */
/**
*
* @deprecated
*/
removeEditorWindow(resourceName: string, id: string): void;
/**
*
*/
removeEditorWindow(resource: Resource): void;
/** 通过视图 id 移除窗口 */
removeEditorWindowById(id: string): void;

View File

@ -22,7 +22,7 @@ const CHANGE_EVENT = 'resource.list.change';
export interface IWorkspace extends Omit<IPublicApiWorkspace<
LowCodePluginManager,
IEditorWindow
>, 'resourceList' | 'plugins'> {
>, 'resourceList' | 'plugins' | 'openEditorWindow' | 'removeEditorWindow'> {
readonly registryInnerPlugin: (designer: IDesigner, editor: Editor, plugins: IPublicApiPlugins) => Promise<IPublicTypeDisposable>;
readonly shellModelFactory: IShellModelFactory;
@ -52,6 +52,18 @@ export interface IWorkspace extends Omit<IPublicApiWorkspace<
emitChangeActiveEditorView(): void;
openEditorWindowByResource(resource: IResource, sleep: boolean): Promise<void>;
/**
* @deprecated
*/
removeEditorWindow(resourceName: string, id: string): void;
removeEditorWindowByResource(resource: IResource): void;
/**
* @deprecated
*/
openEditorWindow(name: string, title: string, options: Object, viewName?: string, sleep?: boolean): Promise<void>;
}
export class Workspace implements IWorkspace {
@ -213,7 +225,12 @@ export class Workspace implements IWorkspace {
}
removeEditorWindow(resourceName: string, id: string) {
const index = this.windows.findIndex(d => (d.resource?.name === resourceName && d.title === id));
const index = this.windows.findIndex(d => (d.resource?.name === resourceName && (d.title === id || d.resource.id === id)));
this.remove(index);
}
removeEditorWindowByResource(resource: IResource) {
const index = this.windows.findIndex(d => (d.resource?.id === resource.id));
this.remove(index);
}