Skip to content

Commit

Permalink
优化:Mac 系统下全屏不能退出问题,Mac 系统下隐藏窗口自动隐藏图标
Browse files Browse the repository at this point in the history
  • Loading branch information
modstart committed Oct 24, 2024
1 parent 1ea3858 commit 4dd12db
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## v0.0.13

- 优化:Mac 系统下全屏不能退出问题
- 优化:Mac 系统下隐藏窗口自动隐藏图标

## v0.0.12

- 新增:日志目录一键打开,方便查看日志
Expand Down
11 changes: 7 additions & 4 deletions electron/config/tray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@ import {trayPath} from "./icon";
import {AppRuntime} from "../mapi/env";
import {AppConfig} from "../../src/config";
import {t} from "./lang";
import {isWin} from "../lib/env";
import {isMac, isWin} from "../lib/env";

let tray = null

const showApp = () => {
if (isMac) {
app.dock.show()
}
AppRuntime.mainWindow.show()
}

const hideApp = () => {
if (isMac) {
app.dock.hide()
}
AppRuntime.mainWindow.hide()
}

Expand All @@ -20,9 +26,6 @@ const quitApp = () => {
}

const ready = () => {
if (process.platform === 'darwin') {
app.dock.show()
}
tray = new Tray(trayPath)

tray.setToolTip(AppConfig.name)
Expand Down
10 changes: 9 additions & 1 deletion electron/mapi/app/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {app, ipcMain, shell} from "electron";
import {WindowConfig} from "../../config/window";
import {AppRuntime} from "../env";
import {isMac} from "../../lib/env";

const quit = () => {
app.quit()
Expand All @@ -11,7 +12,11 @@ const windowMin = () => {
}

const windowMax = () => {
if (AppRuntime.mainWindow.isMaximized()) {
if (AppRuntime.mainWindow.isFullScreen()) {
AppRuntime.mainWindow.setFullScreen(false)
AppRuntime.mainWindow.unmaximize()
AppRuntime.mainWindow.center()
} else if (AppRuntime.mainWindow.isMaximized()) {
AppRuntime.mainWindow.unmaximize()
AppRuntime.mainWindow.center()
} else {
Expand Down Expand Up @@ -58,6 +63,9 @@ ipcMain.handle('window:hide', (event, name: string) => {
} else {
AppRuntime.windows[name]?.hide()
}
if (isMac) {
app.dock.hide()
}
})

export default {
Expand Down

0 comments on commit 4dd12db

Please sign in to comment.