From cd495fcaf1fd425aae56ac19e9c36d71a00967d3 Mon Sep 17 00:00:00 2001 From: nashaofu Date: Wed, 21 Nov 2018 23:55:10 +0800 Subject: [PATCH 1/6] =?UTF-8?q?modify=20=E4=BF=AE=E6=94=B9=E6=96=87?= =?UTF-8?q?=E6=A1=88=EF=BC=8C=E5=8D=87=E7=BA=A7=E6=88=AA=E5=9B=BE=E5=B7=A5?= =?UTF-8?q?=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++-- package.json | 2 +- src/main/dingtalk.js | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 89d8997..8e45392 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ 钉钉桌面版,基于electron和钉钉网页版开发,支持Windows、Linux和macOS ## 安装步骤 -> 直接从[GitHub relase](https://github.com/nashaofu/dingtalk/releases/latest)页面下载最新版安装包即可 +> 直接从[GitHub releases](https://github.com/nashaofu/dingtalk/releases/latest)页面下载最新版安装包即可 ## 国内仓库与版本安装包 * 国内git地址:[https://gitee.com/nashaofu/dingtalk](https://gitee.com/nashaofu/dingtalk) @@ -79,5 +79,5 @@ npm run pack 加密信息暂不支持,详情请看[企业信息加密相关](https://github.com/nashaofu/dingtalk/issues/2),也欢迎各位朋友能够去研究一下,帮助实现这个功能 ## 打赏 -如果你觉的作者德辛苦付出有帮助到你,你可以给作者买杯咖啡!🤣 +如果你觉得作者的辛苦付出有帮助到你,你可以给作者买杯咖啡!🤣 ![打赏](./screenshot/reward.png) diff --git a/package.json b/package.json index 4575983..21e2eb3 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "electron-updater": "^4.0.4", "lodash": "^4.17.10", "normalize.css": "^8.0.0", - "shortcut-capture": "^1.0.1" + "shortcut-capture": "^1.0.2" }, "devDependencies": { "autoprefixer": "^7.2.6", diff --git a/src/main/dingtalk.js b/src/main/dingtalk.js index 5ed442d..12b8350 100644 --- a/src/main/dingtalk.js +++ b/src/main/dingtalk.js @@ -114,6 +114,7 @@ export default class DingTalk { * 退出应用 */ quit () { + this.$shortcutCapture.quit() BrowserWindow.getAllWindows().forEach(item => { if (!item.isDestroyed()) item.destroy() }) From 889897d8ce4198bb9d56a4e6231beeb88ec37bca Mon Sep 17 00:00:00 2001 From: nashaofu Date: Wed, 21 Nov 2018 23:59:38 +0800 Subject: [PATCH 2/6] =?UTF-8?q?modify=20=20=E4=BF=AE=E6=94=B9quit=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E5=86=85=E9=83=A8=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/dingtalk.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/dingtalk.js b/src/main/dingtalk.js index 12b8350..b70dac0 100644 --- a/src/main/dingtalk.js +++ b/src/main/dingtalk.js @@ -114,7 +114,7 @@ export default class DingTalk { * 退出应用 */ quit () { - this.$shortcutCapture.quit() + this.$shortcutCapture.destroy() BrowserWindow.getAllWindows().forEach(item => { if (!item.isDestroyed()) item.destroy() }) From 8b3090deafbf0f7b6af43180af2ce4005f2fbf25 Mon Sep 17 00:00:00 2001 From: nashaofu Date: Sat, 8 Dec 2018 14:57:21 +0800 Subject: [PATCH 3/6] =?UTF-8?q?modify=20=E4=BF=AE=E6=94=B9electron?= =?UTF-8?q?=E4=B8=BA2.0=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 14 ++++----- src/main/dingtalk.js | 71 ++++++++++++++++++++++++++++++++----------- src/main/index.dev.js | 4 +-- 3 files changed, 61 insertions(+), 28 deletions(-) diff --git a/package.json b/package.json index 21e2eb3..afbfb19 100644 --- a/package.json +++ b/package.json @@ -28,10 +28,10 @@ "dependencies": { "axios": "^0.18.0", "electron-store": "^2.0.0", - "electron-updater": "^4.0.4", - "lodash": "^4.17.10", - "normalize.css": "^8.0.0", - "shortcut-capture": "^1.0.2" + "electron-updater": "^3.2.3", + "lodash": "^4.17.11", + "normalize.css": "^8.0.1", + "shortcut-capture": "^1.0.3" }, "devDependencies": { "autoprefixer": "^7.2.6", @@ -43,10 +43,10 @@ "babel-preset-stage-2": "^6.24.1", "chalk": "^2.3.0", "css-loader": "^0.28.9", - "electron": "^3.0.9", - "electron-builder": "^20.36.2", + "electron": "^2.0.14", + "electron-builder": "^20.38.2", "electron-debug": "^2.0.0", - "electron-dev-webpack-plugin": "0.0.10", + "electron-dev-webpack-plugin": "0.0.11", "electron-devtools-installer": "^2.2.4", "eslint": "^4.17.0", "eslint-config-standard": "^10.2.1", diff --git a/src/main/dingtalk.js b/src/main/dingtalk.js index b70dac0..0d6ad6f 100644 --- a/src/main/dingtalk.js +++ b/src/main/dingtalk.js @@ -13,6 +13,8 @@ import shortcut from './shortcut' import ShortcutCapture from 'shortcut-capture' export default class DingTalk { + // app对象是否ready + _ready = null // 托盘图标 $tray = null // 主窗口 @@ -38,18 +40,18 @@ export default class DingTalk { } constructor () { - // 同时只能运行一个人实例 - if (!app.requestSingleInstanceLock()) return app.quit() - this.init().then(() => { - // 移除窗口菜单 - Menu.setApplicationMenu(null) - this.initMainWin() - this.initTray() - this.initShortcutCapture() - this.initNotify() - this.autoUpdate() - this.bindShortcut() - }) + if (!this.requestSingleInstanceLock()) { + this.init().then(() => { + // 移除窗口菜单 + Menu.setApplicationMenu(null) + this.initMainWin() + this.initTray() + this.initShortcutCapture() + this.initNotify() + this.autoUpdate() + this.bindShortcut() + }) + } } /** @@ -59,9 +61,20 @@ export default class DingTalk { async init () { online(this)() this.setting = await initSetting(this)() - // 第二次打开应用,显示主窗口 - app.on('second-instance', (event, commandLine, workingDirectory) => this.showMainWin()) - return app.whenReady() + return this.whenReady() + } + + /** + * 使应用程序成为单个实例应用程序 + * 而不是允许应用程序的多个实例运行 + * 这将确保只有一个应用程序的实例正在运行 + * 其余的实例全部会被终止并退出 + */ + requestSingleInstanceLock () { + // 同时只能运行一个人实例 + const isSecond = app.makeSingleInstance(() => this.showMainWin()) + if (isSecond) app.quit() + return isSecond } /** @@ -110,14 +123,36 @@ export default class DingTalk { return writeSetting(this)() } + /** + * app是否ready + * @return {Promise} setting + */ + whenReady () { + if (this._ready) return this._ready + this._ready = new Promise((resolve, reject) => { + if (app.isReady()) return resolve() + app.once('ready', () => resolve()) + // 所有窗口关闭之后退出应用 + app.once('window-all-closed', () => { + if (process.platform !== 'darwin') { + if (this.$tray && !this.$tray.isDestroyed()) { + this.$tray.destroy() + this.$tray = null + } + app.quit() + } + }) + }) + return this._ready + } + /** * 退出应用 */ quit () { this.$shortcutCapture.destroy() - BrowserWindow.getAllWindows().forEach(item => { - if (!item.isDestroyed()) item.destroy() - }) + const windows = BrowserWindow.getAllWindows() + windows.forEach(item => !item.isDestroyed() && item.destroy()) if (process.platform !== 'darwin') { if (this.$tray && !this.$tray.isDestroyed()) { this.$tray.destroy() diff --git a/src/main/index.dev.js b/src/main/index.dev.js index 9b94750..0af86b6 100644 --- a/src/main/index.dev.js +++ b/src/main/index.dev.js @@ -7,7 +7,5 @@ app.on('ready', () => { installExtension.default(installExtension.VUEJS_DEVTOOLS).catch(err => { console.log('Unable to install `vue-devtools`: \n', err) }) - app.whenReady().then(() => { - debug({ showDevTools: 'undocked' }) - }) + debug({ showDevTools: 'undocked' }) }) From 5c3af55701f3114fd76a5c398244abac8634d686 Mon Sep 17 00:00:00 2001 From: nashaofu Date: Sat, 8 Dec 2018 15:32:03 +0800 Subject: [PATCH 4/6] =?UTF-8?q?modify=20=E4=BF=AE=E6=94=B9electron-builder?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index afbfb19..33a7eff 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "chalk": "^2.3.0", "css-loader": "^0.28.9", "electron": "^2.0.14", - "electron-builder": "^20.38.2", + "electron-builder": "^20.34.0", "electron-debug": "^2.0.0", "electron-dev-webpack-plugin": "0.0.11", "electron-devtools-installer": "^2.2.4", From 7bd8049bc536c334950e9ab8858e169cf640c43a Mon Sep 17 00:00:00 2001 From: nashaofu Date: Sun, 9 Dec 2018 11:32:20 +0800 Subject: [PATCH 5/6] =?UTF-8?q?modify=20=E4=BF=AE=E6=94=B9=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 33a7eff..0444b07 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "chalk": "^2.3.0", "css-loader": "^0.28.9", "electron": "^2.0.14", - "electron-builder": "^20.34.0", + "electron-builder": "<=20.34.0", "electron-debug": "^2.0.0", "electron-dev-webpack-plugin": "0.0.11", "electron-devtools-installer": "^2.2.4", From df70585512df9ac1b1bbb6d9ffe5ea9c4082e7ff Mon Sep 17 00:00:00 2001 From: nashaofu Date: Sun, 9 Dec 2018 12:02:06 +0800 Subject: [PATCH 6/6] release 2.0.10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix 修复deepin托盘图标显示错误问题 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0444b07..ac54725 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dingtalk", - "version": "2.0.9", + "version": "2.0.10", "description": "钉钉桌面版,基于electron和钉钉网页版开发,支持Windows、Linux和macOS", "author": "nashaofu ", "main": "dist/main.js",