File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,9 @@ let mainWindowState = {
14
14
isMaximized : false
15
15
} ;
16
16
17
+ // 保存主窗口引用,以便在 activate 事件中使用
18
+ let mainWindowInstance : BrowserWindow | null = null ;
19
+
17
20
/**
18
21
* 初始化代理设置
19
22
*/
@@ -183,6 +186,17 @@ export function initializeWindowManager() {
183
186
}
184
187
}
185
188
} ) ;
189
+
190
+ // 监听 macOS 下点击 Dock 图标的事件
191
+ app . on ( 'activate' , ( ) => {
192
+ // 当应用被激活时,检查主窗口是否存在
193
+ if ( mainWindowInstance && ! mainWindowInstance . isDestroyed ( ) ) {
194
+ // 如果窗口存在但被隐藏,则显示窗口
195
+ if ( ! mainWindowInstance . isVisible ( ) ) {
196
+ mainWindowInstance . show ( ) ;
197
+ }
198
+ }
199
+ } ) ;
186
200
}
187
201
188
202
/**
@@ -205,6 +219,7 @@ export function createMainWindow(icon: Electron.NativeImage): BrowserWindow {
205
219
} ) ;
206
220
207
221
mainWindow . setMinimumSize ( 1200 , 780 ) ;
222
+ mainWindow . removeMenu ( ) ;
208
223
209
224
mainWindow . on ( 'ready-to-show' , ( ) => {
210
225
mainWindow . show ( ) ;
@@ -229,5 +244,8 @@ export function createMainWindow(icon: Electron.NativeImage): BrowserWindow {
229
244
mainWindow . loadFile ( join ( __dirname , '../renderer/index.html' ) ) ;
230
245
}
231
246
247
+ // 保存主窗口引用
248
+ mainWindowInstance = mainWindow ;
249
+
232
250
return mainWindow ;
233
251
}
You can’t perform that action at this time.
0 commit comments