()
| 1211 | |
| 1212 | // 切换当前插件的开发者工具(打开/关闭) |
| 1213 | public async openPluginDevTools(): Promise<boolean> { |
| 1214 | try { |
| 1215 | if (!this.pluginView || this.pluginView.webContents.isDestroyed()) { |
| 1216 | console.log('[Plugin] 没有活动的插件视图') |
| 1217 | return false |
| 1218 | } |
| 1219 | |
| 1220 | // 检查开发者工具是否已打开 |
| 1221 | if (this.pluginView.webContents.isDevToolsOpened()) { |
| 1222 | // 如果已打开,关闭开发者工具 |
| 1223 | this.pluginView.webContents.closeDevTools() |
| 1224 | console.log('[Plugin] 已关闭插件开发者工具') |
| 1225 | } else { |
| 1226 | // 如果未打开,打开开发者工具 |
| 1227 | const mode = getDevToolsMode() |
| 1228 | this.pluginView.webContents.openDevTools({ mode }) |
| 1229 | console.log('[Plugin] 已打开插件开发者工具') |
| 1230 | } |
| 1231 | return true |
| 1232 | } catch (error) { |
| 1233 | console.error('[Plugin] 切换开发者工具失败:', error) |
| 1234 | return false |
| 1235 | } |
| 1236 | } |
| 1237 | |
| 1238 | /** |
| 1239 | * 强制重绘 WebContentsView(修复部分 Windows 系统白屏问题) |
no test coverage detected