dsh-reminder-notify 0.12.0 → 0.13.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
@@ -42,6 +42,13 @@ dsh plugin --profile desktop add link:<本目录绝对路径>
42
42
  `json` 通用 webhook / `text` 纯文本;`pushDecide` 管「需要你来决定」要不要推,`pushDigest` 管日报要不要推。
43
43
  推送失败不影响桌面卡片,也不会拖慢 `notify_user`。
44
44
 
45
+ 0.13 起设置面板只放「要改的东西」:
46
+
47
+ - 顶部一行状态摘要(位置 · 秒数 · 提示音,开了推送/日报再各加一段)+ 三个「试试看」按钮(完成卡 / 决定卡 / 通用卡),
48
+ 点了就立刻弹一张样卡,二十秒自动关,不用等我真发。
49
+ - 常用两组直接展开:**基本**、**日报与推送**;其余四块(外观 / 提示音 / 排队与免打扰 / 历史·余额·宿主)收在「高级」里,点标题展开。
50
+ - 使用说明不再塞进面板,全部写在插件详情页(本插件的说明文档)里。
51
+
45
52
  ## 资产
46
53
 
47
54
  | 东西 | 位置 |
package/client.js CHANGED
@@ -252,6 +252,17 @@ window.__ModuleLoader__.load({
252
252
  groupQueue: '排队与免打扰',
253
253
  groupHistory: '历史与统计',
254
254
  groupDigest: '日报与推送',
255
+ // 0.13:高频项在前,其余收进折叠块;说明搬到插件详情页。
256
+ groupAdvanced: '高级:历史、余额与宿主',
257
+ foldExpand: '展开',
258
+ foldCollapse: '收起',
259
+ tryTitle: '试试看:',
260
+ tryDone: '发一张完成卡',
261
+ tryDecide: '发一张决定卡',
262
+ tryRaw: '发一张通用卡',
263
+ tryShown: '已经弹出一张样卡,20 秒后自动关闭。',
264
+ tryQuiet: '现在在免打扰时段,样卡被拦住了(正常行为)。',
265
+ tryFailed: '没能弹出示意卡:',
255
266
  speakEnabled: '朗读提醒内容',
256
267
  buttonsEnabled: '卡片显示按钮',
257
268
  snoozeMinutes: '「稍后提醒」延后分钟',
@@ -335,6 +346,16 @@ window.__ModuleLoader__.load({
335
346
  groupQueue: 'Queue & quiet hours',
336
347
  groupHistory: 'History & stats',
337
348
  groupDigest: 'Digest & push',
349
+ groupAdvanced: 'Advanced: history, balance & host',
350
+ foldExpand: 'expand',
351
+ foldCollapse: 'collapse',
352
+ tryTitle: 'Try it:',
353
+ tryDone: 'Show a done card',
354
+ tryDecide: 'Show a decision card',
355
+ tryRaw: 'Show a plain card',
356
+ tryShown: 'A sample card is on screen; it closes itself in 20 seconds.',
357
+ tryQuiet: 'Quiet hours are active, so the sample was held back (expected).',
358
+ tryFailed: 'Could not show the sample: ',
338
359
  speakEnabled: 'Speak the reminder',
339
360
  buttonsEnabled: 'Show card buttons',
340
361
  snoozeMinutes: 'Snooze minutes',
@@ -440,6 +461,14 @@ window.__ModuleLoader__.load({
440
461
  .drn-btn.small { padding: 5px 10px; white-space: nowrap; }
441
462
  .drn-msg { font-size: 12px; color: var(--dsw-alias-label-secondary); }
442
463
  .drn-msg.error { color: var(--dsw-alias-state-error-primary); }
464
+ .drn-summary { font-size: 12px; line-height: 1.55; color: var(--dsw-alias-label-secondary); border: 1px dashed var(--dsw-alias-border-l1); border-radius: 8px; padding: 8px 10px; }
465
+ .drn-try { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
466
+ .drn-try-title { font-size: 12px; color: var(--dsw-alias-label-secondary); }
467
+ .drn-fold { border: 1px solid var(--dsw-alias-border-l1); border-radius: 10px; background: var(--dsw-alias-bg-layer-1); }
468
+ .drn-fold-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; box-sizing: border-box; font: inherit; font-size: 12px; font-weight: 600; color: var(--dsw-alias-label-secondary); background: transparent; border: 0; padding: 10px 14px; cursor: pointer; text-align: left; }
469
+ .drn-fold-body { display: flex; flex-direction: column; gap: 12px; padding: 0 14px 14px; }
470
+ .drn-fold-body > .drn-group { border: 0; padding: 0; background: transparent; }
471
+ .drn-chevron { font-size: 11px; }
443
472
  `
444
473
 
445
474
  // 字段表:kind 决定控件类型,group 决定分组,缺省值来自宿主 config。
@@ -447,7 +476,7 @@ window.__ModuleLoader__.load({
447
476
  { key: 'seconds', group: 'basic', kind: 'number' },
448
477
  { key: 'position', group: 'basic', kind: 'select', options: ['br', 'center', 'tr'], optionLabels: ['positionBr', 'positionCenter', 'positionTr'] },
449
478
  { key: 'sound', group: 'basic', kind: 'boolean' },
450
- { key: 'cooldownMs', group: 'basic', kind: 'number' },
479
+ { key: 'cooldownMs', group: 'host', kind: 'number' },
451
480
  { key: 'doneAudio', group: 'audio', kind: 'text' },
452
481
  { key: 'decideAudio', group: 'audio', kind: 'text' },
453
482
  { key: 'rawAudio', group: 'audio', kind: 'text' },
@@ -561,6 +590,16 @@ window.__ModuleLoader__.load({
561
590
  const GROUPS = ['basic', 'audio', 'look', 'queue', 'history', 'digest', 'balance', 'host']
562
591
  const GROUP_LABELS = { basic: 'groupBasic', audio: 'groupAudio', look: 'groupLook', queue: 'groupQueue', history: 'groupHistory', digest: 'groupDigest', balance: 'groupBalance', host: 'groupHost' }
563
592
 
593
+ // 0.13:面板分两层。常用层只放「不填就不对劲」的项,其余按主题收进四个折叠块。
594
+ const COMMON_DIGEST = ['pushEnabled', 'pushUrl', 'pushFormat', 'digestEnabled', 'digestTime']
595
+ const ADV_DIGEST = ['digestTitle', 'digestIncludeBalance', 'digestAlertCount', 'pushDecide', 'pushDigest']
596
+ const ADV_BLOCKS = [
597
+ { id: 'look', label: 'groupLook', groups: ['look'] },
598
+ { id: 'audio', label: 'groupAudio', groups: ['audio'] },
599
+ { id: 'queue', label: 'groupQueue', groups: ['queue'] },
600
+ { id: 'misc', label: 'groupAdvanced', groups: ['digest', 'history', 'balance', 'host'] },
601
+ ]
602
+
564
603
  function sameValue(a, b) {
565
604
  return JSON.stringify(a) === JSON.stringify(b)
566
605
  }
@@ -585,6 +624,9 @@ window.__ModuleLoader__.load({
585
624
  const [historyBusy, setHistoryBusy] = React.useState(false)
586
625
  const [digest, setDigest] = React.useState(null)
587
626
  const [digestBusy, setDigestBusy] = React.useState(false)
627
+ // 0.13:折叠块的展开状态(默认全收起)与「试试看」的忙碌标记。
628
+ const [openBlocks, setOpenBlocks] = React.useState({})
629
+ const [tryBusy, setTryBusy] = React.useState(null)
588
630
 
589
631
  React.useEffect(() => {
590
632
  if (typeof fetch !== 'function') {
@@ -787,6 +829,52 @@ window.__ModuleLoader__.load({
787
829
  })
788
830
  }
789
831
 
832
+ // 0.13「试试看」:让宿主真的弹一张样卡(POST /preview,mode=card),
833
+ // 比读说明书更快知道每一档长什么样。样卡只停 20 秒,不改任何配置。
834
+ function tryCard(kind) {
835
+ if (tryBusy !== null) return
836
+ setTryBusy(kind)
837
+ setMessage(null)
838
+ Promise.resolve()
839
+ .then(() =>
840
+ fetch(PREVIEW_ROUTE, {
841
+ method: 'POST',
842
+ headers: { 'content-type': 'application/json', accept: 'application/json' },
843
+ body: JSON.stringify({ mode: 'card', kind }),
844
+ }),
845
+ )
846
+ .then((response) => {
847
+ const status = response ? response.status : 0
848
+ const body = response && typeof response.json === 'function' ? response.json() : Promise.resolve(null)
849
+ return Promise.resolve(body)
850
+ .catch(() => null)
851
+ .then((data) => {
852
+ if (response && response.ok && data && data.ok !== false) return data
853
+ const detail = data && (data.detail || data.error) ? (data.detail || data.error) : 'HTTP ' + status
854
+ throw new Error(detail)
855
+ })
856
+ })
857
+ .then((data) => {
858
+ setTryBusy(null)
859
+ const label = typeof t === 'function' ? t : (key) => key
860
+ const card = data && data.card ? data.card : {}
861
+ if (card.ok === false) {
862
+ setMessage({ ok: false, text: label('tryFailed') + String(card.detail || card.error || '') })
863
+ return
864
+ }
865
+ if (card.skipped === 'quiet') {
866
+ setMessage({ ok: true, text: label('tryQuiet') })
867
+ return
868
+ }
869
+ setMessage({ ok: true, text: label('tryShown') })
870
+ })
871
+ .catch((error) => {
872
+ setTryBusy(null)
873
+ const prefix = typeof t === 'function' ? t('tryFailed') : 'cannot show a sample: '
874
+ setMessage({ ok: false, text: prefix + String((error && error.message) || error) })
875
+ })
876
+ }
877
+
790
878
  // 余额:数字与「立即查询 / 重置基线」都走同一个路由(宿主侧问账号服务)。
791
879
  function shortTime(ms) {
792
880
  const n = Number(ms)
@@ -900,11 +988,38 @@ window.__ModuleLoader__.load({
900
988
  }
901
989
 
902
990
  function sendDigest() {
903
- digestFetch({
904
- method: 'POST',
905
- headers: { 'content-type': 'application/json', accept: 'application/json' },
906
- body: JSON.stringify({ mode: 'send' }),
907
- })
991
+ const label = typeof t === 'function' ? t : (key) => key
992
+ setMessage(null)
993
+ setDigestBusy(true)
994
+ Promise.resolve()
995
+ .then(() =>
996
+ fetch(DIGEST_ROUTE, {
997
+ method: 'POST',
998
+ headers: { 'content-type': 'application/json', accept: 'application/json' },
999
+ body: JSON.stringify({ mode: 'send' }),
1000
+ }),
1001
+ )
1002
+ .then((response) => (response && typeof response.json === 'function' ? response.json() : Promise.reject(new Error('HTTP ' + (response ? response.status : '?')))))
1003
+ .then((data) => {
1004
+ setDigestBusy(false)
1005
+ if (!data || data.ok === false) throw new Error((data && data.error) || 'send rejected')
1006
+ setDigest(data)
1007
+ const push = data.push
1008
+ if (!push) {
1009
+ setMessage({ ok: true, text: label('digestSentNoPush') })
1010
+ return
1011
+ }
1012
+ if (push.ok) {
1013
+ setMessage({ ok: true, text: label('digestPushOkPrefix') + String(push.status === undefined ? '200' : push.status) + ')' })
1014
+ return
1015
+ }
1016
+ const reason = push.reason || push.error || push.body || String(push.status || '')
1017
+ setMessage({ ok: false, text: label('digestPushFailedPrefix') + String(reason) })
1018
+ })
1019
+ .catch((error) => {
1020
+ setDigestBusy(false)
1021
+ setMessage({ ok: false, text: label('digestSendFailedPrefix') + String((error && error.message) || error) })
1022
+ })
908
1023
  }
909
1024
 
910
1025
  function digestText() {
@@ -1045,8 +1160,11 @@ window.__ModuleLoader__.load({
1045
1160
  return input
1046
1161
  }
1047
1162
 
1048
- const groups = GROUPS.map((group) => {
1049
- const rows = FIELDS.filter((field) => field.group === group).map((field) =>
1163
+ // 一张分组卡片。allowed 有值时只渲染其中的键(用于把 digest 组拆成「常用」与「高级」两半)。
1164
+ const groupCard = (group, allowed, withExtras) => {
1165
+ const rows = FIELDS.filter(
1166
+ (field) => field.group === group && (allowed === undefined || allowed.includes(field.key)),
1167
+ ).map((field) =>
1050
1168
  h(
1051
1169
  'div',
1052
1170
  { className: 'drn-row', key: field.key },
@@ -1061,7 +1179,7 @@ window.__ModuleLoader__.load({
1061
1179
  h('div', { className: 'drn-control' }, control(field)),
1062
1180
  ),
1063
1181
  )
1064
- if (group === 'history') {
1182
+ if (withExtras !== false && group === 'history') {
1065
1183
  const label = typeof t === 'function' ? t : (key) => key
1066
1184
  rows.push(
1067
1185
  h(
@@ -1105,7 +1223,7 @@ window.__ModuleLoader__.load({
1105
1223
  )
1106
1224
  }
1107
1225
  }
1108
- if (group === 'digest') {
1226
+ if (withExtras !== false && group === 'digest') {
1109
1227
  const label = typeof t === 'function' ? t : (key) => key
1110
1228
  rows.push(
1111
1229
  h(
@@ -1122,19 +1240,19 @@ window.__ModuleLoader__.load({
1122
1240
  { className: 'drn-pick' },
1123
1241
  h(
1124
1242
  'button',
1125
- { type: 'button', className: 'drn-btn small', disabled: digestBusy, onClick: refreshDigest },
1243
+ { type: 'button', className: 'drn-btn drn-digest-btn', disabled: digestBusy, onClick: refreshDigest },
1126
1244
  label('digestRefresh'),
1127
1245
  ),
1128
1246
  h(
1129
1247
  'button',
1130
- { type: 'button', className: 'drn-btn small', disabled: digestBusy, onClick: sendDigest },
1248
+ { type: 'button', className: 'drn-btn drn-digest-btn', disabled: digestBusy, onClick: sendDigest },
1131
1249
  label(digestBusy ? 'digestSending' : 'digestSend'),
1132
1250
  ),
1133
1251
  ),
1134
1252
  ),
1135
1253
  )
1136
1254
  }
1137
- if (group === 'balance') {
1255
+ if (withExtras !== false && group === 'balance') {
1138
1256
  rows.push(
1139
1257
  h(
1140
1258
  'div',
@@ -1171,8 +1289,76 @@ window.__ModuleLoader__.load({
1171
1289
  h('div', { className: 'drn-group-title' }, typeof t === 'function' ? t(GROUP_LABELS[group]) : group),
1172
1290
  rows,
1173
1291
  )
1292
+ }
1293
+
1294
+ const label = typeof t === 'function' ? t : (key) => key
1295
+
1296
+ // 一句话状态:让人不开任何折叠就知道现在是「哪儿、多久、有没有声、推送/日报开没开」。
1297
+ const summaryText = () => {
1298
+ const posKey = values.position === 'center' ? 'positionCenter' : values.position === 'tr' ? 'positionTr' : 'positionBr'
1299
+ const sound = values.sound === false ? label('soundOff') : label('soundOn')
1300
+ const secs = values.seconds === undefined || values.seconds === null ? 60 : values.seconds
1301
+ const parts = [`${label(posKey)} · ${secs}${label('secondsUnit')} · ${sound}`]
1302
+ if (values.pushEnabled === true) {
1303
+ const fmt =
1304
+ values.pushFormat === 'serverchan'
1305
+ ? 'pushFormatServerchan'
1306
+ : values.pushFormat === 'json'
1307
+ ? 'pushFormatJson'
1308
+ : values.pushFormat === 'text'
1309
+ ? 'pushFormatText'
1310
+ : 'pushFormatWecom'
1311
+ parts.push(`${label('pushEnabled')} · ${label(fmt)}`)
1312
+ }
1313
+ if (values.digestEnabled === true) parts.push(`${label('digestEnabled')} · ${values.digestTime || '09:00'}`)
1314
+ return label('summaryPrefix') + parts.join(' · ')
1315
+ }
1316
+
1317
+ const common = [groupCard('basic'), groupCard('digest', COMMON_DIGEST, true)]
1318
+
1319
+ const advanced = ADV_BLOCKS.map((block) => {
1320
+ const open = openBlocks[block.id] === true
1321
+ const children = block.groups.map((group) =>
1322
+ group === 'digest' ? groupCard('digest', ADV_DIGEST, false) : groupCard(group),
1323
+ )
1324
+ return h(
1325
+ 'div',
1326
+ { className: 'drn-fold', key: 'fold-' + block.id },
1327
+ h(
1328
+ 'button',
1329
+ {
1330
+ type: 'button',
1331
+ className: 'drn-fold-head',
1332
+ onClick: () => setOpenBlocks(Object.assign({}, openBlocks, { [block.id]: !open })),
1333
+ },
1334
+ h('span', null, label(block.label)),
1335
+ h('span', { className: 'drn-chevron' }, open ? '▾ ' + label('foldCollapse') : '▸ ' + label('foldExpand')),
1336
+ ),
1337
+ h('div', { className: 'drn-fold-body', style: open ? undefined : { display: 'none' } }, children),
1338
+ )
1174
1339
  })
1175
1340
 
1341
+ const tryRow = h(
1342
+ 'div',
1343
+ { className: 'drn-try' },
1344
+ h('span', { className: 'drn-try-title' }, label('tryTitle')),
1345
+ h(
1346
+ 'button',
1347
+ { type: 'button', className: 'drn-btn drn-try-btn', disabled: tryBusy !== null, onClick: () => tryCard('done') },
1348
+ label('tryDone'),
1349
+ ),
1350
+ h(
1351
+ 'button',
1352
+ { type: 'button', className: 'drn-btn drn-try-btn', disabled: tryBusy !== null, onClick: () => tryCard('decide') },
1353
+ label('tryDecide'),
1354
+ ),
1355
+ h(
1356
+ 'button',
1357
+ { type: 'button', className: 'drn-btn drn-try-btn', disabled: tryBusy !== null, onClick: () => tryCard('raw') },
1358
+ label('tryRaw'),
1359
+ ),
1360
+ )
1361
+
1176
1362
  return h(
1177
1363
  'div',
1178
1364
  { className: 'drn-panel' },
@@ -1181,8 +1367,11 @@ window.__ModuleLoader__.load({
1181
1367
  { className: 'drn-head' },
1182
1368
  h('div', { className: 'drn-head-title' }, typeof t === 'function' ? t('title') : 'Desktop reminder settings'),
1183
1369
  h('div', { className: 'drn-head-intro' }, typeof t === 'function' ? t(writable ? 'intro' : 'readonly') : ''),
1370
+ h('div', { className: 'drn-summary' }, summaryText()),
1184
1371
  ),
1185
- groups,
1372
+ tryRow,
1373
+ common,
1374
+ advanced,
1186
1375
  h(
1187
1376
  'div',
1188
1377
  { className: 'drn-actions' },
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.1**,装源为 **npm**(`dsh-reminder-notify@0.12.1`),不再是 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,26 @@ 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 eight groups:
9
+ The panel holds only what you might change; the instructions live on this page.
10
+
11
+ **Three small things at the top**
12
+
13
+ - A one-line status summary: position · duration · sound, plus `push · serverchan` and `digest · 09:00` when those are on
14
+ - **Try it** — three buttons (done card / decision card / plain card) so you can check position, colours and sound
15
+ without waiting for a real reminder. Each sample closes itself in 20 seconds
16
+ - **Save** / **Discard** at the bottom; saving applies immediately, no restart
17
+
18
+ **Common groups** (open by default)
10
19
 
11
20
  - **Basics**: duration, position, sound on/off
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
- - **Look**: background image, title icon, accent colours, title/message templates (`{title}` `{message}` `{kind}` `{time}`), plus per-kind overrides for background, icon and templates
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
- - **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
17
- - **Host**: script or exe host, script path, PowerShell path
21
+ - **Digest & push**: push switch, URL, format, digest switch, digest time; below it today's digest preview and a "send one now" button
18
22
 
19
- Changes apply on "Save" — no restart needed.
23
+ **Advanced** (collapsed; click the header to expand)
20
24
 
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
25
+ - **Look**: background image, title icon, accent colours, title/message templates (`{title}` `{message}` `{kind}` `{time}`), plus per-kind overrides
26
+ - **Sounds**: audio directory ("Browse…"), the three per-kind file names (wav / mp3)
27
+ - **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
28
+ - **History, balance & host**: history switch and kept entries (with counts, last 8 entries, refresh / clear), DeepSeek balance (thresholds, interval, spoken alerts, check now, set baseline), host (script or exe, script path, PowerShell path, per-kind cooldown)
22
29
 
23
30
  ## Digest and phone push (0.12+)
24
31
 
@@ -30,6 +37,8 @@ Changes apply on "Save" — no restart needed.
30
37
  - **Phone push**: `pushEnabled` + `pushUrl` + `pushFormat` — `wecom` (WeCom bot), `serverchan` (ServerChan),
31
38
  `json` (generic webhook), `text` (plain text). `pushDecide` and `pushDigest` decide whether decisions and the
32
39
  digest are pushed. Delivery is fire-and-forget: 8s timeout, failures only show up in the return value.
40
+ Since 0.12.1 the `errcode` / `code` in the response is parsed, so a WeCom "invalid webhook url" (HTTP 200)
41
+ counts as a failure, and "Send one now" reports the result or the reason in the panel.
33
42
 
34
43
  ## Card behaviour (0.11+)
35
44
 
package/docs/detail.zh.md CHANGED
@@ -6,18 +6,25 @@
6
6
 
7
7
  ## 设置
8
8
 
9
- 在「插件」页打开「桌面提醒」,描述下方就是设置面板,分八组:
9
+ 面板只放「要改的东西」,说明都写在本页(你正在看的这一页)。
10
+
11
+ **最上面三件小事**
12
+
13
+ - 一行状态摘要:现在的位置 · 停留秒数 · 提示音开关;开了推送/日报会各加一段(`推送 · serverchan`、`日报 · 09:00`)
14
+ - 「试试看」三个按钮:**发一张完成卡 / 决定卡 / 通用卡**。二十秒后自动关,用来确认位置、配色、提示音是否合心意——不用等我真弹一张
15
+ - 「保存」/「放弃改动」在页面底部;保存即生效,不用重启
16
+
17
+ **常用的两组**(打开就能改)
10
18
 
11
19
  - **基本**:停留秒数、弹窗位置、是否播放提示音
12
- - **提示音**:提示音目录(可点「浏览…」选目录)、三档提示音文件名(wav / mp3),选了目录后下拉框会列出目录里的音频
20
+ - **日报与推送**:推送开关、地址、格式、日报开关、日报时间;下面能预览今天的日报全文,也能「现在发一条」立刻试一次推送
21
+
22
+ **高级**(默认收起,点标题展开)
23
+
13
24
  - **外观**:背景图、标题图标、强调色、标题/正文模板(`{title}` `{message}` `{kind}` `{time}`),以及每档位单独覆盖的背景 / 图标 / 模板
25
+ - **提示音**:提示音目录(可点「浏览…」选目录)、三档提示音文件名(wav / mp3),选了目录后下拉框会列出目录里的音频
14
26
  - **排队与免打扰**:语音朗读、卡片按钮、「稍后提醒」分钟数、排队开关与上限、合并窗口、免打扰时段与处理方式、全屏时用紧凑卡片
15
- - **历史与统计**:是否记录、保留条数,面板里直接显示总条数 / 今日条数与最近 8 条记录,可「刷新」和「清空」
16
- - **日报与推送**:每日日报(开关、时间、标题、是否带余额、条数预警阈值)、手机推送(开关、地址、格式、「需要你来决定」与日报是否也推);面板里能预览今天的日报全文,也能「现在发一条」
17
- - **DeepSeek 余额**:开关、阈值(默认 20,10,5 %)、检查间隔、是否语音播报;面板里能「立即查询」,也能把当前余额设为基线
18
- - **宿主**:脚本模式或 exe 模式、脚本路径、PowerShell 路径
19
-
20
- 改完点「保存」,立刻生效,不用重启。
27
+ - **历史、余额与宿主**:历史记录开关与保留条数(含统计与最近 8 条、刷新 / 清空)、DeepSeek 余额提醒(阈值、检查间隔、语音播报、立即查询、设为基线)、宿主(脚本或 exe 模式、脚本路径、PowerShell 路径、同档位冷却)
21
28
 
22
29
  ## 日报与手机推送(0.12 起)
23
30
 
@@ -31,6 +38,8 @@
31
38
  `json`(`{"title","message","kind","time"}`)、`text`(`标题\n正文` 纯文本)。
32
39
  `pushDecide` 控制「需要你来决定」是否推送,`pushDigest` 控制日报是否推送。
33
40
  推送是 fire-and-forget:超时 8 秒、失败只记在返回值里,不影响卡片,也不阻塞 `notify_user`。
41
+ 0.12.1 起会解析对方返回的 `errcode` / `code`:企业微信「webhook 地址不对」这类 HTTP 200 的失败也算失败,
42
+ 面板上「现在发一条」会直接写出发送结果或失败原因。
34
43
 
35
44
  ## 提醒的行为(0.11 起)
36
45
 
package/index.js CHANGED
@@ -978,6 +978,21 @@ function registerPreviewRoute(ctx, getSettings) {
978
978
  if (!['done', 'decide', 'raw'].includes(kind)) {
979
979
  return reply(res, 400, { ok: false, error: `unknown kind: ${kind}` })
980
980
  }
981
+ // 面板上的「试试看」:mode=card 时真的弹一张样卡,比只播提示音更能说明效果。
982
+ if (str(body?.mode, 'audio') === 'card') {
983
+ const settings = getSettings()
984
+ const sample = {
985
+ done: '这是一张「完成」卡:任务做完时这样弹,带提示音、按钮,到点自己消失。',
986
+ decide: '这是一张「需要你决定」卡:等你拍板时这样弹。',
987
+ raw: '这是一张通用提醒卡,标题和正文都由调用方给。',
988
+ }[kind]
989
+ const card = await notify(
990
+ kind,
991
+ { message: sample, seconds: Math.min(num(settings.seconds, 60), 20) },
992
+ { ...settings, quietEnabled: false },
993
+ )
994
+ return reply(res, 200, { ok: true, mode: 'card', kind, card })
995
+ }
981
996
  const result = await previewAudio(kind, getSettings())
982
997
  if (result.ok) return reply(res, 200, result)
983
998
  const status = result.error === 'no-audio' || result.error === 'audio-not-found' ? 400 : 500
@@ -1387,6 +1402,19 @@ export async function pushOut(settings, title, message, extra = {}) {
1387
1402
  signal: typeof AbortSignal?.timeout === 'function' ? AbortSignal.timeout(8000) : undefined,
1388
1403
  })
1389
1404
  const text = await response.text().catch(() => '')
1405
+ let parsed = null
1406
+ try {
1407
+ parsed = text === '' ? null : JSON.parse(text)
1408
+ } catch {
1409
+ parsed = null
1410
+ }
1411
+ // 企业微信/Server 酱都是 HTTP 200 + 报文里的错误码:
1412
+ // 只看 response.ok 会把「webhook 地址不对」当成发送成功。
1413
+ const code = parsed && typeof parsed === 'object' ? parsed.errcode ?? parsed.code : undefined
1414
+ if (code !== undefined && code !== null && Number(code) !== 0) {
1415
+ const reason = String(parsed.errmsg ?? parsed.message ?? code)
1416
+ return { ok: false, status: response.status, error: 'webhook-rejected', reason, body: text.slice(0, 200) }
1417
+ }
1390
1418
  return { ok: response.ok, status: response.status, body: text.slice(0, 200) }
1391
1419
  } catch (error) {
1392
1420
  return { ok: false, error: String(error?.message ?? error) }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-reminder-notify",
3
- "version": "0.12.0",
3
+ "version": "0.13.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.11.1",
52
- "publishTimestamp": 1795182589,
51
+ "version": "0.12.1",
52
+ "publishTimestamp": 1795186817,
53
53
  "source": {
54
54
  "type": "npm"
55
55
  },