Skip to content

Commit

Permalink
bugs fixed + push notification
Browse files Browse the repository at this point in the history
  • Loading branch information
RoderickQiu committed Feb 5, 2020
1 parent abbeaad commit 1eafcca
Show file tree
Hide file tree
Showing 7 changed files with 446 additions and 19 deletions.
5 changes: 3 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@
}
</script>

<script src="supporter.js"></script>
<script src="updater.js"></script>
<script src="supporter.js"></script><!-- support wnr running -->
<script src="updater.js"></script><!-- check for updates -->
<script src="querier.js"></script><!-- query push messages -->
<script>
if (!store.get('tour')) {
store.set('tour', 'true');
Expand Down
4 changes: 2 additions & 2 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@
"locker": "Lock Mode",
"locker-settings": "Lock Mode Settings",
"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: ",
"on": "",
"off": "",
"on": "on",
"off": "off",
"period-symbol": ".",
"locker-settings-input": "Input the password here",
"locker-settings-input-again": "Input the password again",
Expand Down
19 changes: 18 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function alarmSet() {
{
title: i18n.__('alarm-for-not-using-wnr-dialog-box-title'),
message: i18n.__('alarm-for-not-using-wnr-dialog-box-content'),
icon: path.join(__dirname, process.platform == "win32" ? '\\res\\icons\\wnrIcon.png' : '\\res\\icons\\iconMac.png'),
icon: path.join(__dirname, process.platform == "win32" ? '\\res\\icons\\wnrIcon.png' : '/res/icons/iconMac.png'),
sound: true,
wait: true //to wait with callback, until user action is taken against notification
}, function () {
Expand Down Expand Up @@ -753,6 +753,23 @@ ipcMain.on('locker-passcode', function (event, message) {
})
})

ipcMain.on('push-notification', function (event, message) {
if (!store.get(message.id)) {
notifier.notify(
{
title: message.title,
message: message.content,
icon: path.join(__dirname, process.platform == "win32" ? '\\res\\icons\\wnrIcon.png' : '/res/icons/iconMac.png'),
sound: true,
wait: true //to wait with callback, until user action is taken against notification
}, function () {
if (message.link != "" && message.link != null) shell.openExternal(message.link);
}
);
store.set(message.id, true);
}
})

ipcMain.on('only-one-min-left', function () {
//if (!store.get('fullscreen-protection'))
notifier.notify(
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wnr",
"version": "1.10.1",
"version": "1.10.2",
"description": "It's a timer app with strong expansibility for computers. The name is an abbr of \"Work and Rest\".",
"main": "main.js",
"scripts": {
Expand All @@ -25,10 +25,11 @@
"compare-version": "0.1.2",
"electron-store": "5.1.0",
"i18n": "0.8.5",
"leancloud-storage": "4.2.0",
"md5": "2.2.1",
"node-notifier": "6.0.0",
"request": "2.88.0",
"winreg": "1.2.4",
"md5": "2.2.1"
"winreg": "1.2.4"
},
"devDependencies": {
"electron": "7.1.11",
Expand Down
22 changes: 22 additions & 0 deletions querier.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
var AV = require('leancloud-storage');
var { Query } = AV;
AV.init({
appId: "p02Iwq6diOAtL0s7NNsYx8Uf-MdYXbMMI",
appKey: "Qrqz9Td7Iz39xHAi1PIzXqmo",
});

var pushNotifications = new AV.Query('notifications');
pushNotifications.descending('createdAt');
pushNotifications.limit(3);

pushNotifications.find().then(function (notifications) {
notifications.forEach(function (notification) {
if (notification.get('targetVersion') == null || notification.get("targetVersion") == "" || notification.get("targetVersion") == require("./package.json").version.toString()) {
var content = store.get("i18n") == 'zh' ? notification.get('notificationContentChinese') : notification.get('notificationContentEnglish');
var title = store.get("i18n") == 'zh' ? notification.get('notificationTitleChinese') : notification.get('notificationTitleEnglish');
var link = store.get("i18n") == 'zh' ? notification.get('notificationLinkChinese') : notification.get('notificationLinkEnglish');
var id = notification.get('objectId');
ipc.send("push-notification", { content: content, title: title, link: link, id: id })
}
})
})
13 changes: 11 additions & 2 deletions res/builder/win.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,24 @@ const config = {
],
"win": {
"target": [
"dir"
"nsis"
],
"icon": "res/icons/iconWin.ico",
"files": [
"**/*",
//! to exclude
"!res/icons/*Mac*",
"!res/icons/*.psd"
]
],
},
"nsis": {
"installerLanguages": [
"en-US",
"zh-CN"
],
"guid": "B5BF1EA0-B474-40D3-B31E-6AD92477CCAF",
"license": "LICENSE",
"oneClick": false
}
}

Expand Down
Loading

0 comments on commit 1eafcca

Please sign in to comment.