dsh-reminder-notify 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -33,6 +33,15 @@ dsh plugin --profile desktop add link:<本目录绝对路径>
33
33
  - 每条结果写进 `~/.dsh/dsh-reminder-notify/history.json`(`historyEnabled` / `historyLimit`),
34
34
  插件页「历史与统计」里能看到总计 / 今日条数和最近记录,可以一键清空。
35
35
 
36
+ 0.12 起多了两件「离屏也能知道」的事:
37
+
38
+ - **每日日报**(`digestEnabled` + `digestTime`,默认 09:00):到点弹一张卡,写今天弹了几条、你点掉了几条,
39
+ 末尾附当前余额;一天只发一条,关机错过不补。
40
+ - **条数预警**(`digestAlertCount`,默认 0 = 关):当天提醒条数超过阈值时,额外弹一张「提醒有点多」。
41
+ - **手机推送**(`pushEnabled` + `pushUrl` + `pushFormat`):`wecom` 企业微信机器人 / `serverchan` Server 酱 /
42
+ `json` 通用 webhook / `text` 纯文本;`pushDecide` 管「需要你来决定」要不要推,`pushDigest` 管日报要不要推。
43
+ 推送失败不影响桌面卡片,也不会拖慢 `notify_user`。
44
+
36
45
  ## 资产
37
46
 
38
47
  | 东西 | 位置 |
@@ -62,6 +71,8 @@ dsh plugin --profile desktop add link:<本目录绝对路径>
62
71
  `quietMode`(`hold`/`skip`)、`compactOnFullscreen`、`historyEnabled`、`historyLimit`(200)、
63
72
  `historyFile`(留空 = `~/.dsh/dsh-reminder-notify/history.json`)。
64
73
 
74
+ 0.12 新增:`digestEnabled`(false)、`digestTime`(09:00)、`digestTitle`(今日提醒日报)、`digestIncludeBalance`(true)、`digestAlertCount`(0)、`pushEnabled`(false)、`pushUrl`、`pushFormat`(wecom)、`pushDecide`(true)、`pushDigest`(true)。
75
+
65
76
  ## 已知限制
66
77
 
67
78
  - 仅 Windows(`os: ["win32"]`):卡片宿主是 WinForms。
package/client.js CHANGED
@@ -22,6 +22,7 @@ window.__ModuleLoader__.load({
22
22
  const BALANCE_ROUTE = '/dsh-reminder-notify/balance'
23
23
  // 0.11 新增:提醒历史(GET 拿统计+最近记录,POST { mode: 'clear' } 清空)。
24
24
  const HISTORY_ROUTE = '/dsh-reminder-notify/history'
25
+ const DIGEST_ROUTE = '/dsh-reminder-notify/digest'
25
26
  // 下拉按扩展名分组:wav 一组、mp3 一组……组内按文件名排序,一眼能看出格式。
26
27
  function groupAudioFiles(files) {
27
28
  const byExt = new Map()
@@ -250,6 +251,7 @@ window.__ModuleLoader__.load({
250
251
  Object.assign(zh, {
251
252
  groupQueue: '排队与免打扰',
252
253
  groupHistory: '历史与统计',
254
+ groupDigest: '日报与推送',
253
255
  speakEnabled: '朗读提醒内容',
254
256
  buttonsEnabled: '卡片显示按钮',
255
257
  snoozeMinutes: '「稍后提醒」延后分钟',
@@ -262,9 +264,23 @@ window.__ModuleLoader__.load({
262
264
  quietMode: '免打扰处理方式',
263
265
  quietModeHold: '留到结束后补弹',
264
266
  quietModeSkip: '直接跳过',
267
+ pushFormatWecom: '企业微信机器人',
268
+ pushFormatServerchan: 'Server 酱',
269
+ pushFormatJson: '通用 JSON',
270
+ pushFormatText: '纯文本',
265
271
  compactOnFullscreen: '全屏时用紧凑卡片',
266
272
  historyEnabled: '记录提醒历史',
267
273
  historyLimit: '历史保留条数',
274
+ digestEnabled: '每日提醒日报',
275
+ digestTime: '日报时间',
276
+ digestTitle: '日报标题',
277
+ digestIncludeBalance: '日报带上余额',
278
+ digestAlertCount: '当天条数预警',
279
+ pushEnabled: '推送到手机',
280
+ pushUrl: '推送地址',
281
+ pushFormat: '推送格式',
282
+ pushDecide: '「需要你来决定」也推送',
283
+ pushDigest: '日报也推送',
268
284
  speakEnabledHint: '用系统语音把标题和正文念出来;要装中文语音包,没装就静音。',
269
285
  buttonsEnabledHint: '卡片右下角给出「知道了」和「稍后提醒」;关掉就只剩自动关闭,点卡片仍可提前关。',
270
286
  snoozeMinutesHint: '点「稍后提醒」后隔多久再弹一次。',
@@ -278,6 +294,22 @@ window.__ModuleLoader__.load({
278
294
  compactOnFullscreenHint: '检测到前台是全屏应用时改用窄卡片,少挡内容。',
279
295
  historyEnabledHint: '每条提醒的结果都会记下来(自动关闭 / 点了按钮 / 稍后提醒 / 免打扰跳过)。',
280
296
  historyLimitHint: '超过这个条数就丢掉最旧的记录。',
297
+ digestEnabledHint: '每天到点弹一条「今天弹了几条、你点掉了几条」的日报。',
298
+ digestTimeHint: 'HH:MM 24 小时制,一天只发一条;关机错过了不补。',
299
+ digestTitleHint: '日报卡片的标题,例如「今日提醒日报」。',
300
+ digestIncludeBalanceHint: '日报末尾附上当前 DeepSeek 余额。',
301
+ digestAlertCountHint: '当天提醒超过这个条数时,额外弹一张「提醒有点多」的预警卡;0 = 关闭。',
302
+ pushUrlHint: '企业微信机器人或 Server 酱的 webhook 地址,只需要填 URL 本身。',
303
+ pushFormatHint: 'wecom = 企业微信机器人;serverchan = Server 酱;json = 通用 JSON;text = 纯文本。',
304
+ pushDecideHint: '需要你拍板的提醒也发到手机,人不在电脑前也能收到。',
305
+ pushDigestHint: '日报也发到手机。',
306
+ digestStatus: '日报预览',
307
+ digestRefresh: '刷新预览',
308
+ digestSend: '现在发一条',
309
+ digestSending: '发送中…',
310
+ digestLoading: '正在读取…',
311
+ digestUnavailable: '日报接口不可用',
312
+ digestDisabled: '日报未开启(开启后每天到点自动发)',
281
313
  historyStatus: '提醒统计',
282
314
  historyLoading: '读取中…',
283
315
  historyUnavailable: '读不到历史文件:',
@@ -302,6 +334,7 @@ window.__ModuleLoader__.load({
302
334
  Object.assign(en, {
303
335
  groupQueue: 'Queue & quiet hours',
304
336
  groupHistory: 'History & stats',
337
+ groupDigest: 'Digest & push',
305
338
  speakEnabled: 'Speak the reminder',
306
339
  buttonsEnabled: 'Show card buttons',
307
340
  snoozeMinutes: 'Snooze minutes',
@@ -314,9 +347,23 @@ window.__ModuleLoader__.load({
314
347
  quietMode: 'Quiet-hours behaviour',
315
348
  quietModeHold: 'Hold until it ends',
316
349
  quietModeSkip: 'Skip it',
350
+ pushFormatWecom: 'WeCom bot',
351
+ pushFormatServerchan: 'ServerChan',
352
+ pushFormatJson: 'Generic JSON',
353
+ pushFormatText: 'Plain text',
317
354
  compactOnFullscreen: 'Compact card on fullscreen',
318
355
  historyEnabled: 'Keep reminder history',
319
356
  historyLimit: 'History entries kept',
357
+ digestEnabled: 'Daily digest',
358
+ digestTime: 'Digest time',
359
+ digestTitle: 'Digest title',
360
+ digestIncludeBalance: 'Include balance',
361
+ digestAlertCount: 'Daily alert threshold',
362
+ pushEnabled: 'Push to phone',
363
+ pushUrl: 'Push URL',
364
+ pushFormat: 'Push format',
365
+ pushDecide: 'Push decisions too',
366
+ pushDigest: 'Push the digest too',
320
367
  speakEnabledHint: 'Read the title and body with the system voice; needs a Chinese voice pack, otherwise silent.',
321
368
  buttonsEnabledHint: 'Show “Got it” and “Snooze” on the card. Off means auto-dismiss only; clicking the card still closes it.',
322
369
  snoozeMinutesHint: 'How long to wait before the snoozed reminder pops again.',
@@ -330,6 +377,22 @@ window.__ModuleLoader__.load({
330
377
  compactOnFullscreenHint: 'Use a narrower card when a fullscreen app is in front.',
331
378
  historyEnabledHint: 'Every reminder result is recorded (auto-close / button / snooze / quiet-skip).',
332
379
  historyLimitHint: 'Older entries are dropped past this count.',
380
+ digestEnabledHint: 'Pops one daily card with how many reminders fired and how you handled them.',
381
+ digestTimeHint: 'HH:MM, 24-hour. One digest per day; a missed day is not replayed.',
382
+ digestTitleHint: 'Title of the digest card.',
383
+ digestIncludeBalanceHint: 'Append the current DeepSeek balance to the digest.',
384
+ digestAlertCountHint: 'When today passes this many reminders, pop one extra "a lot of reminders" card; 0 = off.',
385
+ pushUrlHint: 'A WeCom bot or ServerChan webhook URL. Only the URL is needed.',
386
+ pushFormatHint: 'wecom = WeCom bot; serverchan = ServerChan; json = generic JSON; text = plain text.',
387
+ pushDecideHint: 'Also push "needs your decision" reminders, so you get them away from the PC.',
388
+ pushDigestHint: 'Also push the daily digest.',
389
+ digestStatus: 'Digest preview',
390
+ digestRefresh: 'Refresh preview',
391
+ digestSend: 'Send one now',
392
+ digestSending: 'Sending…',
393
+ digestLoading: 'Loading…',
394
+ digestUnavailable: 'Digest endpoint unavailable',
395
+ digestDisabled: 'Digest is off (turn it on to send daily)',
333
396
  historyStatus: 'Reminder stats',
334
397
  historyLoading: 'Reading…',
335
398
  historyUnavailable: 'Cannot read the history file: ',
@@ -426,6 +489,17 @@ window.__ModuleLoader__.load({
426
489
  { key: 'compactOnFullscreen', group: 'queue', kind: 'boolean' },
427
490
  { key: 'historyEnabled', group: 'history', kind: 'boolean' },
428
491
  { key: 'historyLimit', group: 'history', kind: 'number' },
492
+ // 0.12:日报与手机推送。
493
+ { key: 'digestEnabled', group: 'digest', kind: 'boolean' },
494
+ { key: 'digestTime', group: 'digest', kind: 'text' },
495
+ { key: 'digestTitle', group: 'digest', kind: 'text' },
496
+ { key: 'digestIncludeBalance', group: 'digest', kind: 'boolean' },
497
+ { key: 'digestAlertCount', group: 'digest', kind: 'number' },
498
+ { key: 'pushEnabled', group: 'digest', kind: 'boolean' },
499
+ { key: 'pushUrl', group: 'digest', kind: 'text' },
500
+ { key: 'pushFormat', group: 'digest', kind: 'select', options: ['wecom', 'serverchan', 'json', 'text'], optionLabels: ['pushFormatWecom', 'pushFormatServerchan', 'pushFormatJson', 'pushFormatText'] },
501
+ { key: 'pushDecide', group: 'digest', kind: 'boolean' },
502
+ { key: 'pushDigest', group: 'digest', kind: 'boolean' },
429
503
  { key: 'hostMode', group: 'host', kind: 'select', options: ['script', 'exe'], optionLabels: ['hostModeScript', 'hostModeExe'] },
430
504
  { key: 'scriptPath', group: 'host', kind: 'text' },
431
505
  { key: 'powershellPath', group: 'host', kind: 'text' },
@@ -472,10 +546,20 @@ window.__ModuleLoader__.load({
472
546
  compactOnFullscreen: 'compactOnFullscreenHint',
473
547
  historyEnabled: 'historyEnabledHint',
474
548
  historyLimit: 'historyLimitHint',
549
+ digestEnabled: 'digestEnabledHint',
550
+ digestTime: 'digestTimeHint',
551
+ digestTitle: 'digestTitleHint',
552
+ digestIncludeBalance: 'digestIncludeBalanceHint',
553
+ digestAlertCount: 'digestAlertCountHint',
554
+ pushEnabled: 'pushUrlHint',
555
+ pushUrl: 'pushUrlHint',
556
+ pushFormat: 'pushFormatHint',
557
+ pushDecide: 'pushDecideHint',
558
+ pushDigest: 'pushDigestHint',
475
559
  }
476
560
 
477
- const GROUPS = ['basic', 'audio', 'look', 'queue', 'history', 'balance', 'host']
478
- const GROUP_LABELS = { basic: 'groupBasic', audio: 'groupAudio', look: 'groupLook', queue: 'groupQueue', history: 'groupHistory', balance: 'groupBalance', host: 'groupHost' }
561
+ const GROUPS = ['basic', 'audio', 'look', 'queue', 'history', 'digest', 'balance', 'host']
562
+ const GROUP_LABELS = { basic: 'groupBasic', audio: 'groupAudio', look: 'groupLook', queue: 'groupQueue', history: 'groupHistory', digest: 'groupDigest', balance: 'groupBalance', host: 'groupHost' }
479
563
 
480
564
  function sameValue(a, b) {
481
565
  return JSON.stringify(a) === JSON.stringify(b)
@@ -499,6 +583,8 @@ window.__ModuleLoader__.load({
499
583
  const [balanceBusy, setBalanceBusy] = React.useState(false)
500
584
  const [history, setHistory] = React.useState(null)
501
585
  const [historyBusy, setHistoryBusy] = React.useState(false)
586
+ const [digest, setDigest] = React.useState(null)
587
+ const [digestBusy, setDigestBusy] = React.useState(false)
502
588
 
503
589
  React.useEffect(() => {
504
590
  if (typeof fetch !== 'function') {
@@ -559,6 +645,7 @@ window.__ModuleLoader__.load({
559
645
  React.useEffect(() => {
560
646
  refreshBalance()
561
647
  refreshHistory()
648
+ refreshDigest()
562
649
  }, [])
563
650
 
564
651
  if (props.view === 'summary') {
@@ -792,6 +879,44 @@ window.__ModuleLoader__.load({
792
879
  })
793
880
  }
794
881
 
882
+ function digestFetch(options) {
883
+ setDigestBusy(true)
884
+ Promise.resolve()
885
+ .then(() => fetch(DIGEST_ROUTE, options))
886
+ .then((response) => (response && typeof response.json === 'function' ? response.json() : Promise.resolve(null)))
887
+ .then((data) => {
888
+ setDigestBusy(false)
889
+ if (data && typeof data === 'object') setDigest(data)
890
+ else setDigest({ ok: false, error: 'empty-response' })
891
+ })
892
+ .catch((error) => {
893
+ setDigestBusy(false)
894
+ setDigest({ ok: false, error: String((error && error.message) || error) })
895
+ })
896
+ }
897
+
898
+ function refreshDigest() {
899
+ digestFetch({ headers: { accept: 'application/json' } })
900
+ }
901
+
902
+ function sendDigest() {
903
+ digestFetch({
904
+ method: 'POST',
905
+ headers: { 'content-type': 'application/json', accept: 'application/json' },
906
+ body: JSON.stringify({ mode: 'send' }),
907
+ })
908
+ }
909
+
910
+ function digestText() {
911
+ const label = typeof t === 'function' ? t : (key) => key
912
+ if (digest === null) return label('digestLoading')
913
+ if (digest.ok === false) {
914
+ return label('digestUnavailable') + (digest.error ? '(' + String(digest.error) + ')' : '')
915
+ }
916
+ if (digest.enabled === false) return label('digestDisabled')
917
+ return String(digest.message || '').split('\n').join(' / ')
918
+ }
919
+
795
920
  function refreshHistory() {
796
921
  historyFetch({ headers: { accept: 'application/json' } })
797
922
  }
@@ -980,6 +1105,35 @@ window.__ModuleLoader__.load({
980
1105
  )
981
1106
  }
982
1107
  }
1108
+ if (group === 'digest') {
1109
+ const label = typeof t === 'function' ? t : (key) => key
1110
+ rows.push(
1111
+ h(
1112
+ 'div',
1113
+ { className: 'drn-row', key: 'digest-status' },
1114
+ h(
1115
+ 'div',
1116
+ { className: 'drn-row-main' },
1117
+ h('div', { className: 'drn-label' }, label('digestStatus')),
1118
+ h('div', { className: 'drn-hint' }, digestText()),
1119
+ ),
1120
+ h(
1121
+ 'div',
1122
+ { className: 'drn-pick' },
1123
+ h(
1124
+ 'button',
1125
+ { type: 'button', className: 'drn-btn small', disabled: digestBusy, onClick: refreshDigest },
1126
+ label('digestRefresh'),
1127
+ ),
1128
+ h(
1129
+ 'button',
1130
+ { type: 'button', className: 'drn-btn small', disabled: digestBusy, onClick: sendDigest },
1131
+ label(digestBusy ? 'digestSending' : 'digestSend'),
1132
+ ),
1133
+ ),
1134
+ ),
1135
+ )
1136
+ }
983
1137
  if (group === 'balance') {
984
1138
  rows.push(
985
1139
  h(
package/cordis.patch.yml CHANGED
@@ -72,3 +72,25 @@
72
72
  historyLimit: 200
73
73
  # 历史文件路径;留空 = ~/.dsh/dsh-reminder-notify/history.json
74
74
  historyFile: ''
75
+ # 每天在固定时间弹一条「今日提醒日报」
76
+ digestEnabled: false
77
+ # 日报时间,HH:MM(过点后的第一次检查才会发,一天只发一条)
78
+ digestTime: '09:00'
79
+ digestTitle: 今日提醒日报
80
+ # 日报里带上当前 DeepSeek 余额
81
+ digestIncludeBalance: true
82
+ # 当天提醒超过这个条数就额外弹一张预警卡(0 = 关)
83
+ digestAlertCount: 0
84
+ # 内部状态:上次发日报 / 弹预警的日期
85
+ digestLastDate: ''
86
+ digestAlertDate: ''
87
+ # 把提醒同时推到手机(企业微信机器人 / Server 酱 / 自定义 webhook)
88
+ pushEnabled: false
89
+ # 推送地址
90
+ pushUrl: ''
91
+ # wecom = 企业微信机器人;serverchan = Server 酱;json = 通用 JSON;text = 纯文本
92
+ pushFormat: wecom
93
+ # 「需要你来决定」档位也推到手机
94
+ pushDecide: true
95
+ # 日报同时推到手机
96
+ pushDigest: true
package/docs/PUBLISH.md CHANGED
@@ -12,7 +12,7 @@ DSH 的「插件市场 → 发现」页读的是**索引 URL**:一份 JSON(
12
12
  | 索引地址(他人添加这个) | `https://jiangshuaiye1203.github.io/dsh-reminder-notify/publish/index.json` |
13
13
  | 站点首页 | https://jiangshuaiye1203.github.io/dsh-reminder-notify/ |
14
14
  | npm 包 | https://www.npmjs.com/package/dsh-reminder-notify |
15
- | 当前版本 | **0.10.2**,装源为 **npm**(`dsh-reminder-notify@0.10.2`),不再是 git 固定提交 |
15
+ | 当前版本 | **0.11.0**,装源为 **npm**(`dsh-reminder-notify@0.11.0`),不再是 git 固定提交 |
16
16
  | Pages | Deploy from a branch,`main` / `(root)` |
17
17
 
18
18
  发新版(npm 源):改代码 → 升 `package.json` 版本 → `scripts\publish-npm.cmd` 发布到 npm →
package/docs/detail.en.md CHANGED
@@ -6,19 +6,31 @@ The card host is the bundled `host/ReminderHost.ps1`, drawn with the system Powe
6
6
 
7
7
  ## Settings
8
8
 
9
- Open "Desktop reminder" in the Plugins page; the panel sits right under the description and has seven groups:
9
+ Open "Desktop reminder" in the Plugins page; the panel sits right under the description and has eight groups:
10
10
 
11
11
  - **Basics**: duration, position, sound on/off
12
12
  - **Sounds**: audio directory ("Browse…" picks a directory), the three per-kind file names (wav / mp3). Once a directory is picked the dropdown lists the audio files in it.
13
13
  - **Look**: background image, title icon, accent colours, title/message templates (`{title}` `{message}` `{kind}` `{time}`), plus per-kind overrides for background, icon and templates
14
14
  - **Queue & quiet hours**: spoken alerts, card buttons, snooze minutes, queue on/off and limit, merge window, quiet hours and their behaviour, compact card on fullscreen
15
15
  - **History & stats**: record or not, entries kept, plus the total/today counts and the last 8 entries with "Refresh" and "Clear"
16
+ - **Digest & push**: daily digest (switch, time, title, include balance, alert threshold) and phone push (switch, URL, format, whether decisions and the digest are pushed); the panel previews today's digest text and can send one right now
16
17
  - **Host**: script or exe host, script path, PowerShell path
17
18
 
18
19
  Changes apply on "Save" — no restart needed.
19
20
 
20
21
  - **DeepSeek balance**: enable, thresholds (20/10/5 % by default), check interval, spoken alerts; the panel can check now and set the current balance as the baseline
21
22
 
23
+ ## Digest and phone push (0.12+)
24
+
25
+ - **Daily digest**: with `digestEnabled` on, one card goes out after `digestTime` (default 09:00): how many reminders
26
+ fired today, per kind, how they were handled, plus the current balance if `digestIncludeBalance` is on.
27
+ `digestLastDate` keeps it to one per day; a missed day is not replayed.
28
+ - **Volume alert**: with `digestAlertCount` above 0, one extra "a lot of reminders" card fires the first time today
29
+ passes the threshold (`digestAlertDate` keeps it to once a day).
30
+ - **Phone push**: `pushEnabled` + `pushUrl` + `pushFormat` — `wecom` (WeCom bot), `serverchan` (ServerChan),
31
+ `json` (generic webhook), `text` (plain text). `pushDecide` and `pushDigest` decide whether decisions and the
32
+ digest are pushed. Delivery is fire-and-forget: 8s timeout, failures only show up in the return value.
33
+
22
34
  ## Card behaviour (0.11+)
23
35
 
24
36
  - **Queue**: one card at a time; later reminders wait in a queue (`queueEnabled` / `queueMax`) instead of stacking.
@@ -42,6 +54,22 @@ Baseline rules (0.10.1):
42
54
  - no alert for **30 minutes after a top-up**, and an alert needs **two consecutive readings** below the threshold, which filters out top-up reversals and similar jitter;
43
55
  - when the balance cannot be read (signed out, service error) the last snapshot is kept and marked stale instead of being treated as ¥0.
44
56
 
57
+ ## What was verified on a real machine (0.11.1 note)
58
+
59
+ Verified on Windows 11 · PowerShell 5.1 · 3440×1440 at 125%:
60
+
61
+ - **Queueing**: a second call while a card is open returns `queued:true, position_in_queue:1`, and it moves up once the first card closes.
62
+ - **Merging**: the same kind inside the merge window returns `merged:true, count:2` with one joined body.
63
+ - **Card buttons**: clicking "Got it" closes with `action:"ok"` and shows up in history (`elapsedMs:22413` on the real click).
64
+ - **Snooze**: when a host returns `{"action":"snooze","snooze":N}` the first record is `snoozed:false`, then the card returns N minutes later and records `snoozed:true`. Checked with a stub host that answers `snooze` immediately (`scriptPath` pointed at it) — same code path a real click takes.
65
+ - **Quiet hours**: `raw` inside the window returns `quiet:true`; `skip` returns `skipped:"quiet"` and shows nothing; `hold` re-fires exactly when the window ends (22:30–22:38 window, card appeared 22:38:00, history `quiet:true`); `decide` stays `quiet:false` and is never swallowed.
66
+ - **History**: `/dsh-reminder-notify/history` and the panel counters stay in sync, and `byAction` separates `timeout / ok / snooze / dismiss / quiet-skip`.
67
+
68
+ Not verifiable from code:
69
+
70
+ - Synthetic clicks cannot reach the card: it is a `WS_EX_NOACTIVATE` window, so `mouse_event` and `PostMessage(WM_LBUTTONDOWN)` never arrive (no `MouseDown` at all). Buttons need a human click; the hit-test maths is covered by unit tests.
71
+ - Whether speech is actually audible: logs prove `-Speak` reaches the host and `Microsoft Huihui Desktop (zh-CN)` is installed, but nothing can confirm the speaker played it.
72
+
45
73
  ## Known limits
46
74
 
47
75
  - Windows only (`os: ["win32"]`): the card host is WinForms.
package/docs/detail.zh.md CHANGED
@@ -6,18 +6,32 @@
6
6
 
7
7
  ## 设置
8
8
 
9
- 在「插件」页打开「桌面提醒」,描述下方就是设置面板,分七组:
9
+ 在「插件」页打开「桌面提醒」,描述下方就是设置面板,分八组:
10
10
 
11
11
  - **基本**:停留秒数、弹窗位置、是否播放提示音
12
12
  - **提示音**:提示音目录(可点「浏览…」选目录)、三档提示音文件名(wav / mp3),选了目录后下拉框会列出目录里的音频
13
13
  - **外观**:背景图、标题图标、强调色、标题/正文模板(`{title}` `{message}` `{kind}` `{time}`),以及每档位单独覆盖的背景 / 图标 / 模板
14
14
  - **排队与免打扰**:语音朗读、卡片按钮、「稍后提醒」分钟数、排队开关与上限、合并窗口、免打扰时段与处理方式、全屏时用紧凑卡片
15
15
  - **历史与统计**:是否记录、保留条数,面板里直接显示总条数 / 今日条数与最近 8 条记录,可「刷新」和「清空」
16
+ - **日报与推送**:每日日报(开关、时间、标题、是否带余额、条数预警阈值)、手机推送(开关、地址、格式、「需要你来决定」与日报是否也推);面板里能预览今天的日报全文,也能「现在发一条」
16
17
  - **DeepSeek 余额**:开关、阈值(默认 20,10,5 %)、检查间隔、是否语音播报;面板里能「立即查询」,也能把当前余额设为基线
17
18
  - **宿主**:脚本模式或 exe 模式、脚本路径、PowerShell 路径
18
19
 
19
20
  改完点「保存」,立刻生效,不用重启。
20
21
 
22
+ ## 日报与手机推送(0.12 起)
23
+
24
+ - **每日日报**:`digestEnabled` 打开后,每天在 `digestTime`(默认 09:00)之后的第一次检查里发一条,
25
+ 内容 = 今天的条数、各档位数量、处理方式统计(自动关闭 / 知道了 / 稍后提醒 / 点掉了 / 免打扰跳过),
26
+ 末尾可选附当前余额。用 `digestLastDate` 记住今天已发过,所以一天只发一条,关机错过不补。
27
+ - **条数预警**:`digestAlertCount`(默认 0 = 关)大于 0 时,当天条数一旦超过阈值就额外弹一张
28
+ 「提醒有点多」,一天只弹一次(`digestAlertDate`)。
29
+ - **手机推送**:`pushEnabled` + `pushUrl` + `pushFormat` ——
30
+ `wecom`(企业微信群机器人,`{"msgtype":"text",...}`)、`serverchan`(Server 酱,`{"title","desp"}`)、
31
+ `json`(`{"title","message","kind","time"}`)、`text`(`标题\n正文` 纯文本)。
32
+ `pushDecide` 控制「需要你来决定」是否推送,`pushDigest` 控制日报是否推送。
33
+ 推送是 fire-and-forget:超时 8 秒、失败只记在返回值里,不影响卡片,也不阻塞 `notify_user`。
34
+
21
35
  ## 提醒的行为(0.11 起)
22
36
 
23
37
  - **排队**:一次只显示一张卡,后来的进队列(`queueEnabled` / `queueMax`),不再一叠好几张。
@@ -44,6 +58,22 @@
44
58
  - 刚充值/刚抬升基线的 **30 分钟内不播报**,并且要**连续两次查到低于阈值**才响,避免充值入账被冲正之类的抖动误报;
45
59
  - 查不到余额(未登录、接口失败)时保留上次结果,只显示过期提示,不会当成 0 元去喊。
46
60
 
61
+ ## 各项功能的验证范围(0.11.1 记录)
62
+
63
+ 真机(Windows 11 · PowerShell 5.1 · 屏幕 3440×1440 DPI 125%)跑过的:
64
+
65
+ - **排队**:第一张卡没关时再调 `notify_user`,返回 `queued:true`、`position_in_queue:1`,卡片关掉后第二张自动顶上。
66
+ - **合并**:同档位在合并窗口内再次触发,返回 `merged:true`、`count:2`,正文并成一条。
67
+ - **卡片按钮**:点「知道了」会以 `action:"ok"` 关闭并记进历史(真机点过一次,`elapsedMs:22413`)。
68
+ - **稍后提醒**:宿主回 `{"action":"snooze","snooze":N}` 之后,历史里第一次记 `snoozed:false`,N 分钟后再弹一次并记 `snoozed:true`。这条是用一个“立即返回 snooze”的假宿主脚本(`scriptPath` 指过去)验的,链路与真机点按钮走的是同一段代码。
69
+ - **免打扰**:窗口内 `raw` 返回 `quiet:true`;`skip` 返回 `skipped:"quiet"` 且不弹;`hold` 会在窗口结束的那一刻补弹(实测 22:30–22:38 的窗口,卡片在 22:38:00 出现,历史 `quiet:true`);同一时段 `decide` 档 `quiet:false`,照常弹。
70
+ - **历史与统计**:`/dsh-reminder-notify/history` 与面板的「共 N 条 · 今天 M 条」随每次关闭同步,`byAction` 能分开统计 `timeout / ok / snooze / dismiss / quiet-skip`。
71
+
72
+ 没能自动验证的:
73
+
74
+ - **合成点击点不到卡片**:卡片是 `WS_EX_NOACTIVATE` 的无焦点窗口,`mouse_event`、`PostMessage(WM_LBUTTONDOWN)` 都收不到(连 `MouseDown` 日志都没有),所以按钮只能由人手点。宿主自己的命中判定逻辑有单测覆盖。
75
+ - **语音是否真的出声**:日志能确认 `-Speak` 传到了宿主、系统里也装了 `Microsoft Huihui Desktop (zh-CN)`,但没法从代码里确认扬声器里确实念了。
76
+
47
77
  ## 已知限制
48
78
 
49
79
  - 仅 Windows(`os: ["win32"]`):卡片宿主是 WinForms。
package/index.js CHANGED
@@ -89,6 +89,18 @@ export const Config = z === null ? undefined : z.object({
89
89
  historyEnabled: z.boolean().default(true).description('记录提醒历史(本地 JSON),供插件页看统计').volatile(),
90
90
  historyLimit: z.number().min(20).max(2000).step(10).default(200).description('历史最多保留多少条(20–2000)').volatile(),
91
91
  historyFile: z.string().default('').description('历史文件路径,留空 = <用户目录>\\.dsh\\dsh-reminder-notify\\history.json').volatile(),
92
+ digestEnabled: z.boolean().default(false).description('每天在固定时间弹一条「今日提醒日报」').volatile(),
93
+ digestTime: z.string().default('09:00').description('日报时间,HH:MM(每天只在过点后的第一次检查里发一条)').volatile(),
94
+ digestTitle: z.string().default('今日提醒日报').description('日报卡片标题').volatile(),
95
+ digestIncludeBalance: z.boolean().default(true).description('日报里带上当前 DeepSeek 余额').volatile(),
96
+ digestAlertCount: z.number().min(0).max(500).step(5).default(0).description('当天提醒超过这个条数时额外弹一张预警卡(0 = 关)').volatile(),
97
+ digestLastDate: z.string().default('').description('内部状态:上次发日报的日期').volatile(),
98
+ digestAlertDate: z.string().default('').description('内部状态:上次弹条数预警的日期').volatile(),
99
+ pushEnabled: z.boolean().default(false).description('把提醒同时推到手机(企业微信机器人 / Server酱 / 自定义 webhook)').volatile(),
100
+ pushUrl: z.string().default('').description('推送地址,例如 https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=…').volatile(),
101
+ pushFormat: z.union(['wecom', 'serverchan', 'json', 'text']).default('wecom').description('推送格式:wecom 企业微信机器人、serverchan Server酱、json 通用 JSON、text 纯文本').volatile(),
102
+ pushDecide: z.boolean().default(true).description('「需要你来决定」档位也推到手机').volatile(),
103
+ pushDigest: z.boolean().default(true).description('日报同时推到手机').volatile(),
92
104
  dryRun: z.boolean().default(false).description('调试用:只试算参数、不真的弹窗(自检脚本会打开它)').volatile(),
93
105
  })
94
106
 
@@ -217,6 +229,18 @@ function settingsOf(config) {
217
229
  historyEnabled: c.historyEnabled !== false,
218
230
  historyLimit: Math.round(clamp(num(c.historyLimit, 200), 20, 2000)),
219
231
  historyFile: str(c.historyFile, ''),
232
+ digestEnabled: c.digestEnabled === true,
233
+ digestTime: str(c.digestTime, '09:00'),
234
+ digestTitle: str(c.digestTitle, '今日提醒日报'),
235
+ digestIncludeBalance: c.digestIncludeBalance !== false,
236
+ digestAlertCount: Math.round(clamp(num(c.digestAlertCount, 0), 0, 500)),
237
+ digestLastDate: str(c.digestLastDate, ''),
238
+ digestAlertDate: str(c.digestAlertDate, ''),
239
+ pushEnabled: c.pushEnabled === true,
240
+ pushUrl: typeof c.pushUrl === 'string' ? c.pushUrl.trim() : '',
241
+ pushFormat: ['wecom', 'serverchan', 'json', 'text'].includes(c.pushFormat) ? c.pushFormat : 'wecom',
242
+ pushDecide: c.pushDecide !== false,
243
+ pushDigest: c.pushDigest !== false,
220
244
  dryRun: c.dryRun === true,
221
245
  }
222
246
  }
@@ -720,7 +744,7 @@ const parameters = {
720
744
  },
721
745
  }
722
746
 
723
- function toolDefinition(getSettings) {
747
+ function toolDefinition(getSettings, ctx) {
724
748
  return {
725
749
  name: 'notify_user',
726
750
  description:
@@ -747,6 +771,10 @@ function toolDefinition(getSettings) {
747
771
  }
748
772
  const result = await notify(kind, args && typeof args === 'object' ? args : {}, settings)
749
773
  if (result.ok) lastFiredAt.set(kind, now)
774
+ // 手机推送是「顺带」而不是主路径:失败不影响本次工具调用,也不等它。
775
+ if (result.ok && kind === 'decide' && settings.pushEnabled && settings.pushDecide && settings.dryRun !== true) {
776
+ pushOut(settings, str(result.title, '需要你来决定'), str(result.message, ''), { kind }).catch(() => {})
777
+ }
750
778
  return JSON.stringify(result)
751
779
  },
752
780
  }
@@ -758,6 +786,7 @@ const CONFIG_ROUTE = '/dsh-reminder-notify/config'
758
786
  const PREVIEW_ROUTE = '/dsh-reminder-notify/preview'
759
787
  const BALANCE_ROUTE = '/dsh-reminder-notify/balance'
760
788
  const HISTORY_ROUTE = '/dsh-reminder-notify/history'
789
+ const DIGEST_ROUTE = '/dsh-reminder-notify/digest'
761
790
 
762
791
  // 面板要「把音频目录里的文件列成下拉」,但 Client 侧没有任何读文件能力,
763
792
  // 所以由 Host 注册一条只读的 GET 路由,页面用同源 fetch 取这个 JSON。
@@ -1282,6 +1311,199 @@ export function historyStats(entries) {
1282
1311
  }
1283
1312
  }
1284
1313
 
1314
+ // ——— 日报与手机推送 ——————————————————————————————————————————————
1315
+ //
1316
+ // 手机推送没有可用的宿主服务(服务目录里没有 im / chat / notification),
1317
+ // 所以就按「用户自己提供一个 webhook」来做:企业微信群机器人、Server 酱、
1318
+ // 通用 JSON、纯文本四种格式,都是 POST 一个 URL,不需要账号体系。
1319
+ function dayKeyOf(ms) {
1320
+ const d = new Date(ms)
1321
+ return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`
1322
+ }
1323
+
1324
+ export function todayKey(now = new Date()) {
1325
+ return dayKeyOf(now.getTime())
1326
+ }
1327
+
1328
+ export function digestDue(settings, now = new Date()) {
1329
+ if (settings.digestEnabled !== true) return false
1330
+ const at = parseClock(settings.digestTime)
1331
+ if (at === null) return false
1332
+ if (settings.digestLastDate === todayKey(now)) return false
1333
+ return now.getHours() * 60 + now.getMinutes() >= at
1334
+ }
1335
+
1336
+ export function digestMessage(settings, entries, balance) {
1337
+ const today = todayKey()
1338
+ const rows = (Array.isArray(entries) ? entries : []).filter((e) => dayKeyOf(num(e?.at, 0)) === today)
1339
+ const byKind = (k) => rows.filter((e) => e.kind === k).length
1340
+ const byAction = (a) => rows.filter((e) => e.action === a).length
1341
+ const lines = []
1342
+ if (rows.length === 0) {
1343
+ lines.push('今天还没有弹过提醒。')
1344
+ } else {
1345
+ lines.push(`今天共 ${rows.length} 条提醒:完成 ${byKind('done')}、需要你决定 ${byKind('decide')}、普通 ${byKind('raw')}。`)
1346
+ const how = []
1347
+ if (byAction('timeout') > 0) how.push(`自动关闭 ${byAction('timeout')}`)
1348
+ if (byAction('ok') > 0) how.push(`点知道了 ${byAction('ok')}`)
1349
+ if (byAction('snooze') > 0) how.push(`稍后提醒 ${byAction('snooze')}`)
1350
+ if (byAction('dismiss') > 0) how.push(`点掉了 ${byAction('dismiss')}`)
1351
+ if (byAction('quiet-skip') > 0) how.push(`免打扰跳过 ${byAction('quiet-skip')}`)
1352
+ if (how.length > 0) lines.push(`处理方式:${how.join('、')}。`)
1353
+ }
1354
+ const value = num(balance?.balance, NaN)
1355
+ if (Number.isFinite(value)) {
1356
+ const base = num(settings.balanceBaseline, 0)
1357
+ lines.push(base > 0 ? `DeepSeek 余额 ¥${value.toFixed(2)}(基线 ¥${base.toFixed(2)})` : `DeepSeek 余额 ¥${value.toFixed(2)}`)
1358
+ }
1359
+ return lines.join('\n')
1360
+ }
1361
+
1362
+ export function pushPayload(settings, title, message, extra = {}) {
1363
+ const body = String(message ?? '')
1364
+ const json = { 'content-type': 'application/json' }
1365
+ if (settings.pushFormat === 'serverchan') {
1366
+ return { headers: json, body: JSON.stringify({ title, desp: body }) }
1367
+ }
1368
+ if (settings.pushFormat === 'text') {
1369
+ return { headers: { 'content-type': 'text/plain; charset=utf-8' }, body: `${title}\n${body}` }
1370
+ }
1371
+ if (settings.pushFormat === 'wecom') {
1372
+ return { headers: json, body: JSON.stringify({ msgtype: 'text', text: { content: `${title}\n${body}` } }) }
1373
+ }
1374
+ return { headers: json, body: JSON.stringify({ title, message: body, kind: extra.kind ?? 'raw', time: new Date().toISOString() }) }
1375
+ }
1376
+
1377
+ export async function pushOut(settings, title, message, extra = {}) {
1378
+ if (settings.pushEnabled !== true) return { ok: false, error: 'push-disabled' }
1379
+ const url = str(settings.pushUrl, '')
1380
+ if (!/^https?:\/\//i.test(url)) return { ok: false, error: 'push-url-invalid' }
1381
+ const payload = pushPayload(settings, title, message, extra)
1382
+ try {
1383
+ const response = await fetch(url, {
1384
+ method: 'POST',
1385
+ headers: payload.headers,
1386
+ body: payload.body,
1387
+ signal: typeof AbortSignal?.timeout === 'function' ? AbortSignal.timeout(8000) : undefined,
1388
+ })
1389
+ const text = await response.text().catch(() => '')
1390
+ return { ok: response.ok, status: response.status, body: text.slice(0, 200) }
1391
+ } catch (error) {
1392
+ return { ok: false, error: String(error?.message ?? error) }
1393
+ }
1394
+ }
1395
+
1396
+ export async function runDigest(ctx, getSettings, { force = false } = {}) {
1397
+ const settings = getSettings()
1398
+ if (!force && settings.digestEnabled !== true) return { ok: false, error: 'digest-disabled' }
1399
+ const entries = readHistory(settings)
1400
+ let balance = null
1401
+ if (settings.digestIncludeBalance) {
1402
+ const read = await readAccountBalance(ctx).catch(() => null)
1403
+ if (read && read.balance !== undefined) balance = read
1404
+ }
1405
+ const title = str(settings.digestTitle, '今日提醒日报')
1406
+ const message = digestMessage(settings, entries, balance)
1407
+ const card = await notify('raw', { title, message, seconds: Math.max(20, settings.seconds) }, settings)
1408
+ let push = null
1409
+ if (settings.pushEnabled && settings.pushDigest && settings.dryRun !== true) {
1410
+ push = await pushOut(settings, title, message, { kind: 'digest' })
1411
+ }
1412
+ if (!force) await saveBalanceState(ctx, { digestLastDate: todayKey() })
1413
+ return { ok: true, title, message, card, push }
1414
+ }
1415
+
1416
+ function registerDigestLoop(ctx, getSettings) {
1417
+ let running = false
1418
+ const tick = async () => {
1419
+ if (running) return
1420
+ const settings = getSettings()
1421
+ if (settings.digestEnabled !== true && settings.digestAlertCount <= 0) return
1422
+ running = true
1423
+ try {
1424
+ const now = new Date()
1425
+ if (digestDue(settings, now)) await runDigest(ctx, getSettings).catch(() => {})
1426
+ if (settings.digestAlertCount > 0) {
1427
+ const today = todayKey(now)
1428
+ if (settings.digestAlertDate !== today) {
1429
+ const entries = readHistory(settings)
1430
+ const count = entries.filter((e) => dayKeyOf(num(e?.at, 0)) === today).length
1431
+ if (count >= settings.digestAlertCount) {
1432
+ await saveBalanceState(ctx, { digestAlertDate: today })
1433
+ await notify(
1434
+ 'raw',
1435
+ { title: '提醒有点多', message: `今天已经弹了 ${count} 条提醒,超过你设的 ${settings.digestAlertCount} 条上限。` },
1436
+ settings,
1437
+ )
1438
+ }
1439
+ }
1440
+ }
1441
+ } catch {
1442
+ /* 定时器里出错不影响下一轮 */
1443
+ } finally {
1444
+ running = false
1445
+ }
1446
+ }
1447
+ const timer = setInterval(() => {
1448
+ void tick()
1449
+ }, 60 * 1000)
1450
+ if (typeof timer?.unref === 'function') timer.unref()
1451
+ ctx.effect(() => () => clearInterval(timer), 'dsh-reminder-notify: digest watcher')
1452
+ }
1453
+
1454
+ function registerDigestRoute(ctx, getSettings) {
1455
+ const web = typeof ctx.get === 'function' ? ctx.get('webServer') : undefined
1456
+ if (web === undefined || web === null || typeof web.register !== 'function') {
1457
+ ctx.logger?.warn?.('dsh-reminder-notify: webServer is unavailable, the digest panel stays hidden')
1458
+ return
1459
+ }
1460
+ const reply = (res, status, payload) => {
1461
+ res.writeHead(status, { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' })
1462
+ res.end(JSON.stringify(payload))
1463
+ }
1464
+ const route = {
1465
+ kind: 'exact',
1466
+ path: DIGEST_ROUTE,
1467
+ handler: async (req, res) => {
1468
+ try {
1469
+ const settings = getSettings()
1470
+ const method = (req.method ?? 'GET').toUpperCase()
1471
+ if (method === 'GET') {
1472
+ const entries = readHistory(settings)
1473
+ let balance = null
1474
+ if (settings.digestIncludeBalance) {
1475
+ const read = await readAccountBalance(ctx).catch(() => null)
1476
+ if (read && read.balance !== undefined) balance = read
1477
+ }
1478
+ return reply(res, 200, {
1479
+ ok: true,
1480
+ enabled: settings.digestEnabled,
1481
+ time: settings.digestTime,
1482
+ lastDate: settings.digestLastDate,
1483
+ alertCount: settings.digestAlertCount,
1484
+ pushEnabled: settings.pushEnabled,
1485
+ pushFormat: settings.pushFormat,
1486
+ title: str(settings.digestTitle, '今日提醒日报'),
1487
+ message: digestMessage(settings, entries, balance),
1488
+ })
1489
+ }
1490
+ if (method !== 'POST') return reply(res, 405, { ok: false, error: 'use GET or POST' })
1491
+ await readJsonBody(req)
1492
+ const result = await runDigest(ctx, getSettings, { force: true })
1493
+ return reply(res, 200, { ok: result.ok !== false, title: result.title, message: result.message, push: result.push })
1494
+ } catch (error) {
1495
+ return reply(res, 500, { ok: false, error: String(error?.message ?? error) })
1496
+ }
1497
+ },
1498
+ }
1499
+ ctx.effect(() => {
1500
+ const dispose = web.register(route)
1501
+ return () => {
1502
+ if (typeof dispose === 'function') dispose()
1503
+ }
1504
+ }, 'dsh-reminder-notify: digest route')
1505
+ }
1506
+
1285
1507
  function registerHistoryRoute(ctx, getSettings) {
1286
1508
  const web = typeof ctx.get === 'function' ? ctx.get('webServer') : undefined
1287
1509
  if (web === undefined || web === null || typeof web.register !== 'function') {
@@ -1335,12 +1557,14 @@ export function apply(ctx, config) {
1335
1557
  registerPreviewRoute(ctx, () => settingsOf(config))
1336
1558
  registerBalanceRoute(ctx, () => settingsOf(config), config)
1337
1559
  registerHistoryRoute(ctx, () => settingsOf(config))
1560
+ registerDigestRoute(ctx, () => settingsOf(config))
1561
+ registerDigestLoop(ctx, () => settingsOf(config))
1338
1562
  const tools = typeof ctx.get === 'function' ? ctx.get('tools') : ctx.tools
1339
1563
  if (tools === undefined || tools === null || typeof tools.register !== 'function') {
1340
1564
  ctx.logger?.warn?.('dsh-reminder-notify: tools service is unavailable, notify_user was not registered')
1341
1565
  return
1342
1566
  }
1343
- const definition = toolDefinition(() => settingsOf(config))
1567
+ const definition = toolDefinition(() => settingsOf(config), ctx)
1344
1568
  const dispose = tools.register(definition)
1345
1569
  ctx.effect(() => dispose, 'dsh-reminder-notify: notify_user tool')
1346
1570
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-reminder-notify",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "DSH 桌面提醒插件:把「完成/需要决定」提醒变成 notify_user 工具(浮动卡片 + 提示音,不抢焦点,纯 PowerShell 源码宿主,仓库零 exe)",
5
5
  "author": "Jiangshuaiye1203",
6
6
  "type": "module",
@@ -48,8 +48,8 @@
48
48
  },
49
49
  "versions": [
50
50
  {
51
- "version": "0.10.2",
52
- "publishTimestamp": 1795100824,
51
+ "version": "0.11.1",
52
+ "publishTimestamp": 1795182589,
53
53
  "source": {
54
54
  "type": "npm"
55
55
  },