Skip to content

Commit 059ffe0

Browse files
liujupingJackLian
authored andcommitted
feat: improve the workspace sleep scene
1 parent 2b3d96c commit 059ffe0

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

packages/workspace/src/window.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ export class EditorWindow implements IEditorWindow {
5151
this.title = config.title;
5252
this.icon = resource.icon;
5353
this.sleep = config.sleep;
54-
if (!config.sleep) {
55-
this.init();
56-
}
5754
}
5855

5956
async importSchema(schema: any) {
@@ -155,14 +152,15 @@ export class EditorWindow implements IEditorWindow {
155152
return;
156153
}
157154

155+
this.editorView.setActivate(true);
156+
158157
if (!ignoreEmit) {
159158
this.emitter.emit('window.change.view.type', name);
160159

161160
if (this.id === this.workspace.window.id) {
162161
this.workspace.emitChangeActiveEditorView();
163162
}
164163
}
165-
this.editorView.setActivate(true);
166164
};
167165

168166
get project() {

packages/workspace/src/workspace.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export class Workspace implements IWorkspace {
115115
}
116116
}
117117

118-
initWindow() {
118+
async initWindow() {
119119
if (!this.defaultResourceType || this.enableAutoOpenFirstWindow === false) {
120120
return;
121121
}
@@ -127,6 +127,7 @@ export class Workspace implements IWorkspace {
127127
this.window = new EditorWindow(resource, this, {
128128
title: resource.title,
129129
});
130+
await this.window.init();
130131
this.editorWindowMap.set(this.window.id, this.window);
131132
this.windows = [...this.windows, this.window];
132133
this.emitChangeWindow();
@@ -196,6 +197,9 @@ export class Workspace implements IWorkspace {
196197
this.windows.splice(index, 1);
197198
if (this.window === window) {
198199
this.window = this.windows[index] || this.windows[index + 1] || this.windows[index - 1];
200+
if (this.window.sleep) {
201+
this.window.init();
202+
}
199203
this.emitChangeActiveWindow();
200204
}
201205
this.emitChangeWindow();
@@ -206,10 +210,13 @@ export class Workspace implements IWorkspace {
206210
this.remove(index);
207211
}
208212

209-
openEditorWindowById(id: string) {
213+
async openEditorWindowById(id: string) {
210214
const window = this.editorWindowMap.get(id);
211215
if (window) {
212216
this.window = window;
217+
if (window.sleep) {
218+
await window.init();
219+
}
213220
this.emitChangeActiveWindow();
214221
}
215222
}
@@ -252,6 +259,7 @@ export class Workspace implements IWorkspace {
252259
this.editorWindowMap.set(window.id, window);
253260
if (!sleep) {
254261
this.window = window;
262+
await this.window.init();
255263
}
256264
this.emitChangeWindow();
257265
this.emitChangeActiveWindow();

0 commit comments

Comments
 (0)