Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/docs/api/workspace.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,16 @@ openEditorWindowById(id: string): void;
移除视图窗口

```typescript
/**
* 移除视图窗口
* @deprecated
*/
removeEditorWindow(resourceName: string, id: string): void;

/**
* 移除视图窗口
*/
removeEditorWindow(resource: Resource): void;
```

### removeEditorWindowById
Expand Down
8 changes: 6 additions & 2 deletions packages/shell/src/api/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 9 additions & 1 deletion packages/types/src/shell/api/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
21 changes: 19 additions & 2 deletions packages/workspace/src/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}

Expand Down