MCPcopy Index your code
hub / github.com/ZToolsCenter/ZTools / setupIPC

Method setupIPC

src/main/api/plugin/lifecycle.ts:23–52  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21 }
22
23 private setupIPC(): void {
24 // 插件进入事件
25 ipcMain.handle('onPluginEnter', () => {
26 console.log('[PluginLifecycle] 收到插件进入事件:', this.launchParam)
27 return this.launchParam
28 })
29
30 // 退出插件
31 ipcMain.handle('out-plugin', (event, isKill: boolean = false) => {
32 console.log('[PluginLifecycle] out-plugin', isKill)
33 const pluginInfo = this.pluginManager?.getPluginInfoByWebContents(event.sender)
34 console.log('[PluginLifecycle] pluginInfo', pluginInfo)
35 if (!pluginInfo) {
36 return false
37 }
38
39 this.pluginManager?.hidePluginView()
40 windowManager.notifyBackToSearch()
41 // 主窗口获取焦点(确保前端的 focus() 调用能生效)
42 this.mainWindow?.webContents.focus()
43
44 if (isKill) {
45 return this.pluginManager?.killPlugin(pluginInfo.path)
46 } else {
47 // 发送插件退出事件(isKill=false 表示正常退出)
48 event.sender.send('plugin-out', false)
49 return true
50 }
51 })
52 }
53}
54
55export default new PluginLifecycleAPI()

Callers 1

initMethod · 0.95

Calls 5

hidePluginViewMethod · 0.80
notifyBackToSearchMethod · 0.80
focusMethod · 0.80
killPluginMethod · 0.45

Tested by

no test coverage detected