opensumi / core

🚀 A framework helps you quickly build AI Native IDE products.
https://opensumi.com
MIT License
3.01k stars 389 forks source link

[Question] 如何监听自定义打开窗口关闭事件? #3051

Closed Augustjoe closed 1 year ago

Augustjoe commented 1 year ago

参照示例 https://github.com/opensumi/opensumi-module-samples/blob/main/modules/custom-editor-resource/README.md 打开了一个自定义的编辑窗口,现在需要监听其关闭事件来调用一些销毁容器的接口,请问如何监听?

erha19 commented 1 year ago

@Augustjoe 可以从 WorkbenchEditorService 获取相关服务,参考代码如:

@Autowired(WorkbenchEditorService)
private editorService: WorkbenchEditorService;

...
this.editorService.onActiveResourceChange  // 编辑器资源变化,如关闭,打开,修改等
this.editorService.onDidEditorGroupsChanged // 编辑器分组变化
this.editorService.onDidCurrentEditorGroupChanged // 编辑器分组焦点变化