From ec679659311195496bfc9f7a9a47cc42fd442226 Mon Sep 17 00:00:00 2001 From: npmrun <62639956+npmrun@users.noreply.github.com> Date: Thu, 29 Jul 2021 00:03:21 +0800 Subject: [PATCH] fixed bug --- package.json | 4 ++-- src/main/index.ts | 8 ++++---- src/main/menu.ts | 7 ++++++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index b85a3d9..09f03a1 100644 --- a/package.json +++ b/package.json @@ -120,7 +120,7 @@ "to": "src/preload" }, "mac": { - "icon": "build/icons/icon.icns" + "icon": "resource/electron/static/icon.png" }, "win": { "icon": "resource/electron/static/icon.png", @@ -134,7 +134,7 @@ ] }, "linux": { - "icon": "build/icons" + "icon": "resource/electron/static/icon.png" } } } diff --git a/src/main/index.ts b/src/main/index.ts index b45e816..dcece78 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -12,7 +12,8 @@ Shared.data = { mainWindow: null, floatWindow: null, miniWindow: null, - forceClose: false + forceClose: false, + lastChoice: -1, } console.log('asdasadsads') /** @@ -28,7 +29,6 @@ console.log('asdasadsads') const winURL = process.env.NODE_ENV === 'development' ? `http://localhost:${process.env.PORT}/#/` : `file://${__dirname}/index.html` -let lastChoice = -1 function createWindow() { /** @@ -56,7 +56,7 @@ function createWindow() { Shared.data.mainWindow = null app.quit() } else if (Shared.data.mainWindow) { - if (lastChoice === 1) { + if (Shared.data.lastChoice === 1) { if (Shared.data.miniWindow) { Shared.data.mainWindow.hide() // 调用 最小化实例方法 } else { @@ -73,7 +73,7 @@ function createWindow() { buttons: ['没事', '最小化到托盘', '直接退出'] }) if (choice === 1) { - lastChoice = 1 + Shared.data.lastChoice = 1 if (Shared.data.miniWindow) { Shared.data.mainWindow.hide() // 调用 最小化实例方法 } else { diff --git a/src/main/menu.ts b/src/main/menu.ts index 2bb905e..302cd26 100644 --- a/src/main/menu.ts +++ b/src/main/menu.ts @@ -67,7 +67,12 @@ let template = [ { label: "最小化到托盘", click: function (item: any, focusedWindow:BrowserWindow) { - setTray(app, Shared.data.mainWindow) + Shared.data.lastChoice = 1; + if (Shared.data.miniWindow) { + Shared.data.mainWindow.hide() // 调用 最小化实例方法 + } else { + setTray(app, Shared.data.mainWindow) + } }, }, {