Skip to content

Commit

Permalink
Fix the message notification
Browse files Browse the repository at this point in the history
  • Loading branch information
Howard Ju committed May 31, 2018
1 parent 7ee727f commit 8bb14f8
Showing 1 changed file with 29 additions and 16 deletions.
45 changes: 29 additions & 16 deletions src/controller/app-tray-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 8bb14f8

Please sign in to comment.