@@ -2,7 +2,7 @@ import { IDesigner, ILowCodePluginManager, LowCodePluginManager } from '@alilc/l
22import { createModuleEventBus , Editor , IEditor , IEventBus , makeObservable , obx } from '@alilc/lowcode-editor-core' ;
33import { IPublicApiPlugins , IPublicApiWorkspace , IPublicEnumPluginRegisterLevel , IPublicResourceList , IPublicTypeDisposable , IPublicTypeResourceType , IShellModelFactory } from '@alilc/lowcode-types' ;
44import { BasicContext } from './context/base-context' ;
5- import { EditorWindow } from './window' ;
5+ import { EditorWindow , WINDOW_STATE } from './window' ;
66import type { IEditorWindow } from './window' ;
77import { IResource , Resource } from './resource' ;
88import { IResourceType , ResourceType } from './resource-type' ;
@@ -198,6 +198,7 @@ export class Workspace implements IWorkspace {
198198 }
199199 const window = this . windows [ index ] ;
200200 this . windows . splice ( index , 1 ) ;
201+ this . window ?. updateState ( WINDOW_STATE . destroyed ) ;
201202 if ( this . window === window ) {
202203 this . window = this . windows [ index ] || this . windows [ index + 1 ] || this . windows [ index - 1 ] ;
203204 if ( this . window ?. sleep ) {
@@ -206,6 +207,7 @@ export class Workspace implements IWorkspace {
206207 this . emitChangeActiveWindow ( ) ;
207208 }
208209 this . emitChangeWindow ( ) ;
210+ this . window ?. updateState ( WINDOW_STATE . active ) ;
209211 }
210212
211213 removeEditorWindow ( resourceName : string , title : string ) {
@@ -215,13 +217,15 @@ export class Workspace implements IWorkspace {
215217
216218 async openEditorWindowById ( id : string ) {
217219 const window = this . editorWindowMap . get ( id ) ;
220+ this . window ?. updateState ( WINDOW_STATE . inactive ) ;
218221 if ( window ) {
219222 this . window = window ;
220223 if ( window . sleep ) {
221224 await window . init ( ) ;
222225 }
223226 this . emitChangeActiveWindow ( ) ;
224227 }
228+ this . window ?. updateState ( WINDOW_STATE . active ) ;
225229 }
226230
227231 async openEditorWindow ( name : string , title : string , options : Object , viewType ?: string , sleep ?: boolean ) {
@@ -236,6 +240,7 @@ export class Workspace implements IWorkspace {
236240 console . error ( `${ name } resourceType is not available` ) ;
237241 return ;
238242 }
243+ this . window ?. updateState ( WINDOW_STATE . inactive ) ;
239244 const filterWindows = this . windows . filter ( d => ( d . resource ?. name === name && d . resource . title == title ) ) ;
240245 if ( filterWindows && filterWindows . length ) {
241246 this . window = filterWindows [ 0 ] ;
@@ -245,6 +250,7 @@ export class Workspace implements IWorkspace {
245250 this . checkWindowQueue ( ) ;
246251 }
247252 this . emitChangeActiveWindow ( ) ;
253+ this . window ?. updateState ( WINDOW_STATE . active ) ;
248254 return ;
249255 }
250256 const resource = new Resource ( {
@@ -266,6 +272,7 @@ export class Workspace implements IWorkspace {
266272 }
267273 this . emitChangeWindow ( ) ;
268274 this . emitChangeActiveWindow ( ) ;
275+ this . window ?. updateState ( WINDOW_STATE . active ) ;
269276 }
270277
271278 onChangeWindows ( fn : ( ) => void ) {
0 commit comments