MCPcopy Index your code
hub / github.com/ZToolsCenter/ZTools / setSubInputValue

Method setSubInputValue

src/main/api/plugin/ui.ts:213–243  ·  view source on GitHub ↗
(
    text: string,
    event?: Electron.IpcMainInvokeEvent | Electron.IpcMainEvent
  )

Source from the content-addressed store, hash-verified

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 {

Callers 4

setupIPCMethod · 0.95
notifySubInputChangeMethod · 0.45
registerFunction · 0.45
setSubInputFunction · 0.45

Calls 3

notifySubInputChangeMethod · 0.95
subInputFocusMethod · 0.95

Tested by

no test coverage detected