(
text: string,
event?: Electron.IpcMainInvokeEvent | Electron.IpcMainEvent
)
| 211 | } |
| 212 | |
| 213 | private setSubInputValue( |
| 214 | text: string, |
| 215 | event?: Electron.IpcMainInvokeEvent | Electron.IpcMainEvent |
| 216 | ): boolean { |
| 217 | try { |
| 218 | // 判断插件是在主窗口还是分离窗口 |
| 219 | const targetWindow = event |
| 220 | ? detachedWindowManager.getWindowByPluginWebContents(event.sender.id) || this.mainWindow |
| 221 | : this.mainWindow |
| 222 | |
| 223 | if (!targetWindow) { |
| 224 | console.warn('[PluginUI] 无法找到目标窗口') |
| 225 | return false |
| 226 | } |
| 227 | |
| 228 | // 发送事件到目标窗口渲染进程,设置输入框的值 |
| 229 | targetWindow.webContents.send('set-sub-input-value', text) |
| 230 | console.log('[PluginUI] 设置子输入框值:', text) |
| 231 | |
| 232 | // 触发插件的 onChange 回调 |
| 233 | this.notifySubInputChange(text, event) |
| 234 | |
| 235 | // 聚焦子输入框 |
| 236 | this.subInputFocus(event) |
| 237 | |
| 238 | return true |
| 239 | } catch (error: unknown) { |
| 240 | console.error('[PluginUI] 设置子输入框值失败:', error) |
| 241 | return false |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | private subInputFocus(event?: Electron.IpcMainEvent | Electron.IpcMainInvokeEvent): boolean { |
| 246 | try { |
no test coverage detected