MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / checkApp

Method checkApp

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

Source from the content-addressed store, hash-verified

70
71 // 单例锁
72 async checkApp() {
73 // E2E 测试模式:绕过单实例锁以支持并行实例
74 const isTestMode = process.env.TEST_MODE === 'true'
75 if (isTestMode) {
76 return true
77 }
78
79 if (!app.requestSingleInstanceLock()) {
80 app.quit()
81 // 未获得锁
82 return false
83 }
84 // 聚焦到当前程序
85 else {
86 app.on('second-instance', () => {
87 if (this.mainWindow) {
88 this.mainWindow.show()
89 if (this.mainWindow.isMinimized()) this.mainWindow.restore()
90 this.mainWindow.focus()
91 }
92 })
93 // 获得锁
94 return true
95 }
96 }
97
98 // 初始化程序
99 async init() {

Callers 1

constructorMethod · 0.95

Calls 1

onMethod · 0.80

Tested by

no test coverage detected