Skip to content

Commit 1eafcca

Browse files
committed
bugs fixed + push notification
1 parent abbeaad commit 1eafcca

File tree

7 files changed

+446
-19
lines changed

7 files changed

+446
-19
lines changed

index.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@
4040
}
4141
</script>
4242

43-
<script src="supporter.js"></script>
44-
<script src="updater.js"></script>
43+
<script src="supporter.js"></script><!-- support wnr running -->
44+
<script src="updater.js"></script><!-- check for updates -->
45+
<script src="querier.js"></script><!-- query push messages -->
4546
<script>
4647
if (!store.get('tour')) {
4748
store.set('tour', 'true');

locales/en.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@
134134
"locker": "Lock Mode",
135135
"locker-settings": "Lock Mode Settings",
136136
"locker-settings-tip": "When lock mode is on, you cannot edit settings or exit wnr. On macOS, the dock icon and top bar will be hidden. Status: ",
137-
"on": "",
138-
"off": "",
137+
"on": "on",
138+
"off": "off",
139139
"period-symbol": ".",
140140
"locker-settings-input": "Input the password here",
141141
"locker-settings-input-again": "Input the password again",

main.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function alarmSet() {
7575
{
7676
title: i18n.__('alarm-for-not-using-wnr-dialog-box-title'),
7777
message: i18n.__('alarm-for-not-using-wnr-dialog-box-content'),
78-
icon: path.join(__dirname, process.platform == "win32" ? '\\res\\icons\\wnrIcon.png' : '\\res\\icons\\iconMac.png'),
78+
icon: path.join(__dirname, process.platform == "win32" ? '\\res\\icons\\wnrIcon.png' : '/res/icons/iconMac.png'),
7979
sound: true,
8080
wait: true //to wait with callback, until user action is taken against notification
8181
}, function () {
@@ -753,6 +753,23 @@ ipcMain.on('locker-passcode', function (event, message) {
753753
})
754754
})
755755

756+
ipcMain.on('push-notification', function (event, message) {
757+
if (!store.get(message.id)) {
758+
notifier.notify(
759+
{
760+
title: message.title,
761+
message: message.content,
762+
icon: path.join(__dirname, process.platform == "win32" ? '\\res\\icons\\wnrIcon.png' : '/res/icons/iconMac.png'),
763+
sound: true,
764+
wait: true //to wait with callback, until user action is taken against notification
765+
}, function () {
766+
if (message.link != "" && message.link != null) shell.openExternal(message.link);
767+
}
768+
);
769+
store.set(message.id, true);
770+
}
771+
})
772+
756773
ipcMain.on('only-one-min-left', function () {
757774
//if (!store.get('fullscreen-protection'))
758775
notifier.notify(

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wnr",
3-
"version": "1.10.1",
3+
"version": "1.10.2",
44
"description": "It's a timer app with strong expansibility for computers. The name is an abbr of \"Work and Rest\".",
55
"main": "main.js",
66
"scripts": {
@@ -25,10 +25,11 @@
2525
"compare-version": "0.1.2",
2626
"electron-store": "5.1.0",
2727
"i18n": "0.8.5",
28+
"leancloud-storage": "4.2.0",
29+
"md5": "2.2.1",
2830
"node-notifier": "6.0.0",
2931
"request": "2.88.0",
30-
"winreg": "1.2.4",
31-
"md5": "2.2.1"
32+
"winreg": "1.2.4"
3233
},
3334
"devDependencies": {
3435
"electron": "7.1.11",

querier.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
var AV = require('leancloud-storage');
2+
var { Query } = AV;
3+
AV.init({
4+
appId: "p02Iwq6diOAtL0s7NNsYx8Uf-MdYXbMMI",
5+
appKey: "Qrqz9Td7Iz39xHAi1PIzXqmo",
6+
});
7+
8+
var pushNotifications = new AV.Query('notifications');
9+
pushNotifications.descending('createdAt');
10+
pushNotifications.limit(3);
11+
12+
pushNotifications.find().then(function (notifications) {
13+
notifications.forEach(function (notification) {
14+
if (notification.get('targetVersion') == null || notification.get("targetVersion") == "" || notification.get("targetVersion") == require("./package.json").version.toString()) {
15+
var content = store.get("i18n") == 'zh' ? notification.get('notificationContentChinese') : notification.get('notificationContentEnglish');
16+
var title = store.get("i18n") == 'zh' ? notification.get('notificationTitleChinese') : notification.get('notificationTitleEnglish');
17+
var link = store.get("i18n") == 'zh' ? notification.get('notificationLinkChinese') : notification.get('notificationLinkEnglish');
18+
var id = notification.get('objectId');
19+
ipc.send("push-notification", { content: content, title: title, link: link, id: id })
20+
}
21+
})
22+
})

res/builder/win.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,24 @@ const config = {
77
],
88
"win": {
99
"target": [
10-
"dir"
10+
"nsis"
1111
],
1212
"icon": "res/icons/iconWin.ico",
1313
"files": [
1414
"**/*",
1515
//! to exclude
1616
"!res/icons/*Mac*",
1717
"!res/icons/*.psd"
18-
]
18+
],
19+
},
20+
"nsis": {
21+
"installerLanguages": [
22+
"en-US",
23+
"zh-CN"
24+
],
25+
"guid": "B5BF1EA0-B474-40D3-B31E-6AD92477CCAF",
26+
"license": "LICENSE",
27+
"oneClick": false
1928
}
2029
}
2130

0 commit comments

Comments
 (0)