fix: mac fullscreen changed when switch back through clicking dock icon

This commit is contained in:
fullex 2025-04-13 23:08:55 +08:00 committed by Asurada
parent ab4fb7d1d6
commit 64200b00a9

View File

@ -272,9 +272,14 @@ export class WindowService {
} }
} }
//上述逻辑以下,是“开启托盘+设置关闭时最小化到托盘”的情况 /**
* :
* win/linux: +
* mac: 任何情况都会到这里mac
*/
event.preventDefault() event.preventDefault()
mainWindow.hide() mainWindow.hide()
//for mac users, should hide dock icon if close to tray //for mac users, should hide dock icon if close to tray
@ -320,10 +325,14 @@ export class WindowService {
this.mainWindow.setVisibleOnAllWorkspaces(true) this.mainWindow.setVisibleOnAllWorkspaces(true)
} }
//[macOS] After being closed in fullscreen, the fullscreen behavior will become strange when window shows again /**
// So we need to set it to FALSE explicitly. * [macOS] After being closed in fullscreen, the fullscreen behavior will become strange when window shows again
// althougle other platforms don't have the issue, but it's a good practice to do so * So we need to set it to FALSE explicitly.
if (this.mainWindow.isFullScreen()) { * althougle other platforms don't have the issue, but it's a good practice to do so
*
* Check if window is visible to prevent interrupting fullscreen state when clicking dock icon
*/
if (this.mainWindow.isFullScreen() && !this.mainWindow.isVisible()) {
this.mainWindow.setFullScreen(false) this.mainWindow.setFullScreen(false)
} }