MCPcopy
hub / github.com/ZToolsCenter/ZTools / setupIPC

Method setupIPC

src/main/api/plugin/ui.ts:24–75  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

22 }
23
24 private setupIPC(): void {
25 // 注册 getThemeInfo 到统一分发器(同步 API)
26 registerPluginApiServices({
27 getThemeInfo: (event: Electron.IpcMainEvent) => {
28 event.returnValue = this.buildThemeInfo()
29 }
30 })
31
32 // 显示系统通知
33 ipcMain.handle('show-notification', (event, body: string) => this.showNotification(event, body))
34
35 // 设置插件高度
36 ipcMain.handle('set-expend-height', (event, height: number) =>
37 this.setExpendHeight(event, height)
38 )
39
40 // 子输入框相关
41 ipcMain.handle('set-sub-input', (event, placeholder?: string, isFocus?: boolean) =>
42 this.setSubInput(placeholder, isFocus, event)
43 )
44 ipcMain.handle('remove-sub-input', (event) => this.removeSubInput(event))
45 ipcMain.on('notify-sub-input-change', (event, text: string) =>
46 this.notifySubInputChange(text, event)
47 )
48 ipcMain.handle('set-sub-input-value', (event, text: string) =>
49 this.setSubInputValue(text, event)
50 )
51 ipcMain.on('sub-input-focus', (event) => {
52 event.returnValue = this.subInputFocus(event)
53 })
54 ipcMain.on('sub-input-blur', (event) => {
55 event.returnValue = this.subInputBlur(event)
56 })
57 ipcMain.on('sub-input-select', (event) => {
58 event.returnValue = this.subInputSelect(event)
59 })
60
61 // 隐藏插件
62 ipcMain.on('hide-plugin', () => this.hidePlugin())
63
64 // 插件 ESC 按键事件(由插件 preload 通过 JS 拦截后上报)
65 ipcMain.on('plugin-esc-pressed', () => {
66 if (this.pluginManager && typeof this.pluginManager.handlePluginEsc === 'function') {
67 this.pluginManager.handlePluginEsc()
68 }
69 })
70
71 // 获取是否深色主题
72 ipcMain.on('is-dark-colors', (event) => {
73 event.returnValue = nativeTheme.shouldUseDarkColors
74 })
75 }
76
77 private showNotification(event: Electron.IpcMainInvokeEvent, body: string): void {
78 if (Notification.isSupported()) {

Callers 1

initMethod · 0.95

Calls 14

buildThemeInfoMethod · 0.95
showNotificationMethod · 0.95
setExpendHeightMethod · 0.95
setSubInputMethod · 0.95
removeSubInputMethod · 0.95
notifySubInputChangeMethod · 0.95
setSubInputValueMethod · 0.95
subInputFocusMethod · 0.95
subInputBlurMethod · 0.95
subInputSelectMethod · 0.95
hidePluginMethod · 0.95

Tested by

no test coverage detected