@@ -12,6 +12,7 @@ import {Log} from "../../log/main";
1212import { Events } from "../../event/main" ;
1313import { ManagerSystem } from "../system" ;
1414import { AppsMain } from "../../app/main" ;
15+ import { ManagerPluginEvent } from "../plugin/event" ;
1516
1617const browserViews = new Map < WebContents , BrowserView > ( )
1718const detachWindows = new Map < WebContents , BrowserWindow > ( )
@@ -264,8 +265,11 @@ export const ManagerWindow = {
264265 const view = win . getBrowserView ( )
265266 await executePluginHooks ( view , 'SubInputChange' , keywords ) ;
266267 } ,
267- async close ( plugin ?: PluginRecord , option ?: { } ) {
268+ async close ( plugin ?: PluginRecord , option ?: {
269+ window ?: BrowserWindow
270+ } ) {
268271 if ( mainWindowView && ( ! plugin || mainWindowView . _plugin . name === plugin . name ) ) {
272+ // 主窗口插件
269273 await executePluginHooks ( mainWindowView , 'PluginExit' , null ) . then ( )
270274 await executeHooks ( AppRuntime . mainWindow , 'PluginExit' , null ) . then ( )
271275 removeBrowserViews ( mainWindowView )
@@ -274,7 +278,11 @@ export const ManagerWindow = {
274278 mainWindowView . webContents ?. destroy ( ) ;
275279 } else {
276280 // detach的插件窗口
277- //TODO
281+ if ( option . window ) {
282+ option . window . close ( )
283+ } else {
284+ Log . error ( 'ManagerWindow.close' , 'windowNotFound' )
285+ }
278286 }
279287 } ,
280288 async openMainPluginDevTools ( plugin : PluginRecord , option ?: { } ) {
@@ -293,6 +301,9 @@ export const ManagerWindow = {
293301 width : number ,
294302 height : number ,
295303 } ) {
304+ if ( ! await ManagerPluginEvent . isMainWindowShown ( null , null ) ) {
305+ await ManagerPluginEvent . showMainWindow ( null , null )
306+ }
296307 // console.log('showInMainWindow', view._plugin.name, option)
297308 if ( mainWindowView ) {
298309 await this . close ( mainWindowView . _plugin )
0 commit comments