修复 mac 托盘图标问题
parent
0090f484d8
commit
aed9889a2e
|
@ -7,13 +7,13 @@ if (!app.requestSingleInstanceLock()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
app.on('second-instance', (event, argv, cwd) => {
|
app.on('second-instance', (event, argv, cwd) => {
|
||||||
if (mainWindow) {
|
if (global.mainWindow) {
|
||||||
if (mainWindow.isMinimized()) {
|
if (global.mainWindow.isMinimized()) {
|
||||||
mainWindow.restore()
|
global.mainWindow.restore()
|
||||||
} else if (mainWindow.isVisible()) {
|
} else if (global.mainWindow.isVisible()) {
|
||||||
mainWindow.focus()
|
global.mainWindow.focus()
|
||||||
} else {
|
} else {
|
||||||
mainWindow.show()
|
global.mainWindow.show()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
app.quit()
|
app.quit()
|
||||||
|
@ -67,7 +67,7 @@ const winEvent = require('./rendererEvents/winEvent')
|
||||||
const autoUpdate = require('./utils/autoUpdate')
|
const autoUpdate = require('./utils/autoUpdate')
|
||||||
const { isMac, isLinux } = require('../common/utils')
|
const { isMac, isLinux } = require('../common/utils')
|
||||||
|
|
||||||
let mainWindow
|
|
||||||
let winURL
|
let winURL
|
||||||
|
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
|
@ -84,7 +84,7 @@ function createWindow() {
|
||||||
/**
|
/**
|
||||||
* Initial window options
|
* Initial window options
|
||||||
*/
|
*/
|
||||||
mainWindow = global.mainWindow = new BrowserWindow({
|
global.mainWindow = new BrowserWindow({
|
||||||
height: windowSizeInfo.height,
|
height: windowSizeInfo.height,
|
||||||
useContentSize: true,
|
useContentSize: true,
|
||||||
width: windowSizeInfo.width,
|
width: windowSizeInfo.width,
|
||||||
|
@ -103,9 +103,9 @@ function createWindow() {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
mainWindow.loadURL(winURL)
|
global.mainWindow.loadURL(winURL)
|
||||||
|
|
||||||
winEvent(mainWindow)
|
winEvent(global.mainWindow)
|
||||||
// mainWindow.webContents.openDevTools()
|
// mainWindow.webContents.openDevTools()
|
||||||
|
|
||||||
if (!isDev) autoUpdate()
|
if (!isDev) autoUpdate()
|
||||||
|
@ -120,7 +120,17 @@ function init() {
|
||||||
app.on('ready', init)
|
app.on('ready', init)
|
||||||
|
|
||||||
app.on('activate', () => {
|
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', () => {
|
app.on('window-all-closed', () => {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const { app, Tray, Menu } = require('electron')
|
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 { tray: TRAY_EVENT_NAME } = require('../events/_name')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
global.lx_event.tray.on(TRAY_EVENT_NAME.create, () => {
|
global.lx_event.tray.on(TRAY_EVENT_NAME.create, () => {
|
||||||
|
@ -13,7 +13,7 @@ let tray
|
||||||
function createTray() {
|
function createTray() {
|
||||||
if ((tray && !tray.isDestroyed()) || !global.appSetting.tray || !global.appSetting.tray.isShow) return
|
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)
|
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