diff --git a/fe/modules/index/Index.vue b/fe/modules/index/Index.vue index aa6723e..d09601e 100644 --- a/fe/modules/index/Index.vue +++ b/fe/modules/index/Index.vue @@ -122,14 +122,14 @@ export default { click() { that.forwardWindow() } - }, + }, { label: '后退', visible: true, click () { that.backWindow() } - }, + }, { label: '刷新', visible: true, @@ -273,7 +273,7 @@ export default { const release = os.release() const first = parseInt(release.split('.')[0], 10) if (first !== 10) { // 判断在windows以下都用自己开发的Notification来进行通知 - mainWindow.Notification = nativeNotify + mainWindow.Notification = nativeNotify } else { // 如果是win10 mainWindow.Notification = notification } @@ -887,9 +887,11 @@ body.win .welcome-page:before { user-select: none; } .drag-bar-win .traffic-lights > span { - display: inline-block; - height: 12px; + display: flex; + height: 100%; width: 12px; + align-items: center; + justify-content: center; } .drag-bar-win .traffic-lights > span img { vertical-align: top; @@ -920,4 +922,4 @@ body.win .traffic-lights.mac { display: none; } - \ No newline at end of file + diff --git a/fe/modules/utils/nativeNotify.js b/fe/modules/utils/nativeNotify.js index d452dd0..f98059c 100755 --- a/fe/modules/utils/nativeNotify.js +++ b/fe/modules/utils/nativeNotify.js @@ -25,22 +25,22 @@ NativeNotify.prototype.offEvents = () => { ipcRenderer.removeAllListeners(EVENTS.Notification_Close_reply) } -NativeNotify.prototype.initEvents = () => { +NativeNotify.prototype.initEvents = function () { ipcRenderer.on(EVENTS.Notification_Show_reply, this.onNotificationShow.bind(this)) ipcRenderer.on(EVENTS.Notification_Click_reply, this.onNotificationClick.bind(this)) ipcRenderer.on(EVENTS.Notification_Close_reply, this.onNotificationClose.bind(this)) } -NativeNotify.prototype.onNotificationShow = () => { +NativeNotify.prototype.onNotificationShow = function () { this.sound() if (this.onshow) this.onshow() } -NativeNotify.prototype.onNotificationClick = () => { +NativeNotify.prototype.onNotificationClick = function () { if (this.onclick) this.onclick() } -NativeNotify.prototype.onNotificationClose = () => { +NativeNotify.prototype.onNotificationClose = function () { if (this.onclose) this.onclose() } diff --git a/main.js b/main.js index 92efc87..ab40044 100644 --- a/main.js +++ b/main.js @@ -3,6 +3,7 @@ Sentry.init(); const electron = require('electron'); const pkg = require('./package.json'); const Menu = require('./native/menu'); +const Update = require('./native/update'); const path = require('path'); const download = require('./download'); const preference = require('./preference'); @@ -69,6 +70,7 @@ class Main { await this._createWindow(); download.initWindow(); preference.initWindow(); + const u = new Update(this.mainWindow); const m = new Menu(this.mainWindow); } diff --git a/native/update.js b/native/update.js new file mode 100644 index 0000000..79dc72a --- /dev/null +++ b/native/update.js @@ -0,0 +1,33 @@ +const Notification = require('electron').Notification; +const autoUpdater = require('electron-updater').autoUpdater; +const pkg = require('../package.json'); +const Sentry = require('./sentry'); + +class Update { + constructor (mainWindow) { + this.mainWindow = mainWindow; + this.webContents = mainWindow.webContents; + this.setAutoUpdate(); + } + setAutoUpdate () { + autoUpdater.on('update-downloaded', function (info) { + const notify = new Notification({ + title: `日事清V${info.version} 已准备就绪!`, + body: `请退出当前应用,以便完成更新!` + }); + notify.show(); + }); + autoUpdater.on('error', function (error) { + const notify = new Notification({ + title: '日事清PC端自动更新出错了!!!', + body: error.message + }); + Sentry.captureException(new Error(error)); + notify.show(); + }); + if (pkg.env !== 'dev' && pkg.env !== 'debug') { + autoUpdater.checkForUpdates(); + } + } +} +module.exports = Update; diff --git a/package.json b/package.json index 03d01db..6d4f4c4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rishiqing-electron", - "version": "3.2.1", + "version": "3.2.4", "author": "北京创仕科锐信息技术有限责任公司", "electronVersion": "3.0.10", "main": "main.js",