Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
RoderickQiu committed Apr 27, 2019
1 parent bacaf76 commit 7a67143
Show file tree
Hide file tree
Showing 9 changed files with 288 additions and 263 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ As a timer app, wnr is simple but useful.

- modern design

- ...

## To-do List

Please go and see the [GitHub Project](https://github.com/RoderickQiu/wnr/projects/1).
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<input name="loop" id="loop" type="number"
onkeypress="return (/[0-9]/.test(String.fromCharCode(event.keyCode)))" style="ime-mode:Disabled"
class="small" required /><br /><br /><!-- control that only numbers are OK -->
<input name="note" id="note" type="text" class="small" maxlength="22" />
<input name="note" id="note" type="text" class="small" maxlength="39" />
</form>
<script>
$('#work-time').attr('placeholder', i18n.__('worktime'));
Expand Down
91 changes: 52 additions & 39 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const { app, BrowserWindow, ipcMain, Tray, Menu, globalShortcut, dialog, shell }
const Store = require('electron-store');
const store = new Store();
const path = require("path");
const notifier = require('node-notifier');
var i18n = require("i18n")

// Keep a global reference of the window object, if you don't, the window will
Expand All @@ -19,7 +20,7 @@ function createWindow() {
// 创建浏览器窗口。
win = new BrowserWindow({
width: 324,
height: 298,
height: 320,
frame: false,
resizable: false,
show: false,
Expand Down Expand Up @@ -51,6 +52,23 @@ function createWindow() {
})
}

function alarmSet() {
if (!resetAlarm) {
resetAlarm = setInterval(function () {
if (win != null) win.flashFrame(true);
notifier.notify(
{
title: i18n.__('alarmtip'),
message: i18n.__('alarmtipmsg'),
sound: true, // Only Notification Center or Windows Toasters
wait: true // Wait with callback, until user action is taken against notification
}
);
if (!win.isVisible()) win.show();
}, 1200000)//不断提示使用wnr
}
}

// 当程序就要结束
app.on('will-quit', () => {
// 清空所有快捷键
Expand Down Expand Up @@ -178,6 +196,8 @@ app.on('ready', () => {
var osxMenu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(osxMenu)
}// 应付macOS的顶栏空缺


})

app.on('activate', () => {
Expand All @@ -201,18 +221,18 @@ ipcMain.on('warninggiver-workend', function () {
setTimeout(function () {
dialog.showMessageBox(win, {
title: i18n.__('worktimeend'),
type: "info",
message: i18n.__('worktimemsg'),
silent: true
type: "warning",
message: i18n.__('worktimeend'),
}, function (response) {
win.webContents.send('warning-closed');
});
})
}, 100)
}
})

ipcMain.on('warninggiver-restend', function () {
if (win != null) {
if (!win.isVisible()) win.show();
win.flashFrame(true);
if (store.get("fullscreen") == true) {
if (store.get("top") != true) win.setAlwaysOnTop(false);//取消不需要的恒定最上层
Expand All @@ -221,18 +241,18 @@ ipcMain.on('warninggiver-restend', function () {
setTimeout(function () {
dialog.showMessageBox(win, {
title: i18n.__('resttimeend'),
type: "info",
message: i18n.__('resttimemsg')
type: "warning",
message: i18n.__('resttimemsg'),
}, function (response) {
if (!win.isVisible()) win.show();
win.webContents.send('warning-closed');
});
})
}, 180)
}
})

ipcMain.on('warninggiver-allend', function () {
if (win != null) {
if (!win.isVisible()) win.show();
win.flashFrame(true);
if (store.get("fullscreen") == true) {
if (store.get("top") != true) win.setAlwaysOnTop(false);//取消不需要的恒定最上层
Expand All @@ -241,20 +261,13 @@ ipcMain.on('warninggiver-allend', function () {
setTimeout(function () {
dialog.showMessageBox(win, {
title: i18n.__('allend'),
type: "info",
message: i18n.__('allmsg')
}, function () {
if (!win.isVisible()) win.show()
});
type: "warning",
message: i18n.__('allmsg'),
}, function (response) {
win.loadFile('index.html');//回到首页,方便开始新计划
})
}, 100)
resetAlarm = setTimeout(function () {
dialog.showMessageBox(win, {
title: i18n.__('alarmtip'),
type: "info",
message: i18n.__('alarmtipmsg'),
silent: true
});
}, 1200000)
alarmSet();
}
})

Expand All @@ -269,7 +282,6 @@ ipcMain.on('updateavailable', function () {
if (checkboxChecked) {
shell.openExternal("https://github.com/RoderickQiu/wnr/releases/latest");
}

})
})

Expand Down Expand Up @@ -335,12 +347,14 @@ ipcMain.on('settings', function () {
})
if (!store.get("settings-experience")) {
store.set("settings-experience", true);
dialog.showMessageBox(win, {
title: i18n.__('settingstip'),
type: "info",
message: i18n.__('settingstipmsg'),
silent: true
})
notifier.notify(
{
title: i18n.__('settingstip'),
message: i18n.__('settingstipmsg'),
sound: true, // Only Notification Center or Windows Toasters
wait: true // Wait with callback, until user action is taken against notification
}
);
}
})

Expand All @@ -354,6 +368,14 @@ ipcMain.on('tourguide', function () {
tourWin.on('closed', () => {
tourWin = null
})
notifier.notify(
{
title: i18n.__('welcomer1'),
message: i18n.__('alarmtipmsg'),
sound: true, // Only Notification Center or Windows Toasters
wait: true // Wait with callback, until user action is taken against notification
}
);
})

ipcMain.on("progress-bar-set", function (event, message) {
Expand All @@ -380,15 +402,6 @@ ipcMain.on("timer-win", function (event, message) {
contextMenu.items[2].enabled = false;
}
globalShortcut.unregister('CommandOrControl+Shift+Alt+' + store.get('hotkey2'));
if (!resetAlarm) {
resetAlarm = setTimeout(function () {
dialog.showMessageBox(win, {
title: i18n.__('alarmtip'),
type: "info",
message: i18n.__('alarmtipmsg'),
silent: true
});
}, 1200000)
}
alarmSet();
}
})
Loading

0 comments on commit 7a67143

Please sign in to comment.