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

Function registerWindowHandlers

apps/desktop/main/ipc/window.ts:44–326  ·  view source on GitHub ↗
(ctx: IpcContext)

Source from the content-addressed store, hash-verified

42 * 注册窗口和文件系统操作 IPC 处理器
43 */
44export function registerWindowHandlers(ctx: IpcContext): void {
45 const { win } = ctx
46
47 // ==================== 窗口操作 ====================
48 ipcMain.on('window-min', (ev) => {
49 ev.preventDefault()
50 win.minimize()
51 })
52
53 ipcMain.on('window-maxOrRestore', (ev) => {
54 const winSizeState = win.isMaximized()
55 if (winSizeState) {
56 win.restore()
57 } else {
58 win.maximize()
59 }
60 ev.reply('windowState', win.isMaximized())
61 })
62
63 ipcMain.on('window-restore', () => {
64 win.restore()
65 })
66
67 ipcMain.on('window-hide', () => {
68 win.hide()
69 })
70
71 ipcMain.on('window-close', () => {
72 win.close()
73 appWithQuitFlag.isQuiting = true
74 app.quit()
75 })
76
77 ipcMain.on('window-resize', (_, data) => {
78 if (data.resize) {
79 win.setResizable(true)
80 } else {
81 win.setSize(1180, 752)
82 win.setResizable(false)
83 }
84 })
85
86 ipcMain.on('open-devtools', () => {
87 win.webContents.openDevTools()
88 })
89
90 // 设置主题模式
91 ipcMain.on('window:setThemeSource', (_, mode: 'system' | 'light' | 'dark') => {
92 nativeTheme.themeSource = mode
93
94 // Windows 上动态更新 overlay 颜色以匹配主题
95 if (process.platform === 'win32' && win) {
96 resetCurrentTitleBarOverlayColor()
97 applyCurrentTitleBarOverlay(win, nativeTheme.shouldUseDarkColors)
98 }
99 })
100
101 ipcMain.on('window:setTitleBarOverlayColor', (_, color: string) => {

Callers 1

mainIpcMainFunction · 0.90

Calls 15

getDesktopAppVersionFunction · 0.90
manualCheckForUpdatesFunction · 0.90
simulateUpdateDialogFunction · 0.90
tFunction · 0.90
isAllowedRemoteConfigUrlFunction · 0.85
setTimeoutFunction · 0.85
clearTimeoutFunction · 0.85
onMethod · 0.80
abortMethod · 0.80

Tested by

no test coverage detected