dsh-reminder-notify 0.11.1 → 0.12.1

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,71 @@ 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
+ const label = typeof t === 'function' ? t : (key) => key
904
+ setMessage(null)
905
+ setDigestBusy(true)
906
+ Promise.resolve()
907
+ .then(() =>
908
+ fetch(DIGEST_ROUTE, {
909
+ method: 'POST',
910
+ headers: { 'content-type': 'application/json', accept: 'application/json' },
911
+ body: JSON.stringify({ mode: 'send' }),
912
+ }),
913
+ )
914
+ .then((response) => (response && typeof response.json === 'function' ? response.json() : Promise.reject(new Error('HTTP ' + (response ? response.status : '?')))))
915
+ .then((data) => {
916
+ setDigestBusy(false)
917
+ if (!data || data.ok === false) throw new Error((data && data.error) || 'send rejected')
918
+ setDigest(data)
919
+ const push = data.push
920
+ if (!push) {
921
+ setMessage({ ok: true, text: label('digestSentNoPush') })
922
+ return
923
+ }
924
+ if (push.ok) {
925
+ setMessage({ ok: true, text: label('digestPushOkPrefix') + String(push.status === undefined ? '200' : push.status) + ')' })
926
+ return
927
+ }
928
+ const reason = push.reason || push.error || push.body || String(push.status || '')
929
+ setMessage({ ok: false, text: label('digestPushFailedPrefix') + String(reason) })
930
+ })
931
+ .catch((error) => {
932
+ setDigestBusy(false)
933
+ setMessage({ ok: false, text: label('digestSendFailedPrefix') + String((error && error.message) || error) })
934
+ })
935
+ }
936
+
937
+ function digestText() {
938
+ const label = typeof t === 'function' ? t : (key) => key
939
+ if (digest === null) return label('digestLoading')
940
+ if (digest.ok === false) {
941
+ return label('digestUnavailable') + (digest.error ? '(' + String(digest.error) + ')' : '')
942
+ }
943
+ if (digest.enabled === false) return label('digestDisabled')
944
+ return String(digest.message || '').split('\n').join(' / ')
945
+ }
946
+
795
947
  function refreshHistory() {
796
948
  historyFetch({ headers: { accept: 'application/json' } })
797
949
  }
@@ -980,6 +1132,35 @@ window.__ModuleLoader__.load({
980
1132
  )
981
1133
  }
982
1134
  }
1135
+ if (group === 'digest') {
1136
+ const label = typeof t === 'function' ? t : (key) => key
1137
+ rows.push(
1138
+ h(
1139
+ 'div',
1140
+ { className: 'drn-row', key: 'digest-status' },
1141
+ h(
1142
+ 'div',
1143
+ { className: 'drn-row-main' },
1144
+ h('div', { className: 'drn-label' }, label('digestStatus')),
1145
+ h('div', { className: 'drn-hint' }, digestText()),
1146
+ ),
1147
+ h(
1148
+ 'div',
1149
+ { className: 'drn-pick' },
1150
+ h(
1151
+ 'button',
1152
+ { type: 'button', className: 'drn-btn small', disabled: digestBusy, onClick: refreshDigest },
1153
+ label('digestRefresh'),
1154
+ ),
1155
+ h(
1156
+ 'button',
1157
+ { type: 'button', className: 'drn-btn small', disabled: digestBusy, onClick: sendDigest },
1158
+ label(digestBusy ? 'digestSending' : 'digestSend'),
1159
+ ),
1160
+ ),
1161
+ ),
1162
+ )
1163
+ }
983
1164
  if (group === 'balance') {
984
1165
  rows.push(
985
1166
  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.11.0**,装源为 **npm**(`dsh-reminder-notify@0.11.0`),不再是 git 固定提交 |
15
+ | 当前版本 | **0.12.0**,装源为 **npm**(`dsh-reminder-notify@0.12.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,33 @@ 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
+ Since 0.12.1 the `errcode` / `code` in the response is parsed, so a WeCom "invalid webhook url" (HTTP 200)
34
+ counts as a failure, and "Send one now" reports the result or the reason in the panel.
35
+
22
36
  ## Card behaviour (0.11+)
23
37
 
24
38
  - **Queue**: one card at a time; later reminders wait in a queue (`queueEnabled` / `queueMax`) instead of stacking.
package/docs/detail.zh.md CHANGED
@@ -6,18 +6,34 @@
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
+ 0.12.1 起会解析对方返回的 `errcode` / `code`:企业微信「webhook 地址不对」这类 HTTP 200 的失败也算失败,
35
+ 面板上「现在发一条」会直接写出发送结果或失败原因。
36
+
21
37
  ## 提醒的行为(0.11 起)
22
38
 
23
39
  - **排队**:一次只显示一张卡,后来的进队列(`queueEnabled` / `queueMax`),不再一叠好几张。
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,212 @@ 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
+ let parsed = null
1391
+ try {
1392
+ parsed = text === '' ? null : JSON.parse(text)
1393
+ } catch {
1394
+ parsed = null
1395
+ }
1396
+ // 企业微信/Server 酱都是 HTTP 200 + 报文里的错误码:
1397
+ // 只看 response.ok 会把「webhook 地址不对」当成发送成功。
1398
+ const code = parsed && typeof parsed === 'object' ? parsed.errcode ?? parsed.code : undefined
1399
+ if (code !== undefined && code !== null && Number(code) !== 0) {
1400
+ const reason = String(parsed.errmsg ?? parsed.message ?? code)
1401
+ return { ok: false, status: response.status, error: 'webhook-rejected', reason, body: text.slice(0, 200) }
1402
+ }
1403
+ return { ok: response.ok, status: response.status, body: text.slice(0, 200) }
1404
+ } catch (error) {
1405
+ return { ok: false, error: String(error?.message ?? error) }
1406
+ }
1407
+ }
1408
+
1409
+ export async function runDigest(ctx, getSettings, { force = false } = {}) {
1410
+ const settings = getSettings()
1411
+ if (!force && settings.digestEnabled !== true) return { ok: false, error: 'digest-disabled' }
1412
+ const entries = readHistory(settings)
1413
+ let balance = null
1414
+ if (settings.digestIncludeBalance) {
1415
+ const read = await readAccountBalance(ctx).catch(() => null)
1416
+ if (read && read.balance !== undefined) balance = read
1417
+ }
1418
+ const title = str(settings.digestTitle, '今日提醒日报')
1419
+ const message = digestMessage(settings, entries, balance)
1420
+ const card = await notify('raw', { title, message, seconds: Math.max(20, settings.seconds) }, settings)
1421
+ let push = null
1422
+ if (settings.pushEnabled && settings.pushDigest && settings.dryRun !== true) {
1423
+ push = await pushOut(settings, title, message, { kind: 'digest' })
1424
+ }
1425
+ if (!force) await saveBalanceState(ctx, { digestLastDate: todayKey() })
1426
+ return { ok: true, title, message, card, push }
1427
+ }
1428
+
1429
+ function registerDigestLoop(ctx, getSettings) {
1430
+ let running = false
1431
+ const tick = async () => {
1432
+ if (running) return
1433
+ const settings = getSettings()
1434
+ if (settings.digestEnabled !== true && settings.digestAlertCount <= 0) return
1435
+ running = true
1436
+ try {
1437
+ const now = new Date()
1438
+ if (digestDue(settings, now)) await runDigest(ctx, getSettings).catch(() => {})
1439
+ if (settings.digestAlertCount > 0) {
1440
+ const today = todayKey(now)
1441
+ if (settings.digestAlertDate !== today) {
1442
+ const entries = readHistory(settings)
1443
+ const count = entries.filter((e) => dayKeyOf(num(e?.at, 0)) === today).length
1444
+ if (count >= settings.digestAlertCount) {
1445
+ await saveBalanceState(ctx, { digestAlertDate: today })
1446
+ await notify(
1447
+ 'raw',
1448
+ { title: '提醒有点多', message: `今天已经弹了 ${count} 条提醒,超过你设的 ${settings.digestAlertCount} 条上限。` },
1449
+ settings,
1450
+ )
1451
+ }
1452
+ }
1453
+ }
1454
+ } catch {
1455
+ /* 定时器里出错不影响下一轮 */
1456
+ } finally {
1457
+ running = false
1458
+ }
1459
+ }
1460
+ const timer = setInterval(() => {
1461
+ void tick()
1462
+ }, 60 * 1000)
1463
+ if (typeof timer?.unref === 'function') timer.unref()
1464
+ ctx.effect(() => () => clearInterval(timer), 'dsh-reminder-notify: digest watcher')
1465
+ }
1466
+
1467
+ function registerDigestRoute(ctx, getSettings) {
1468
+ const web = typeof ctx.get === 'function' ? ctx.get('webServer') : undefined
1469
+ if (web === undefined || web === null || typeof web.register !== 'function') {
1470
+ ctx.logger?.warn?.('dsh-reminder-notify: webServer is unavailable, the digest panel stays hidden')
1471
+ return
1472
+ }
1473
+ const reply = (res, status, payload) => {
1474
+ res.writeHead(status, { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' })
1475
+ res.end(JSON.stringify(payload))
1476
+ }
1477
+ const route = {
1478
+ kind: 'exact',
1479
+ path: DIGEST_ROUTE,
1480
+ handler: async (req, res) => {
1481
+ try {
1482
+ const settings = getSettings()
1483
+ const method = (req.method ?? 'GET').toUpperCase()
1484
+ if (method === 'GET') {
1485
+ const entries = readHistory(settings)
1486
+ let balance = null
1487
+ if (settings.digestIncludeBalance) {
1488
+ const read = await readAccountBalance(ctx).catch(() => null)
1489
+ if (read && read.balance !== undefined) balance = read
1490
+ }
1491
+ return reply(res, 200, {
1492
+ ok: true,
1493
+ enabled: settings.digestEnabled,
1494
+ time: settings.digestTime,
1495
+ lastDate: settings.digestLastDate,
1496
+ alertCount: settings.digestAlertCount,
1497
+ pushEnabled: settings.pushEnabled,
1498
+ pushFormat: settings.pushFormat,
1499
+ title: str(settings.digestTitle, '今日提醒日报'),
1500
+ message: digestMessage(settings, entries, balance),
1501
+ })
1502
+ }
1503
+ if (method !== 'POST') return reply(res, 405, { ok: false, error: 'use GET or POST' })
1504
+ await readJsonBody(req)
1505
+ const result = await runDigest(ctx, getSettings, { force: true })
1506
+ return reply(res, 200, { ok: result.ok !== false, title: result.title, message: result.message, push: result.push })
1507
+ } catch (error) {
1508
+ return reply(res, 500, { ok: false, error: String(error?.message ?? error) })
1509
+ }
1510
+ },
1511
+ }
1512
+ ctx.effect(() => {
1513
+ const dispose = web.register(route)
1514
+ return () => {
1515
+ if (typeof dispose === 'function') dispose()
1516
+ }
1517
+ }, 'dsh-reminder-notify: digest route')
1518
+ }
1519
+
1285
1520
  function registerHistoryRoute(ctx, getSettings) {
1286
1521
  const web = typeof ctx.get === 'function' ? ctx.get('webServer') : undefined
1287
1522
  if (web === undefined || web === null || typeof web.register !== 'function') {
@@ -1335,12 +1570,14 @@ export function apply(ctx, config) {
1335
1570
  registerPreviewRoute(ctx, () => settingsOf(config))
1336
1571
  registerBalanceRoute(ctx, () => settingsOf(config), config)
1337
1572
  registerHistoryRoute(ctx, () => settingsOf(config))
1573
+ registerDigestRoute(ctx, () => settingsOf(config))
1574
+ registerDigestLoop(ctx, () => settingsOf(config))
1338
1575
  const tools = typeof ctx.get === 'function' ? ctx.get('tools') : ctx.tools
1339
1576
  if (tools === undefined || tools === null || typeof tools.register !== 'function') {
1340
1577
  ctx.logger?.warn?.('dsh-reminder-notify: tools service is unavailable, notify_user was not registered')
1341
1578
  return
1342
1579
  }
1343
- const definition = toolDefinition(() => settingsOf(config))
1580
+ const definition = toolDefinition(() => settingsOf(config), ctx)
1344
1581
  const dispose = tools.register(definition)
1345
1582
  ctx.effect(() => dispose, 'dsh-reminder-notify: notify_user tool')
1346
1583
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-reminder-notify",
3
- "version": "0.11.1",
3
+ "version": "0.12.1",
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.11.0",
52
- "publishTimestamp": 1795182292,
51
+ "version": "0.12.0",
52
+ "publishTimestamp": 1795186049,
53
53
  "source": {
54
54
  "type": "npm"
55
55
  },