Skip to content

Commit

Permalink
Merge pull request #57 from rishiqing/beta
Browse files Browse the repository at this point in the history
beta
  • Loading branch information
qinyang912 authored Jun 17, 2019
2 parents 3911f76 + c7c1a91 commit 5575189
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 11 deletions.
14 changes: 8 additions & 6 deletions fe/modules/index/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,14 @@ export default {
click() {
that.forwardWindow()
}
},
},
{
label: '后退',
visible: true,
click () {
that.backWindow()
}
},
},
{
label: '刷新',
visible: true,
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -920,4 +922,4 @@ body.win .traffic-lights.mac {
display: none;
}
</style>
</style>
8 changes: 4 additions & 4 deletions fe/modules/utils/nativeNotify.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
2 changes: 2 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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);
}

Expand Down
33 changes: 33 additions & 0 deletions native/update.js
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rishiqing-electron",
"version": "3.2.1",
"version": "3.2.4",
"author": "北京创仕科锐信息技术有限责任公司",
"electronVersion": "3.0.10",
"main": "main.js",
Expand Down

0 comments on commit 5575189

Please sign in to comment.