MCPcopy Create free account
hub / github.com/ChatLab/ChatLab / mainIpcMain

Function mainIpcMain

apps/desktop/main/ipcMain.ts:26–56  ·  view source on GitHub ↗
(win: BrowserWindow)

Source from the content-addressed store, hash-verified

24 * @param win - 主窗口实例
25 */
26const mainIpcMain = (win: BrowserWindow) => {
27 console.log('[IpcMain] Registering IPC handlers...')
28
29 // 初始化 Worker
30 try {
31 worker.initWorker()
32 console.log('[IpcMain] Worker initialized successfully')
33 } catch (error) {
34 console.error('[IpcMain] Failed to initialize worker:', error)
35 }
36
37 const context: IpcContext = { win }
38
39 // 注册各模块的处理器
40 registerWindowHandlers(context)
41 registerChatHandlers(context)
42 registerAIHandlers(context)
43 registerMessagesHandlers(context)
44 registerCacheHandlers(context)
45 registerNetworkHandlers(context)
46 registerAnalyticsHandlers()
47 registerApiHandlers(context)
48 registerDemoHandlers(context)
49
50 // 启动 ChatLab API 服务(异步,不阻塞 IPC 注册)
51 initApiServer(context).catch((err) => {
52 console.error('[IpcMain] API server init failed:', err)
53 })
54
55 console.log('[IpcMain] All IPC handlers registered successfully')
56}
57
58export const cleanup = () => {
59 console.log('[IpcMain] Cleaning up resources...')

Callers 1

mainAppEventsMethod · 0.85

Calls 11

registerWindowHandlersFunction · 0.90
registerChatHandlersFunction · 0.90
registerAIHandlersFunction · 0.90
registerMessagesHandlersFunction · 0.90
registerCacheHandlersFunction · 0.90
registerNetworkHandlersFunction · 0.90
registerApiHandlersFunction · 0.90
registerDemoHandlersFunction · 0.90
initApiServerFunction · 0.90
errorMethod · 0.65

Tested by

no test coverage detected