Skip to content

Commit

Permalink
make tray statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
RoderickQiu committed Mar 6, 2023
1 parent 74c20e1 commit b0b5789
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 9 deletions.
3 changes: 2 additions & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -383,5 +383,6 @@
"autostarttask-tip" : "When a default task is set and this setting is on, wnr will automatically start the default task every time this app is opened. ",
"withdraw-timing": "Withdraw timing",
"fail-to-withdraw": "You cannot withdraw timing currently. ",
"today-total": "today "
"statistics-enter": "Enter statistics",
"today-total": "Today "
}
1 change: 1 addition & 0 deletions locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -378,5 +378,6 @@
"autostarttask-tip" : "当设置了默认预设且开启了此选项后,将在每次打开 wnr 软件时自动开始默认预设的计时,以提升强力水平。",
"withdraw-timing": "提前退出计时",
"fail-to-withdraw": "当前不能提前退出。",
"statistics-enter": "进入统计界面",
"today-total": "今日 "
}
1 change: 1 addition & 0 deletions locales/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -378,5 +378,6 @@
"autostarttask-tip" : "當設置了默認預設且開啟了此選項後,將在每次打開 wnr 軟件時自動開始默認預設的計時,以提升強力水平。",
"withdraw-timing": "提前退出計時",
"fail-to-withdraw": "當前不能提前退出。",
"statistics-enter": "進入統計界面",
"today-total": "今日 "
}
55 changes: 47 additions & 8 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const winReleaseId = require('win-release-id');
let win = null, settingsWin = null, aboutWin = null, tourWin = null, floatingWin = null, externalTitleWin = null,
customDialogWin = null, tray = null, contextMenu = null, settingsWinContextMenu = null,
resetAlarm = null, powerSaveBlockerId = null, sleepBlockerId = null,
isTimerWin = null, isWorkMode = null, isChinese = null, isFocused = true,
isTimerWin = null, isWorkMode = null, isChinese = null, isFocused = true, isFullscreenMode = false,
isOnlyRest = false, isPositiveTiming = false,
timeLeftTip = null, positiveTimingTip = null, trayTimeMsg = null, predefinedTasks = null,
trayH = null, trayMin = null,
Expand Down Expand Up @@ -586,6 +586,7 @@ app.on('ready', () => {
console.log(e);
}
traySolution(false);
isFullscreenMode = false;
macOSFullscreenSolution(false);
isDarkMode();
settingsWinContextMenuSolution();
Expand Down Expand Up @@ -999,20 +1000,41 @@ function traySolution(isFullScreen) {
}
}, {
type: 'separator'
}, {
label: i18n.__('statistics'),
type: 'submenu',
submenu: [{
enabled: !isTimerWin,
label: i18n.__('statistics-enter'),
click: function () {
if (win != null) win.loadFile('statistics.html');
if (process.platform === "darwin" && win != null) win.show();
}
}, {
label: i18n.__('statistics-work-time') + " " + statistics.get(yearMonDay).workTime + " " + i18n.__('min'),
visible: statistics.get(yearMonDay).workTime > 0
}, {
label: i18n.__('statistics-rest-time') + " " + statistics.get(yearMonDay).restTime + " " + i18n.__('min'),
visible: statistics.get(yearMonDay).restTime > 0,
}, {
label: i18n.__('onlyrest') + " " + statistics.get(yearMonDay).onlyRest + " " + i18n.__('min'),
visible: statistics.get(yearMonDay).onlyRest > 0,
}, {
label: i18n.__('positive') + " " + statistics.get(yearMonDay).positive + " " + i18n.__('min'),
visible: statistics.get(yearMonDay).positive > 0
}, {
label: i18n.__('statistics-time-sum') + " " + statistics.get(yearMonDay).sum + " " + i18n.__('min'),
visible: statistics.get(yearMonDay).sum > 0,
}],
}, {
type: 'separator'
}, {
enabled: !isTimerWin,
label: i18n.__('locker-mode'),
click: function () {
if (process.platform === "darwin" && win != null) win.show();
locker();
}
}, {
enabled: !isTimerWin,
label: i18n.__('statistics'),
click: function () {
if (win != null) win.loadFile('statistics.html');
if (process.platform === "darwin" && win != null) win.show();
}
}, {
enabled: (!store.get('islocked')) && (!isTimerWin),
label: i18n.__('settings'),
Expand Down Expand Up @@ -1399,6 +1421,13 @@ function statisticsInitializer() {
statistics.set("year", year);
statistics.set("mon", months[tempDate.getMonth()]);
statistics.set("day", tempDate.getDate().toString());
statistics.set(yearMonDay, {
"workTime": statistics.has(yearMonDay) ? statistics.get(yearMonDay).workTime : 0,
"restTime": statistics.has(yearMonDay) ? statistics.get(yearMonDay).restTime : 0,
"positive": statistics.has(yearMonDay) ? statistics.get(yearMonDay).positive : 0,
"onlyRest": statistics.has(yearMonDay) ? statistics.get(yearMonDay).onlyRest : 0,
"sum": statistics.has(yearMonDay) ? statistics.get(yearMonDay).sum : 0
});
}

function statisticsWriter() {
Expand Down Expand Up @@ -1513,6 +1542,7 @@ function statisticsPauseDealer(startOrStop) {
recorderDate = tempDate;
} else {
statisticsWriter();
traySolution(isFullscreenMode);
}
}

Expand Down Expand Up @@ -1546,6 +1576,7 @@ function focusSolution() {
setFullScreenMode(true);
macOSFullscreenSolution(true);
traySolution(true);
isFullscreenMode = true;
if ((process.env.NODE_ENV !== "development") && (!isLoose)) win.setFocusable(false);
if (sleepBlockerId) {
if (!powerSaveBlocker.isStarted(sleepBlockerId)) {
Expand All @@ -1564,6 +1595,7 @@ function nonFocusSolution(mode) {
setFullScreenMode(false);
macOSFullscreenSolution(false);
traySolution(false);
isFullscreenMode = false;
win.setFocusable(true);
if (sleepBlockerId) {
if (powerSaveBlocker.isStarted(sleepBlockerId)) {
Expand Down Expand Up @@ -1671,6 +1703,8 @@ ipcMain.on('warning-giver-workend', function () {
}, 1500)
}
}

traySolution(isFullscreenMode);
})

ipcMain.on('warning-giver-restend', function () {
Expand Down Expand Up @@ -1709,6 +1743,8 @@ ipcMain.on('warning-giver-restend', function () {
}, 1500)
}
}

traySolution(isFullscreenMode);
})

ipcMain.on('warning-giver-all-task-end', function () {
Expand All @@ -1730,6 +1766,7 @@ ipcMain.on('warning-giver-all-task-end', function () {
setFullScreenMode(false);
macOSFullscreenSolution(false);
traySolution(false);
isFullscreenMode = false;
win.setFocusable(true);
}
let personal = personliazationNotificationSolution(4);
Expand Down Expand Up @@ -1765,6 +1802,8 @@ ipcMain.on('warning-giver-all-task-end', function () {
}, 1000);
}
}

traySolution(isFullscreenMode);
})

ipcMain.on('update-feedback', function (event, message) {
Expand Down

0 comments on commit b0b5789

Please sign in to comment.