修复 mac 托盘图标问题
parent
0090f484d8
commit
aed9889a2e
|
@ -7,13 +7,13 @@ if (!app.requestSingleInstanceLock()) {
|
|||
return
|
||||
}
|
||||
app.on('second-instance', (event, argv, cwd) => {
|
||||
if (mainWindow) {
|
||||
if (mainWindow.isMinimized()) {
|
||||
mainWindow.restore()
|
||||
} else if (mainWindow.isVisible()) {
|
||||
mainWindow.focus()
|
||||
if (global.mainWindow) {
|
||||
if (global.mainWindow.isMinimized()) {
|
||||
global.mainWindow.restore()
|
||||
} else if (global.mainWindow.isVisible()) {
|
||||
global.mainWindow.focus()
|
||||
} else {
|
||||
mainWindow.show()
|
||||
global.mainWindow.show()
|
||||
}
|
||||
} else {
|
||||
app.quit()
|
||||
|
@ -67,7 +67,7 @@ const winEvent = require('./rendererEvents/winEvent')
|
|||
const autoUpdate = require('./utils/autoUpdate')
|
||||
const { isMac, isLinux } = require('../common/utils')
|
||||
|
||||
let mainWindow
|
||||
|
||||
let winURL
|
||||
|
||||
if (isDev) {
|
||||
|
@ -84,7 +84,7 @@ function createWindow() {
|
|||
/**
|
||||
* Initial window options
|
||||
*/
|
||||
mainWindow = global.mainWindow = new BrowserWindow({
|
||||
global.mainWindow = new BrowserWindow({
|
||||
height: windowSizeInfo.height,
|
||||
useContentSize: true,
|
||||
width: windowSizeInfo.width,
|
||||
|
@ -103,9 +103,9 @@ function createWindow() {
|
|||
},
|
||||
})
|
||||
|
||||
mainWindow.loadURL(winURL)
|
||||
global.mainWindow.loadURL(winURL)
|
||||
|
||||
winEvent(mainWindow)
|
||||
winEvent(global.mainWindow)
|
||||
// mainWindow.webContents.openDevTools()
|
||||
|
||||
if (!isDev) autoUpdate()
|
||||
|
@ -120,7 +120,17 @@ function init() {
|
|||
app.on('ready', init)
|
||||
|
||||
app.on('activate', () => {
|
||||
if (mainWindow === null) return init()
|
||||
if (global.mainWindow) {
|
||||
if (global.mainWindow.isMinimized()) {
|
||||
global.mainWindow.restore()
|
||||
} else if (global.mainWindow.isVisible()) {
|
||||
global.mainWindow.focus()
|
||||
} else {
|
||||
global.mainWindow.show()
|
||||
}
|
||||
} else if (global.mainWindow === null) {
|
||||
init()
|
||||
}
|
||||
})
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const { app, Tray, Menu } = require('electron')
|
||||
const { isMac, isWin } = require('../../common/utils')
|
||||
const { isWin } = require('../../common/utils')
|
||||
const { tray: TRAY_EVENT_NAME } = require('../events/_name')
|
||||
const path = require('path')
|
||||
global.lx_event.tray.on(TRAY_EVENT_NAME.create, () => {
|
||||
|
@ -13,7 +13,7 @@ let tray
|
|||
function createTray() {
|
||||
if ((tray && !tray.isDestroyed()) || !global.appSetting.tray || !global.appSetting.tray.isShow) return
|
||||
|
||||
const iconPath = path.join(global.__static, 'images/tray', isWin ? '256x256.ico' : isMac ? '512x512.icns' : '512x512.png')
|
||||
const iconPath = path.join(global.__static, 'images/tray', isWin ? 'trayTemplate.ico' : 'trayTemplate.png')
|
||||
|
||||
// 托盘
|
||||
tray = new Tray(iconPath)
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 7.4 KiB |
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 16 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 359 B |
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 681 B |
Loading…
Reference in New Issue