fix two tray on windows

This commit is contained in:
life
2021-03-28 09:22:06 +08:00
parent e83689c756
commit 3dbb0cf240
3 changed files with 13 additions and 2 deletions

View File

@@ -232,6 +232,10 @@ function openIt() {
ipc.on('openUrl', function(event, arg) {
console.log('openUrl', arg);
// if (appIcon) {
// appIcon.destroy()
// }
arg.webPreferences = arg.webPreferences === undefined ? {} : arg.webPreferences;
arg.webPreferences.nodeIntegration = true;
arg.webPreferences.contextIsolation = false;
@@ -268,6 +272,8 @@ function openIt() {
}
}
// tray只要实例化一次
// tray在windows下可能会有两个, 原因不明, 当注销后再启动
var trayShowed = false;
ipc.on('show-tray', function(event, arg) {
if (trayShowed) {
@@ -279,6 +285,8 @@ function openIt() {
return;
}
console.log('show tray')
appIcon = new Tray(__dirname + '/public/images/tray/' + ( process.platform == 'darwin' ? 'trayTemplate.png' : 'tray.png'))
var contextMenu = Menu.buildFromTemplate([
{