From e5eee02b62e566b1a1c1a35edcdb13121625f770 Mon Sep 17 00:00:00 2001 From: imndx Date: Sat, 26 Sep 2020 23:26:57 +0800 Subject: [PATCH] add badge support --- main.js | 5 +++ package-lock.json | 63 +++++++++++++++++++++------------ package.json | 1 + src/js/ui/pages/Footer/index.js | 4 +-- src/js/ui/pages/Layout.js | 22 +++++++----- 5 files changed, 61 insertions(+), 34 deletions(-) diff --git a/main.js b/main.js index 36b2ca7e..8710e8c3 100644 --- a/main.js +++ b/main.js @@ -23,6 +23,8 @@ import i18n from 'i18n'; import proto from './marswrapper.node'; import pkg from './package.json'; +import Badge from 'electron-windows-badge'; + let Locales = {}; i18n.configure({ @@ -557,6 +559,8 @@ const createMainWindow = () => { frame: !isWin, icon }); + const badgeOptions = {} + new Badge(mainWindow, badgeOptions); mainWindow.setSize(400, 480); mainWindow.loadURL( @@ -765,6 +769,7 @@ const createMainWindow = () => { var counter = args.counter; //if (settings.showOnTray) { updateTray(counter); + app.setBadgeCount(counter); //} }); diff --git a/package-lock.json b/package-lock.json index cbad08b5..a89acfed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "wildfireChat", - "version": "0.3.4", + "version": "0.4.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -3033,7 +3033,8 @@ "version": "3.0.1", "resolved": "https://registry.npm.taobao.org/boolean/download/boolean-3.0.1.tgz", "integrity": "sha1-NezytKLuGRsLRJhvFOtfBSpcu08=", - "dev": true + "dev": true, + "optional": true }, "bowser": { "version": "1.9.4", @@ -5307,6 +5308,11 @@ } } }, + "electron-windows-badge": { + "version": "1.1.0", + "resolved": "https://registry.npm.taobao.org/electron-windows-badge/download/electron-windows-badge-1.1.0.tgz", + "integrity": "sha1-y8h0xoXnbaQrY1Zbi8g+q3xluWE=" + }, "elliptic": { "version": "6.5.1", "resolved": "https://registry.npm.taobao.org/elliptic/download/elliptic-6.5.1.tgz?cache=0&sync_timestamp=1567592249994&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Felliptic%2Fdownload%2Felliptic-6.5.1.tgz", @@ -6793,7 +6799,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -6814,12 +6821,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -6834,17 +6843,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -6961,7 +6973,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -6973,6 +6986,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -6987,6 +7001,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -6994,12 +7009,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -7018,6 +7035,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -7098,7 +7116,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -7110,6 +7129,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -7195,7 +7215,8 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -7231,6 +7252,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -7250,6 +7272,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -7293,12 +7316,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, @@ -9688,7 +9713,8 @@ "version": "2.14.0", "resolved": "https://registry.npm.taobao.org/nan/download/nan-2.14.0.tgz", "integrity": "sha1-eBj3IgJ7JFmobwKV1DTR/CM2xSw=", - "dev": true + "dev": true, + "optional": true }, "nanomatch": { "version": "1.2.13", @@ -12865,15 +12891,6 @@ "integrity": "sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU=", "dev": true }, - "sleep": { - "version": "6.1.0", - "resolved": "https://registry.npm.taobao.org/sleep/download/sleep-6.1.0.tgz", - "integrity": "sha1-VQe1IFVqgv+5g9ORI8VFlHD6Kp4=", - "dev": true, - "requires": { - "nan": "^2.13.2" - } - }, "slice-ansi": { "version": "2.1.0", "resolved": "https://registry.npm.taobao.org/slice-ansi/download/slice-ansi-2.1.0.tgz", diff --git a/package.json b/package.json index 5922a7c8..e37c2ee2 100755 --- a/package.json +++ b/package.json @@ -109,6 +109,7 @@ "electron-json-storage": "^4.0.2", "electron-screenshots": "0.0.10", "electron-window-state": "^4.1.1", + "electron-windows-badge": "^1.1.0", "emoji-mart": "^2.11.1", "file-saver": "^2.0.2", "han": "^0.0.7", diff --git a/src/js/ui/pages/Footer/index.js b/src/js/ui/pages/Footer/index.js index 9e40ec06..f8ae2199 100644 --- a/src/js/ui/pages/Footer/index.js +++ b/src/js/ui/pages/Footer/index.js @@ -57,7 +57,7 @@ export default class Footer extends Component { return (