This repository has been archived by the owner on Feb 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 453
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #159 from nashaofu/dev
release 2.0.11
- Loading branch information
Showing
11 changed files
with
183 additions
and
115 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "dingtalk", | ||
"version": "2.0.10", | ||
"version": "2.0.11", | ||
"description": "钉钉桌面版,基于electron和钉钉网页版开发,支持Windows、Linux和macOS", | ||
"author": "nashaofu <[email protected]>", | ||
"main": "dist/main.js", | ||
|
@@ -43,7 +43,7 @@ | |
"babel-preset-stage-2": "^6.24.1", | ||
"chalk": "^2.3.0", | ||
"css-loader": "^0.28.9", | ||
"electron": "^2.0.14", | ||
"electron": "^2.0.15", | ||
"electron-builder": "<=20.34.0", | ||
"electron-debug": "^2.0.0", | ||
"electron-dev-webpack-plugin": "0.0.11", | ||
|
Binary file not shown.
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
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 |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import { Tray, Menu } from 'electron' | ||
import { getMessageTrayIcon, getNoMessageTrayIcon } from './logo' | ||
|
||
export default class DingtalkTray { | ||
_dingtalk = null | ||
// 图标闪烁定时 | ||
_flickerTimer = null | ||
|
||
// 托盘对象 | ||
$tray = null | ||
|
||
constructor ({ dingtalk }) { | ||
this._dingtalk = dingtalk | ||
// 生成托盘图标及其菜单项实例 | ||
this.$tray = new Tray(getNoMessageTrayIcon()) | ||
// 设置鼠标悬浮时的标题 | ||
this.$tray.setToolTip('钉钉') | ||
this.initMenu() | ||
this.initEvent() | ||
} | ||
|
||
/** | ||
* 初始化菜单 | ||
*/ | ||
initMenu () { | ||
// 绑定菜单 | ||
this.$tray.setContextMenu( | ||
Menu.buildFromTemplate([ | ||
{ | ||
label: '显示窗口', | ||
click: () => this._dingtalk.showMainWin() | ||
}, | ||
{ | ||
label: '屏幕截图', | ||
click: () => this._dingtalk.shortcutCapture() | ||
}, | ||
{ | ||
label: '设置', | ||
click: () => this._dingtalk.showSettingWin() | ||
}, | ||
{ | ||
label: '关于', | ||
click: () => this._dingtalk.showAboutWin() | ||
}, | ||
{ | ||
label: '退出', | ||
click: () => this._dingtalk.quit() | ||
} | ||
]) | ||
) | ||
} | ||
|
||
/** | ||
* 初始化事件 | ||
*/ | ||
initEvent () { | ||
this.$tray.on('click', () => this._dingtalk.showMainWin()) | ||
this.$tray.on('double-click', () => this._dingtalk.showMainWin()) | ||
} | ||
|
||
/** | ||
* 控制图标是否闪烁 | ||
* @param {Boolean} is | ||
*/ | ||
flicker (is) { | ||
const messageTrayIcon = getMessageTrayIcon() | ||
const noMessageTrayIcon = getNoMessageTrayIcon() | ||
if (is) { | ||
// 防止连续调用多次,导致图标切换时间间隔不是500ms | ||
if (this._flickerTimer !== null) return | ||
let icon = messageTrayIcon | ||
this._flickerTimer = setInterval(() => { | ||
this.$tray.setImage(icon) | ||
icon = icon === messageTrayIcon ? noMessageTrayIcon : messageTrayIcon | ||
}, 500) | ||
} else { | ||
clearInterval(this._flickerTimer) | ||
this._flickerTimer = null | ||
this.$tray.setImage(noMessageTrayIcon) | ||
} | ||
} | ||
|
||
/** | ||
* 判断托盘是否销毁 | ||
*/ | ||
isDestroyed () { | ||
return this.$tray.isDestroyed() | ||
} | ||
|
||
/** | ||
* 销毁托盘图标 | ||
*/ | ||
destroy () { | ||
return this.$tray.destroy() | ||
} | ||
} |
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
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
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.