* 打开插件安装页面(用于 .zpx 文件关联双击打开) * 流程:激活应用 → 启动设置插件 → 导航到 PluginInstaller 页面 → 传入文件路径 * @param zpxPath .zpx 文件路径
(zpxPath: string)
| 1349 | * @param zpxPath .zpx 文件路径 |
| 1350 | */ |
| 1351 | public async openPluginInstaller(zpxPath: string): Promise<void> { |
| 1352 | if (!this.mainWindow) return |
| 1353 | |
| 1354 | console.log('[Window] 打开插件安装页面:', zpxPath) |
| 1355 | |
| 1356 | // 临时抑制 blur 隐藏行为,防止窗口激活过程中被 blur 事件隐藏 |
| 1357 | this.suppressBlurHide = true |
| 1358 | |
| 1359 | // macOS: 先显示 Dock 图标并激活应用,否则窗口无法获取焦点 |
| 1360 | if (platform.isMacOS) { |
| 1361 | await app.dock?.show() |
| 1362 | app.focus({ steal: true }) |
| 1363 | } |
| 1364 | |
| 1365 | // 如果当前有插件在显示,先隐藏 |
| 1366 | if (pluginManager.getCurrentPluginPath() !== null) { |
| 1367 | pluginManager.hidePluginView() |
| 1368 | this.notifyBackToSearch() |
| 1369 | } |
| 1370 | |
| 1371 | try { |
| 1372 | const settingPlugin = this.findSettingPlugin() |
| 1373 | if (!settingPlugin) { |
| 1374 | this.suppressBlurHide = false |
| 1375 | return |
| 1376 | } |
| 1377 | |
| 1378 | // 启动设置插件,使用 install-plugin feature code |
| 1379 | // payload 传入文件路径数组(与 "type": "files" cmd 格式一致) |
| 1380 | const result = await api.launchPlugin({ |
| 1381 | path: settingPlugin.path, |
| 1382 | type: 'plugin', |
| 1383 | featureCode: 'function.install-plugin?router=PluginInstaller', |
| 1384 | name: '安装插件', |
| 1385 | cmdType: 'files', |
| 1386 | param: { |
| 1387 | code: 'function.install-plugin?router=PluginInstaller', |
| 1388 | payload: [{ path: zpxPath }] |
| 1389 | } |
| 1390 | }) |
| 1391 | |
| 1392 | if (!result.success) { |
| 1393 | console.error('[Window] 启动插件安装页面失败:', result.error) |
| 1394 | this.suppressBlurHide = false |
| 1395 | return |
| 1396 | } |
| 1397 | |
| 1398 | this.moveWindowToCursor() |
| 1399 | // macOS: forceActivateWindow 不会 setAlwaysOnTop/focus,需要单独处理焦点抢占 |
| 1400 | this.mainWindow.show() |
| 1401 | if (platform.isMacOS) { |
| 1402 | this.mainWindow.focus() |
| 1403 | } else { |
| 1404 | this.forceActivateWindow() |
| 1405 | } |
| 1406 | |
| 1407 | // 延迟恢复 blur 隐藏行为,确保窗口已稳定获取焦点 |
| 1408 | setTimeout(() => { |
no test coverage detected