-
-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Howard Ju
committed
May 31, 2018
1 parent
7ee727f
commit 8bb14f8
Showing
1 changed file
with
29 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,9 +19,14 @@ class AppTrayController { | |
this.tray = new Tray(this.createTrayIcon()) | ||
this.tray.setToolTip('Wechat Desktop') | ||
|
||
const context = Menu.buildFromTemplate([ | ||
{label: '切换聊天窗口', click: () => this.mainController.toggle()}, | ||
{label: '退出', click: () => this.cleanupAndExit()} | ||
const context = Menu.buildFromTemplate([{ | ||
label: '切换聊天窗口', | ||
click: () => this.mainController.toggle() | ||
}, | ||
{ | ||
label: '退出', | ||
click: () => this.cleanupAndExit() | ||
} | ||
]) | ||
|
||
this.tray.setContextMenu(context) | ||
|
@@ -52,24 +57,32 @@ class AppTrayController { | |
|
||
getUnreadImage(value) { | ||
this.unreadType = value | ||
let trayIcon | ||
switch (value) { | ||
case 'important': | ||
trayIcon = 'darwin' === this.platform ? | ||
nativeImage.createFromPath(path.join(__dirname, '../../assets/iconImportant.png')) : | ||
nativeImage.createFromPath(path.join(__dirname, '../../assets/[email protected]')) | ||
if ('darwin' === this.platform) { | ||
let trayIcon = nativeImage.createFromPath(path.join(__dirname, '../../assets/iconImportant.png')) | ||
trayIcon.setTemplateImage(true) | ||
return trayIcon | ||
} else { | ||
return nativeImage.createFromPath(path.join(__dirname, '../../assets/[email protected]')) | ||
} | ||
case 'minor': | ||
trayIcon = 'darwin' === this.platform ? | ||
nativeImage.createFromPath(path.join(__dirname, '../../assets/iconUnread.png')) : | ||
nativeImage.createFromPath(path.join(__dirname, '../../assets/[email protected]')) | ||
if ('darwin' === this.platform) { | ||
let trayIcon = nativeImage.createFromPath(path.join(__dirname, '../../assets/iconUnread.png')) | ||
trayIcon.setTemplateImage(true) | ||
return trayIcon | ||
} else { | ||
return nativeImage.createFromPath(path.join(__dirname, '../../assets/[email protected]')) | ||
} | ||
default: | ||
trayIcon = 'darwin' === this.platform ? | ||
nativeImage.createFromPath(path.join(__dirname, '../../assets/icon.png')) : | ||
nativeImage.createFromPath(path.join(__dirname, '../../assets/[email protected]')) | ||
if ('darwin' === this.platform) { | ||
let trayIcon = nativeImage.createFromPath(path.join(__dirname, '../../assets/icon.png')) | ||
trayIcon.setTemplateImage(true) | ||
return trayIcon | ||
} else { | ||
return nativeImage.createFromPath(path.join(__dirname, '../../assets/[email protected]')) | ||
} | ||
} | ||
|
||
trayIcon.setTemplateImage(true) | ||
return trayIcon | ||
} | ||
|
||
cleanupAndExit() { | ||
|