MCPcopy
hub / github.com/ZToolsCenter/ZTools / hidePluginView

Method hidePluginView

src/main/managers/pluginManager.ts:802–844  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

800
801 // 隐藏插件视图
802 public hidePluginView(): void {
803 if (this.pluginView && this.mainWindow) {
804 const currentPath = this.currentPluginPath
805 const pluginView = this.pluginView
806 console.log('[Plugin] 隐藏插件视图:', {
807 currentPath,
808 hasAssembly: this.assemblyCoordinator.hasCurrentSession()
809 })
810
811 // 发送插件退出事件(isKill=false 表示正常退出)
812 if (!pluginView.webContents.isDestroyed()) {
813 void this.assemblyCoordinator.dispatchLifecycleEvent(pluginView, 'PluginOut', false)
814 }
815
816 // 获取插件名称
817 const cached = this.pluginViews.find((v) => v.path === currentPath)
818 const pluginName = cached?.name
819
820 // 仅移除视图以达到隐藏效果,但保留实例以便复用
821 this.mainWindow.contentView.removeChildView(pluginView)
822 // 隐藏时按策略决定是否启用节流
823 this.applyBackgroundThrottlingByPolicy(pluginView, currentPath, true)
824 console.log('[Plugin] Plugin WebContentsView 已隐藏,缓存保留')
825
826 // 将当前引用清空,但缓存仍保留
827 this.pluginView = null
828 this.currentPluginPath = null
829 this.assemblyCoordinator.abortCurrentSession('hide-view-abort-assembly')
830 this.assemblyCoordinator.clearCurrentSession()
831
832 // 通知渲染进程插件已关闭
833 this.mainWindow.webContents.send('plugin-closed')
834
835 // 检查是否需要终止插件
836 if (pluginName && currentPath) {
837 if (pluginWindowManager.hasWindowsByPlugin(currentPath)) {
838 console.log(`[Plugin] 插件 ${pluginName} 还有打开的子窗口,暂不终止进程`)
839 } else {
840 this.checkAndKillPlugin(pluginName, currentPath)
841 }
842 }
843 }
844 }
845
846 // 检查并终止插件
847 private checkAndKillPlugin(pluginName: string, pluginPath: string): void {

Callers 11

createPluginViewMethod · 0.95
handlePluginEscMethod · 0.95
backToSearchMethod · 0.80
showSettingsMethod · 0.80
openPluginInstallerMethod · 0.80
hidePluginMethod · 0.80
setupIPCMethod · 0.80
toSearchPageMethod · 0.80
launchMethod · 0.80
launchAsAdminMethod · 0.80

Calls 7

checkAndKillPluginMethod · 0.95
hasCurrentSessionMethod · 0.80
abortCurrentSessionMethod · 0.80
clearCurrentSessionMethod · 0.80
hasWindowsByPluginMethod · 0.80

Tested by

no test coverage detected