Skip to content

Commit 9651914

Browse files
committed
✨ feat(番茄钟): 添加随机提示音系统通知功能
- 新增设置选项以启用/禁用随机提示音系统通知 - 更新相关的国际化文本 - 修改 PomodoroTimer 类以支持系统通知 - 更新默认设置以包含随机提示音系统通知
1 parent 1b52337 commit 9651914

File tree

6 files changed

+22
-6
lines changed

6 files changed

+22
-6
lines changed

public/i18n/en_US.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,8 @@
297297
"randomNotificationSoundsDesc": "Set the random notification sound file path during pomodoro, leave empty to disable",
298298
"randomNotificationEndSound": "Random Notification End Sound",
299299
"randomNotificationEndSoundDesc": "Set the notification sound file path after random notification ends, leave empty for no sound",
300+
"randomNotificationSystemNotification": "Random Notification System Notification",
301+
"randomNotificationSystemNotificationDesc": "Show system notification when random notification plays, reminding to start break and end break",
300302
"dragHint": "Drag and drop category items to adjust the order",
301303
"copyBlockRef": "Copy Block Ref",
302304
"startPomodoro": "Start Pomodoro",

public/i18n/zh_CN.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,8 @@
296296
"randomNotificationSoundsDesc": "设置番茄钟运行时随机提示音的文件路径,留空则不启用",
297297
"randomNotificationEndSound": "随机提示音结束声音",
298298
"randomNotificationEndSoundDesc": "设置随机提示音播放结束后的提示音文件路径,留空则不播放",
299+
"randomNotificationSystemNotification": "随机提示音系统通知",
300+
"randomNotificationSystemNotificationDesc": "随机提示音播放时显示系统通知提醒,提醒开始休息和结束休息",
299301
"dragHint": "拖拽分类项可调整排序",
300302
"copyBlockRef": "复制块引用",
301303
"startPomodoro": "开始番茄钟",

src/SettingPanel.svelte

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,13 @@
160160
title: t('randomNotificationEnabled'),
161161
description: t('randomNotificationEnabledDesc'),
162162
},
163+
{
164+
key: 'randomNotificationSystemNotification',
165+
value: settings.randomNotificationSystemNotification,
166+
type: 'checkbox',
167+
title: t('randomNotificationSystemNotification'),
168+
description: t('randomNotificationSystemNotificationDesc'),
169+
},
163170
{
164171
key: 'randomNotificationMinInterval',
165172
value: settings.randomNotificationMinInterval,

src/components/PomodoroTimer.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export class PomodoroTimer {
6969
private randomNotificationEndSound: HTMLAudioElement = null;
7070

7171
private systemNotificationEnabled: boolean = true; // 新增:系统弹窗开关
72+
private randomNotificationSystemNotificationEnabled: boolean = true; // 新增:随机提示音系统通知开关
7273

7374
private isFullscreen: boolean = false; // 新增:全屏模式状态
7475
private escapeKeyHandler: ((e: KeyboardEvent) => void) | null = null; // 新增:ESC键监听器
@@ -90,6 +91,7 @@ export class PomodoroTimer {
9091

9192
// 初始化随机提示音设置
9293
this.randomNotificationEnabled = settings.randomNotificationEnabled || false;
94+
this.randomNotificationSystemNotificationEnabled = settings.randomNotificationSystemNotification !== false; // 新增
9395

9496
// 初始化自动模式设置
9597
this.autoMode = settings.autoMode || false;
@@ -297,7 +299,7 @@ export class PomodoroTimer {
297299
await selectedAudio.play();
298300

299301
// 新增:显示系统通知
300-
if (this.systemNotificationEnabled) {
302+
if (this.randomNotificationSystemNotificationEnabled) {
301303
this.showSystemNotification(
302304
t('randomNotificationSettings'),
303305
t('randomRest')
@@ -323,7 +325,7 @@ export class PomodoroTimer {
323325
await this.randomNotificationEndSound.play();
324326

325327
// 新增:播放结束声音后显示系统通知
326-
if (this.systemNotificationEnabled) {
328+
if (this.randomNotificationSystemNotificationEnabled) {
327329
this.showSystemNotification(
328330
t('randomNotificationSettings'),
329331
t('randomRestComplete') || '微休息时间结束,可以继续专注工作了!'
@@ -343,7 +345,7 @@ export class PomodoroTimer {
343345
await this.randomNotificationEndSound.play();
344346

345347
// 新增:在延迟播放时也显示系统通知
346-
if (this.systemNotificationEnabled) {
348+
if (this.randomNotificationSystemNotificationEnabled) {
347349
this.showSystemNotification(
348350
t('randomNotificationSettings'),
349351
t('randomRestComplete') || '微休息时间结束,可以继续专注工作了!'
@@ -354,7 +356,7 @@ export class PomodoroTimer {
354356
console.debug('延迟播放随机提示音结束声音失败,这是预期的浏览器安全限制');
355357

356358
// 即使音频播放失败,也要显示系统通知
357-
if (this.systemNotificationEnabled) {
359+
if (this.randomNotificationSystemNotificationEnabled) {
358360
this.showSystemNotification(
359361
t('randomNotificationSettings'),
360362
t('randomRestComplete') || '微休息时间结束,可以继续专注工作了!'

src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export const DEFAULT_SETTINGS = {
5454
randomNotificationBreakDuration: 10,
5555
randomNotificationSounds: '/plugins/siyuan-plugin-task-note-management/audios/random_start.mp3',
5656
randomNotificationEndSound: '/plugins/siyuan-plugin-task-note-management/audios/random_end.mp3',
57+
randomNotificationSystemNotification: true, // 新增:随机提示音系统通知
5758
dailyFocusGoal: 6,
5859
};
5960

@@ -201,6 +202,7 @@ export default class ReminderPlugin extends Plugin {
201202
randomNotificationBreakDuration: Math.max(1, settings.randomNotificationBreakDuration),
202203
randomNotificationSounds: settings.randomNotificationSounds,
203204
randomNotificationEndSound: settings.randomNotificationEndSound,
205+
randomNotificationSystemNotification: settings.randomNotificationSystemNotification, // 新增
204206
dailyFocusGoal: settings.dailyFocusGoal
205207
};
206208
}
@@ -1332,7 +1334,8 @@ export default class ReminderPlugin extends Plugin {
13321334
openCalendarTab() {
13331335
openTab({
13341336
app: this.app,
1335-
custom: {
1337+
custom:
1338+
{
13361339
title: t("calendarView"),
13371340
icon: 'iconCalendar',
13381341
id: this.name + TAB_TYPE,

src/utils/pomodoroRecord.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ export class PomodoroRecordManager {
278278

279279
formatTime(minutes: number): string {
280280
const hours = Math.floor(minutes / 60);
281-
const mins = minutes % 60;
281+
const mins = Math.floor(minutes % 60);
282282

283283
if (hours > 0) {
284284
return `${hours}h ${mins}m`;

0 commit comments

Comments
 (0)