(event?: Electron.IpcMainEvent | Electron.IpcMainInvokeEvent)
| 243 | } |
| 244 | |
| 245 | private subInputFocus(event?: Electron.IpcMainEvent | Electron.IpcMainInvokeEvent): boolean { |
| 246 | try { |
| 247 | // 判断插件是在主窗口还是分离窗口 |
| 248 | const targetWindow = event |
| 249 | ? detachedWindowManager.getWindowByPluginWebContents(event.sender.id) || this.mainWindow |
| 250 | : this.mainWindow |
| 251 | |
| 252 | if (!targetWindow) { |
| 253 | console.warn('[PluginUI] 无法找到目标窗口') |
| 254 | return false |
| 255 | } |
| 256 | |
| 257 | targetWindow.webContents.focus() |
| 258 | console.log('[PluginUI] 目标窗口获取焦点') |
| 259 | |
| 260 | // 发送事件到目标窗口渲染进程,聚焦输入框 |
| 261 | targetWindow.webContents.send('focus-sub-input') |
| 262 | console.log('[PluginUI] 请求聚焦子输入框') |
| 263 | |
| 264 | return true |
| 265 | } catch (error: unknown) { |
| 266 | console.error('[PluginUI] 聚焦子输入框失败:', error) |
| 267 | return false |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | private subInputBlur(event?: Electron.IpcMainEvent | Electron.IpcMainInvokeEvent): boolean { |
| 272 | try { |
no test coverage detected