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

Method mainWindowEvents

apps/desktop/main/index.ts:392–423  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

390
391 // 主窗口事件
392 mainWindowEvents() {
393 if (!this.mainWindow) {
394 return
395 }
396 this.mainWindow.webContents.on('did-finish-load', () => {
397 setTimeout(() => {
398 if (this.mainWindow) {
399 this.mainWindow.webContents.send('app-started')
400 }
401 }, 500)
402 })
403
404 this.mainWindow.on('maximize', () => {
405 this.mainWindow?.webContents.send('windowState', true)
406 })
407
408 this.mainWindow.on('unmaximize', () => {
409 this.mainWindow?.webContents.send('windowState', false)
410 })
411
412 // 窗口关闭
413 this.mainWindow.on('close', (event) => {
414 if (platform.isMacOS) {
415 // macOS: 只有明确退出时才真正关闭,否则只隐藏窗口(符合 macOS 用户习惯)
416 if (!appWithQuitFlag.isQuiting) {
417 event.preventDefault()
418 this.mainWindow?.hide()
419 }
420 }
421 // Windows/Linux: 不阻止关闭,正常触发 window-all-closed → app.quit() → cleanup()
422 })
423 }
424}
425
426// 捕获未捕获的异常与未处理的 Promise 拒绝,落盘到 logs/app.log 便于排查

Callers 1

createWindowMethod · 0.95

Calls 2

setTimeoutFunction · 0.85
onMethod · 0.80

Tested by

no test coverage detected