@kanadego/dsh-heartbeat 2.1.2 → 2.2.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 +15 -22
- package/client.js +259 -47
- package/dist/bili-login-XQVEE4M6.js +32 -0
- package/dist/{chunk-HE6IF6OU.js → chunk-F2XVKX55.js} +14 -1
- package/dist/chunk-F2XVKX55.js.map +1 -0
- package/dist/{chunk-63E5OYSI.js → chunk-N6SMIGYJ.js} +46 -19
- package/dist/chunk-N6SMIGYJ.js.map +1 -0
- package/dist/chunk-OCBE2AKW.js +25 -0
- package/dist/chunk-OCBE2AKW.js.map +1 -0
- package/dist/chunk-SIY3YHFY.js +221 -0
- package/dist/chunk-SIY3YHFY.js.map +1 -0
- package/dist/{chunk-XCMGPIUQ.js → chunk-WF7ZBW5C.js} +196 -70
- package/dist/chunk-WF7ZBW5C.js.map +1 -0
- package/dist/{chunk-LPPRI53J.js → chunk-XYBII5PR.js} +2 -2
- package/dist/cli/index.js +47 -14
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +11 -0
- package/dist/index.js +368 -29
- package/dist/index.js.map +1 -1
- package/dist/{orchestrator-MNFCPH43.js → orchestrator-QE2XVVM6.js} +12 -4
- package/dist/{pool-MAABBHC4.js → pool-76VLAZER.js} +4 -2
- package/dist/pool-76VLAZER.js.map +1 -0
- package/package.json +5 -3
- package/dist/chunk-63E5OYSI.js.map +0 -1
- package/dist/chunk-HE6IF6OU.js.map +0 -1
- package/dist/chunk-XCMGPIUQ.js.map +0 -1
- /package/dist/{orchestrator-MNFCPH43.js.map → bili-login-XQVEE4M6.js.map} +0 -0
- /package/dist/{chunk-LPPRI53J.js.map → chunk-XYBII5PR.js.map} +0 -0
- /package/dist/{pool-MAABBHC4.js.map → orchestrator-QE2XVVM6.js.map} +0 -0
package/README.md
CHANGED
|
@@ -294,7 +294,8 @@ node <插件目录>/dist/cli/index.js <命令>
|
|
|
294
294
|
|
|
295
295
|
| 插件版本 | 适配的 DSH |
|
|
296
296
|
| ------------------ | --------------------------- |
|
|
297
|
-
| **v2.
|
|
297
|
+
| **v2.2.0**(当前) | `0.2.0-rc.1` – `0.2.2-rc.1` |
|
|
298
|
+
| v2.1.1 – v2.1.2 | `0.2.0-rc.1` – `0.2.1-rc.5` |
|
|
298
299
|
| v2.0.0 – v2.0.1 | `0.2.0-rc.1` – `0.2.1-rc.2` |
|
|
299
300
|
| v1.7.4 – v1.9.3 | `0.2.0-rc.1` – `0.2.0-rc.2` |
|
|
300
301
|
| v1.7.2 – v1.7.3 | `0.1.7-rc.1` – `0.2.0-rc.1` |
|
|
@@ -335,33 +336,25 @@ dsh plugin --profile web remove @kanadego/dsh-heartbeat
|
|
|
335
336
|
## 版本更新
|
|
336
337
|
|
|
337
338
|
<details open>
|
|
338
|
-
<summary><b>v2.
|
|
339
|
+
<summary><b>v2.2.x</b></summary>
|
|
339
340
|
|
|
340
|
-
### v2.
|
|
341
|
+
### v2.2.0 · 2026-11-09(B 站素材源 · 扫码登录 · 静默时段面板 · 兼容 DSH 0.2.2)
|
|
341
342
|
|
|
342
|
-
|
|
343
|
+
这版把「你在 B 站看什么」变成了心跳的素材来源,顺手把登录和静默时段都挪进了面板。
|
|
343
344
|
|
|
344
|
-
-
|
|
345
|
-
-
|
|
346
|
-
-
|
|
347
|
-
-
|
|
348
|
-
-
|
|
349
|
-
-
|
|
350
|
-
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
> ⚠️ **升级提示:v2.1.1 存在渲染回归,建议直接跳过 v2.1.1 安装 v2.1.2。** v2.1.1 的面板槽位 key 只注册了 npm 全名 `@kanadego/dsh-heartbeat`,`file:` / 本地安装方式下宿主报的 bundle 名是短名 `dsh-heartbeat`,两者对不上时详情页整块配置区不会渲染(issue #8 跟进)。直接升级到 v2.1.2 即可恢复。
|
|
355
|
-
|
|
356
|
-
- **面板槽位 key 改为双注册**:`plugins.bundle.config` 同一组件同时以 `dsh-heartbeat` 与 `@kanadego/dsh-heartbeat` 两个 key 注册,npm 安装与本地安装两种方式下面板都不再消失;`scripts/panel-smoke.mjs` 冒烟断言同步覆盖双 key。
|
|
357
|
-
|
|
358
|
-
### v2.1.1 · 2026-11-04(修复:原生面板在 DSH 0.2.1-rc.3+ 详情页完全不显示)
|
|
359
|
-
|
|
360
|
-
- **面板槽位 key 改回全名**:`plugins.bundle.config` 的注册 key 误用短名 `dsh-heartbeat`,而宿主 plugin-manager 按 npm 全名 `@kanadego/dsh-heartbeat`(manifest dependencies 的 key)判定是否渲染插件详情页的配置区——key 对不上,面板「装了但看不见」(issue #8)。v2.1.1 把 key 改回 `@kanadego/dsh-heartbeat` 并同步修正冒烟断言;v2.1.0 的「必须用短名」结论是反的,见 CHANGELOG v2.1.0 段订正。
|
|
345
|
+
- **B 站观看历史进素材池**:开启后每 2 小时拉一次观看历史,挑真正在看的(短视频、直播间、刚点开就划走的都不要),变成「他刚看完《…》」「《…》他看到第 12 分钟」这样的素材。同一个视频一天内不会重复进池,素材两天后自动过期。账号只读,不点赞、不评论、不改任何东西。
|
|
346
|
+
- **扫码登录**:终端里一条 `heartbeat bili login` 出二维码,手机 B 站 App 扫一下就登好;登录态加密存在本地,跟账号密码无关。
|
|
347
|
+
- **素材 tab 里多了账号卡片**:不用开终端——面板里点「扫码登录」,弹层显示二维码,扫完自动关闭,状态和上次登录时间一直在卡片上。
|
|
348
|
+
- **静默时段能在面板改**:设置里新增起止两个时间框,保存立刻生效,不用重启。以前这个值只能改文件、还要重启才认。
|
|
349
|
+
- **投递不再对着空气说话**:把已归档的会话从投递目标里排除了,全部目标都归档时会如实记下,而不是空转一轮。
|
|
350
|
+
- **静默原因说人话**:日志里不再把「门没开」一律写成「模型说了英文」——被拦截、没吐字、真的说了英文,三种分开记。
|
|
351
|
+
- **时间注入不再漏进引擎室**:心跳自己的反刍 / 闲逛轮次不会再被塞一句「当前本地时间…」。
|
|
352
|
+
- **Linux 上不会一点就崩**:在 Linux 点开账本或摘抄本,以前会因为找不到 Windows 的打开命令把整个 DSH 带崩,现在按平台来;同一处修复也让 Linux 上的 CLI 命令恢复正常输出。
|
|
353
|
+
- **兼容 DSH 0.2.2**:0.2.2 改了工具声明的下发时机,首轮请求可能抢在工具挂好之前,现在引擎室会先等工具就位再开口。
|
|
361
354
|
|
|
362
355
|
</details>
|
|
363
356
|
|
|
364
|
-
> v2.
|
|
357
|
+
> v2.1.x 及更早的更新记录已移至 [CHANGELOG.md](CHANGELOG.md)(README 这里只保留当前大版本 v2.2.x,插件市场的「更新内容」读的就是这一节)。
|
|
365
358
|
|
|
366
359
|
|
|
367
360
|
|
package/client.js
CHANGED
|
@@ -86,6 +86,10 @@ const PANEL_CSS = [
|
|
|
86
86
|
".hb-ok{font-size:12px;color:#2fbf7f;border:1px solid rgba(61,220,151,.5);border-radius:9px;padding:6px 10px;word-break:break-all;background:rgba(61,220,151,.08)}",
|
|
87
87
|
".hb-scroll{max-height:340px;overflow-y:auto;padding:2px}",
|
|
88
88
|
".hb-pre{margin:0;font-family:ui-monospace,Consolas,monospace;font-size:11px;line-height:1.6;white-space:pre-wrap;word-break:break-word;max-height:320px;overflow:auto;border-radius:9px;padding:8px 10px;background:rgba(127,127,127,.10)}",
|
|
89
|
+
// B站扫码登录弹层(v2.3.0):全屏半透明遮罩 + 居中小卡,二维码放白底上保证对比度
|
|
90
|
+
".hb-modalMask{position:fixed;inset:0;z-index:1000;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,.45)}",
|
|
91
|
+
".hb-modal{display:flex;flex-direction:column;align-items:center;gap:10px;max-width:320px;padding:18px 20px;border-radius:14px;border:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.25));background:var(--dsw-alias-bg-layer-1,#fff);box-shadow:0 18px 50px rgba(0,0,0,.35)}",
|
|
92
|
+
".hb-qrImg{width:240px;height:240px;border-radius:8px;background:#fff;padding:8px;box-sizing:border-box}",
|
|
89
93
|
].join("");
|
|
90
94
|
function ensurePanelStyle() {
|
|
91
95
|
try {
|
|
@@ -178,9 +182,29 @@ const LOCALE_NS = "heartbeat";
|
|
|
178
182
|
"seeds.hintTopic": "浏览流、手写、画像喂进来的:随机挑,可重复用",
|
|
179
183
|
"seeds.emptyArchived": "(这类还没有归档条目)",
|
|
180
184
|
"seeds.empty": "(这类还没有条目)",
|
|
185
|
+
"seeds.filterPlaceholder": "关键字过滤(匹配 文本 / 标签 / 来源)",
|
|
186
|
+
"seeds.filterClear": "清除",
|
|
187
|
+
"seeds.filterNoMatch": "没有匹配关键字的条目,换个词试试",
|
|
188
|
+
"seeds.filterHint": "过滤后剩 {n} 条",
|
|
189
|
+
"seeds.usedCount": "已用 {n} 次",
|
|
181
190
|
"seeds.restore": "恢复",
|
|
182
191
|
"seeds.archive": "归档",
|
|
183
192
|
"seeds.used": " used:{used}",
|
|
193
|
+
"bili.sourceTitle": "素材来源",
|
|
194
|
+
"bili.status.loggedIn": "B站 · 已登录(保存于 {time})",
|
|
195
|
+
"bili.status.notLoggedIn": "B站 · 未登录",
|
|
196
|
+
"bili.loginButton": "扫码登录",
|
|
197
|
+
"bili.reloginButton": "重新登录",
|
|
198
|
+
"bili.state.starting": "正在获取二维码…",
|
|
199
|
+
"bili.state.waiting": "等待扫码…",
|
|
200
|
+
"bili.state.scanned": "已扫码,请在手机上确认",
|
|
201
|
+
"bili.state.success": "登录成功",
|
|
202
|
+
"bili.state.expired": "二维码已过期,请重新获取",
|
|
203
|
+
"bili.state.error": "登录失败",
|
|
204
|
+
"bili.state.errorDetail": "失败原因:{error}",
|
|
205
|
+
"bili.qrHeading": "B站扫码登录",
|
|
206
|
+
"bili.qrHint": "用 B站 App 扫码,登录后才能抓取 B站素材",
|
|
207
|
+
"bili.cancel": "取消",
|
|
184
208
|
"interests.added": "已添加",
|
|
185
209
|
"interests.addFailed": "添加失败:{error}",
|
|
186
210
|
"interests.deleted": "已删除",
|
|
@@ -194,6 +218,8 @@ const LOCALE_NS = "heartbeat";
|
|
|
194
218
|
"interests.to": "到",
|
|
195
219
|
"interests.addWindow": "加一个时段",
|
|
196
220
|
"interests.saveWindows": "保存时段",
|
|
221
|
+
"interests.stats": "当前兴趣 {n} 条 · 浏览时段 {m} 个",
|
|
222
|
+
"interests.statsNote": "面板暂无法区分出厂默认与已改过(接口未返回该标记),以上为当前生效条数",
|
|
197
223
|
"profile.tabInterest": "兴趣",
|
|
198
224
|
"profile.tabProjects": "进行中",
|
|
199
225
|
"profile.tabComm": "沟通偏好",
|
|
@@ -213,12 +239,16 @@ const LOCALE_NS = "heartbeat";
|
|
|
213
239
|
"profile.stale": " 久未验证",
|
|
214
240
|
"profile.updated": " 更新 {date}",
|
|
215
241
|
"profile.exportMarkdown": "导出 Markdown",
|
|
242
|
+
"profile.expand": "展开全文",
|
|
243
|
+
"profile.collapse": "收起",
|
|
216
244
|
"config.saved": "已保存(即时生效,无需重启)",
|
|
217
245
|
"config.saveFailed": "保存失败:{error}",
|
|
218
246
|
"config.interval": "心跳间隔(分钟)",
|
|
219
247
|
"config.cap": "每日表达上限(条)",
|
|
220
248
|
"config.timeInject": "时间注入间隔(分钟)",
|
|
221
249
|
"config.timeInjectOff": "0 = 关闭",
|
|
250
|
+
"config.quietHours": "静默时段",
|
|
251
|
+
"config.quietHoursHint": "这段时间内不主动出声;保存后下一跳生效",
|
|
222
252
|
"config.statusbar": "状态栏",
|
|
223
253
|
"config.statusbarHint": "日常会话中的心跳状态感知(会额外消耗token)",
|
|
224
254
|
"config.idle": "闲着模式",
|
|
@@ -235,8 +265,19 @@ const LOCALE_NS = "heartbeat";
|
|
|
235
265
|
"config.focusPaused": "已暂停至 {clock}",
|
|
236
266
|
"config.focusMinutes": "分钟",
|
|
237
267
|
"config.focusFailed": "操作失败:{error}",
|
|
268
|
+
"config.group.rhythm": "节律",
|
|
269
|
+
"config.group.rhythmDesc": "心跳多久跳一次、一天最多说几条。",
|
|
270
|
+
"config.group.time": "时间与状态栏",
|
|
271
|
+
"config.group.timeDesc": "给日常会话注入精确时间、在会话里挂一条心跳状态。",
|
|
272
|
+
"config.group.express": "表达",
|
|
273
|
+
"config.group.expressDesc": "心跳说话的方式与开销。",
|
|
274
|
+
"config.group.focus": "专注模式",
|
|
275
|
+
"config.group.focusDesc": "需要安静时手动暂停心跳,到点自动恢复。它是即时生效的独立开关:点按钮立刻暂停/恢复,不走下面的「保存」。",
|
|
276
|
+
"config.effect.now": "多久生效:保存后定时器立刻按新间隔重排,下一次心跳就按新间隔走(无需重启)。",
|
|
277
|
+
"config.effect.next": "多久生效:保存后从下一跳开始生效(无需重启)。",
|
|
238
278
|
"weekly.intro": "每 7 天生成一份:本周表达与静默、新认识、账本、素材池与活跃高峰。报告只陈述事实,由后台「心跳」署名。",
|
|
239
279
|
"weekly.empty": "(还没有周报——装好一周后自动出第一期)",
|
|
280
|
+
"weekly.showBody": "展开查看报告正文",
|
|
240
281
|
"migrate.processing": "处理中…",
|
|
241
282
|
"migrate.failed": "失败:{error}",
|
|
242
283
|
"migrate.pwMismatch": "两次口令不一致或为空",
|
|
@@ -252,6 +293,8 @@ const LOCALE_NS = "heartbeat";
|
|
|
252
293
|
"migrate.filePlaceholder": "迁移包完整路径(.hbmig)",
|
|
253
294
|
"migrate.pwPlaceholderShort": "口令",
|
|
254
295
|
"migrate.importButton": "导入",
|
|
296
|
+
"migrate.confirmImport": "确认导入(覆盖本机数据)",
|
|
297
|
+
"migrate.confirmHint": "⚠ 危险操作:导入会用迁移包覆盖本机的心跳数据(被替换的文件会自动备份)。确认路径和口令无误后,再点一次「确认导入」才会执行。",
|
|
255
298
|
"section.status": "心跳状态",
|
|
256
299
|
"section.sessions": "会话绑定",
|
|
257
300
|
"section.seeds": "素材池",
|
|
@@ -359,9 +402,29 @@ const LOCALE_NS = "heartbeat";
|
|
|
359
402
|
"seeds.hintTopic": "From browsing, handwriting, and the profile: picked at random and reusable",
|
|
360
403
|
"seeds.emptyArchived": "(No archived entries of this kind yet)",
|
|
361
404
|
"seeds.empty": "(No entries of this kind yet)",
|
|
405
|
+
"seeds.filterPlaceholder": "Keyword filter (matches text / tag / source)",
|
|
406
|
+
"seeds.filterClear": "Clear",
|
|
407
|
+
"seeds.filterNoMatch": "No entries match this keyword — try another word",
|
|
408
|
+
"seeds.filterHint": "{n} entries after filtering",
|
|
409
|
+
"seeds.usedCount": "Used {n} times",
|
|
362
410
|
"seeds.restore": "Restore",
|
|
363
411
|
"seeds.archive": "Archive",
|
|
364
412
|
"seeds.used": " used: {used}",
|
|
413
|
+
"bili.sourceTitle": "Material sources",
|
|
414
|
+
"bili.status.loggedIn": "Bilibili · logged in (saved {time})",
|
|
415
|
+
"bili.status.notLoggedIn": "Bilibili · not logged in",
|
|
416
|
+
"bili.loginButton": "Scan to log in",
|
|
417
|
+
"bili.reloginButton": "Log in again",
|
|
418
|
+
"bili.state.starting": "Fetching QR code…",
|
|
419
|
+
"bili.state.waiting": "Waiting for scan…",
|
|
420
|
+
"bili.state.scanned": "Scanned — confirm on your phone",
|
|
421
|
+
"bili.state.success": "Logged in",
|
|
422
|
+
"bili.state.expired": "QR code expired — please start again",
|
|
423
|
+
"bili.state.error": "Login failed",
|
|
424
|
+
"bili.state.errorDetail": "Reason: {error}",
|
|
425
|
+
"bili.qrHeading": "Bilibili QR login",
|
|
426
|
+
"bili.qrHint": "Scan with the Bilibili app; the login is used for fetching Bilibili material",
|
|
427
|
+
"bili.cancel": "Cancel",
|
|
365
428
|
"interests.added": "Added",
|
|
366
429
|
"interests.addFailed": "Failed to add: {error}",
|
|
367
430
|
"interests.deleted": "Deleted",
|
|
@@ -375,6 +438,8 @@ const LOCALE_NS = "heartbeat";
|
|
|
375
438
|
"interests.to": "to",
|
|
376
439
|
"interests.addWindow": "Add a window",
|
|
377
440
|
"interests.saveWindows": "Save windows",
|
|
441
|
+
"interests.stats": "{n} interests · {m} browsing windows",
|
|
442
|
+
"interests.statsNote": "The panel cannot tell factory defaults from edited entries (the API does not expose that marker); the counts above are what is currently in effect",
|
|
378
443
|
"profile.tabInterest": "Interests",
|
|
379
444
|
"profile.tabProjects": "In progress",
|
|
380
445
|
"profile.tabComm": "Communication preferences",
|
|
@@ -394,12 +459,16 @@ const LOCALE_NS = "heartbeat";
|
|
|
394
459
|
"profile.stale": " · not verified for a while",
|
|
395
460
|
"profile.updated": " · updated {date}",
|
|
396
461
|
"profile.exportMarkdown": "Export Markdown",
|
|
462
|
+
"profile.expand": "Show full text",
|
|
463
|
+
"profile.collapse": "Collapse",
|
|
397
464
|
"config.saved": "Saved (takes effect immediately, no restart needed)",
|
|
398
465
|
"config.saveFailed": "Failed to save: {error}",
|
|
399
466
|
"config.interval": "Heartbeat interval (minutes)",
|
|
400
467
|
"config.cap": "Daily expression limit",
|
|
401
468
|
"config.timeInject": "Time injection interval (minutes)",
|
|
402
469
|
"config.timeInjectOff": "0 = off",
|
|
470
|
+
"config.quietHours": "Quiet hours",
|
|
471
|
+
"config.quietHoursHint": "No proactive messages during this window; takes effect on the next beat after saving",
|
|
403
472
|
"config.statusbar": "Status bar",
|
|
404
473
|
"config.statusbarHint": "Show heartbeat status in everyday conversations (uses extra tokens)",
|
|
405
474
|
"config.idle": "Idle mode",
|
|
@@ -416,8 +485,19 @@ const LOCALE_NS = "heartbeat";
|
|
|
416
485
|
"config.focusPaused": "Paused until {clock}",
|
|
417
486
|
"config.focusMinutes": "min",
|
|
418
487
|
"config.focusFailed": "Failed: {error}",
|
|
488
|
+
"config.group.rhythm": "Rhythm",
|
|
489
|
+
"config.group.rhythmDesc": "How often the heartbeat beats, and how many messages it may send per day.",
|
|
490
|
+
"config.group.time": "Time & status bar",
|
|
491
|
+
"config.group.timeDesc": "Inject precise time into everyday sessions and pin a heartbeat status there.",
|
|
492
|
+
"config.group.express": "Expression",
|
|
493
|
+
"config.group.expressDesc": "How the heartbeat talks, and what it costs.",
|
|
494
|
+
"config.group.focus": "Focus mode",
|
|
495
|
+
"config.group.focusDesc": "Pause the heartbeat manually when you need quiet; it resumes automatically when time is up. This is an instant, independent switch: clicking the button pauses/resumes right away, without going through Save below.",
|
|
496
|
+
"config.effect.now": "When it takes effect: after saving, the timer is rescheduled to the new interval immediately, so the very next heartbeat follows it (no restart needed).",
|
|
497
|
+
"config.effect.next": "When it takes effect: after saving, changes apply from the next heartbeat on (no restart needed).",
|
|
419
498
|
"weekly.intro": "Generated every 7 days: this week's expressions and silences, new acquaintances, ledger, material pool, and activity peaks. The report states facts only and is signed by the background Heartbeat.",
|
|
420
499
|
"weekly.empty": "(No weekly report yet — the first one appears a week after installation)",
|
|
500
|
+
"weekly.showBody": "Show report body",
|
|
421
501
|
"migrate.processing": "Working…",
|
|
422
502
|
"migrate.failed": "Failed: {error}",
|
|
423
503
|
"migrate.pwMismatch": "The two passphrases do not match, or are empty",
|
|
@@ -433,6 +513,8 @@ const LOCALE_NS = "heartbeat";
|
|
|
433
513
|
"migrate.filePlaceholder": "Full path to the migration package (.hbmig)",
|
|
434
514
|
"migrate.pwPlaceholderShort": "Passphrase",
|
|
435
515
|
"migrate.importButton": "Import",
|
|
516
|
+
"migrate.confirmImport": "Confirm import (overwrites local data)",
|
|
517
|
+
"migrate.confirmHint": "⚠ Dangerous operation: importing overwrites this machine's heartbeat data with the migration package (replaced files are backed up automatically). Once the path and passphrase are verified, click Confirm import one more time to proceed.",
|
|
436
518
|
"section.status": "Heartbeat status",
|
|
437
519
|
"section.sessions": "Session bindings",
|
|
438
520
|
"section.seeds": "Material pool",
|
|
@@ -550,6 +632,15 @@ const LOCALE_NS = "heartbeat";
|
|
|
550
632
|
return d.toLocaleString(localeTag(), { hour12: false });
|
|
551
633
|
} catch { return String(iso); }
|
|
552
634
|
};
|
|
635
|
+
// MM-DD HH:mm(本地时区),用于「保存于 …」这类紧凑时间戳
|
|
636
|
+
const fmtMonthDayClock = (ms) => {
|
|
637
|
+
try {
|
|
638
|
+
const d = new Date(ms);
|
|
639
|
+
if (Number.isNaN(d.getTime())) return String(ms);
|
|
640
|
+
const two = (n) => String(n).padStart(2, "0");
|
|
641
|
+
return two(d.getMonth() + 1) + "-" + two(d.getDate()) + " " + two(d.getHours()) + ":" + two(d.getMinutes());
|
|
642
|
+
} catch { return String(ms); }
|
|
643
|
+
};
|
|
553
644
|
|
|
554
645
|
// ── 心跳状态卡片 ──────────────────────────────────────────────
|
|
555
646
|
function StatusCard() {
|
|
@@ -698,17 +789,137 @@ const LOCALE_NS = "heartbeat";
|
|
|
698
789
|
);
|
|
699
790
|
}
|
|
700
791
|
|
|
792
|
+
// ── 素材来源:B站扫码登录(v2.3.0)─────────────────────────────
|
|
793
|
+
// 素材 tab 顶部的登录入口:状态行走 bili.status;扫码流程走
|
|
794
|
+
// bili.login.start 拿 dataURL 二维码(弹层展示),之后每 2 秒
|
|
795
|
+
// bili.login.poll 轮询一次。成功/过期/出错即停表并收起弹层,
|
|
796
|
+
// 成功后刷新登录状态;弹层有「取消」按钮、点遮罩空白也能关。
|
|
797
|
+
// 卸载时清掉轮询定时器。所有文案走 DICT。
|
|
798
|
+
function BiliLoginCard() {
|
|
799
|
+
const [status, setStatus] = React.useState(null);
|
|
800
|
+
const [phase, setPhase] = React.useState("idle"); // idle|starting|waiting|scanned|success|expired|error
|
|
801
|
+
const [errMsg, setErrMsg] = React.useState("");
|
|
802
|
+
const [qrDataUrl, setQrDataUrl] = React.useState(null);
|
|
803
|
+
const [modal, setModal] = React.useState(false);
|
|
804
|
+
const pollTimer = React.useRef(null);
|
|
805
|
+
// 竞态守卫:sessionRef 记当前有效的 sessionId,startSeqRef 给每次 start
|
|
806
|
+
// 发号。连点/旧流程晚归时,过期的 start 结果与 poll 回调一律忽略,
|
|
807
|
+
// 不会误关新弹层。
|
|
808
|
+
const sessionRef = React.useRef(null);
|
|
809
|
+
const startSeqRef = React.useRef(0);
|
|
810
|
+
const stopPolling = React.useCallback(() => {
|
|
811
|
+
if (pollTimer.current !== null) { clearInterval(pollTimer.current); pollTimer.current = null; }
|
|
812
|
+
}, []);
|
|
813
|
+
// 组件卸载:轮询定时器必须跟着走,不留后台请求
|
|
814
|
+
React.useEffect(() => () => stopPolling(), [stopPolling]);
|
|
815
|
+
const reload = React.useCallback(() => {
|
|
816
|
+
rpc("bili.status").then(setStatus, () => setStatus({ loggedIn: false, savedAt: null }));
|
|
817
|
+
}, []);
|
|
818
|
+
React.useEffect(() => { reload(); }, [reload]);
|
|
819
|
+
const closeLogin = (next, message) => {
|
|
820
|
+
stopPolling();
|
|
821
|
+
sessionRef.current = null;
|
|
822
|
+
setQrDataUrl(null);
|
|
823
|
+
setModal(false);
|
|
824
|
+
setPhase(next);
|
|
825
|
+
setErrMsg(message || "");
|
|
826
|
+
if (next === "success") reload();
|
|
827
|
+
};
|
|
828
|
+
// 用户主动放弃:会话留在服务端内存里自然过期,不为此新增 rpc 调用
|
|
829
|
+
const cancelLogin = () => {
|
|
830
|
+
stopPolling();
|
|
831
|
+
startSeqRef.current += 1; // 让在途的 start 结果作废
|
|
832
|
+
sessionRef.current = null;
|
|
833
|
+
setQrDataUrl(null);
|
|
834
|
+
setModal(false);
|
|
835
|
+
setPhase("idle");
|
|
836
|
+
setErrMsg("");
|
|
837
|
+
};
|
|
838
|
+
const startLogin = async () => {
|
|
839
|
+
stopPolling();
|
|
840
|
+
const seq = ++startSeqRef.current;
|
|
841
|
+
setErrMsg("");
|
|
842
|
+
setPhase("starting");
|
|
843
|
+
let v;
|
|
844
|
+
try {
|
|
845
|
+
v = await rpc("bili.login.start");
|
|
846
|
+
} catch (e) {
|
|
847
|
+
if (startSeqRef.current !== seq) return; // 已被更新的启动/取消取代
|
|
848
|
+
setPhase("error");
|
|
849
|
+
setErrMsg(String(e).slice(0, 80));
|
|
850
|
+
return;
|
|
851
|
+
}
|
|
852
|
+
if (startSeqRef.current !== seq) return; // 晚归的旧结果:丢弃
|
|
853
|
+
sessionRef.current = v.sessionId;
|
|
854
|
+
setQrDataUrl(v.qrDataUrl);
|
|
855
|
+
setModal(true);
|
|
856
|
+
setPhase("waiting");
|
|
857
|
+
stopPolling();
|
|
858
|
+
pollTimer.current = setInterval(() => {
|
|
859
|
+
rpc("bili.login.poll", { sessionId: v.sessionId }).then(
|
|
860
|
+
(r) => {
|
|
861
|
+
if (sessionRef.current !== v.sessionId) return; // 非当前会话:忽略
|
|
862
|
+
if (r.state === "waiting" || r.state === "scanned") { setPhase(r.state); return; }
|
|
863
|
+
if (r.state === "success") closeLogin("success");
|
|
864
|
+
else if (r.state === "expired") closeLogin("expired");
|
|
865
|
+
else closeLogin("error", r.message || "");
|
|
866
|
+
},
|
|
867
|
+
(e) => {
|
|
868
|
+
if (sessionRef.current !== v.sessionId) return;
|
|
869
|
+
closeLogin("error", String(e).slice(0, 80));
|
|
870
|
+
},
|
|
871
|
+
);
|
|
872
|
+
}, 2000);
|
|
873
|
+
};
|
|
874
|
+
const loggedIn = !!(status && status.loggedIn);
|
|
875
|
+
const savedAt = status && status.loggedIn && typeof status.savedAt === "number" ? status.savedAt : null;
|
|
876
|
+
const stateLine = status === null ? t("common.loading")
|
|
877
|
+
: loggedIn ? L("bili.status.loggedIn", { time: savedAt !== null ? fmtMonthDayClock(savedAt) : t("common.unknown") })
|
|
878
|
+
: t("bili.status.notLoggedIn");
|
|
879
|
+
const phaseText = phase === "starting" ? t("bili.state.starting")
|
|
880
|
+
: phase === "waiting" ? t("bili.state.waiting")
|
|
881
|
+
: phase === "scanned" ? t("bili.state.scanned")
|
|
882
|
+
: phase === "success" ? t("bili.state.success")
|
|
883
|
+
: phase === "expired" ? t("bili.state.expired")
|
|
884
|
+
: phase === "error" ? t("bili.state.error")
|
|
885
|
+
: null;
|
|
886
|
+
const badgeCls = loggedIn ? "hb-badge hb-badgeOk" : "hb-badge hb-badgeOff";
|
|
887
|
+
return React.createElement(
|
|
888
|
+
"div",
|
|
889
|
+
{ className: "hb-card" },
|
|
890
|
+
React.createElement("div", { className: "hb-cardHead" },
|
|
891
|
+
React.createElement("span", { className: "hb-cardTitle" }, t("bili.sourceTitle")),
|
|
892
|
+
React.createElement("span", { className: badgeCls },
|
|
893
|
+
React.createElement("i", { className: "hb-dot" }),
|
|
894
|
+
stateLine)),
|
|
895
|
+
React.createElement("div", { className: "hb-row" },
|
|
896
|
+
React.createElement("button", {
|
|
897
|
+
className: phase === "starting" ? "hb-btn" : "hb-btn hb-btnPrimary",
|
|
898
|
+
disabled: phase === "starting",
|
|
899
|
+
onClick: () => { void startLogin(); },
|
|
900
|
+
}, loggedIn ? t("bili.reloginButton") : t("bili.loginButton")),
|
|
901
|
+
phaseText ? React.createElement("span", { className: phase === "error" ? "hb-err" : "hb-ok" },
|
|
902
|
+
phase === "error" && errMsg ? L("bili.state.errorDetail", { error: errMsg }) : phaseText) : null),
|
|
903
|
+
modal ? React.createElement(
|
|
904
|
+
"div",
|
|
905
|
+
{ className: "hb-modalMask", onClick: (e) => { if (e.target === e.currentTarget) cancelLogin(); } },
|
|
906
|
+
React.createElement(
|
|
907
|
+
"div",
|
|
908
|
+
{ className: "hb-modal" },
|
|
909
|
+
React.createElement("div", { className: "hb-cardTitle" }, t("bili.qrHeading")),
|
|
910
|
+
React.createElement("img", { className: "hb-qrImg", src: qrDataUrl, alt: t("bili.qrHeading") }),
|
|
911
|
+
React.createElement("div", { className: "hb-hint" },
|
|
912
|
+
phase === "scanned" ? t("bili.state.scanned") : t("bili.state.waiting")),
|
|
913
|
+
React.createElement("div", { className: "hb-hint" }, t("bili.qrHint")),
|
|
914
|
+
React.createElement("button", { className: "hb-btn", onClick: cancelLogin }, t("bili.cancel")),
|
|
915
|
+
),
|
|
916
|
+
) : null,
|
|
917
|
+
);
|
|
918
|
+
}
|
|
919
|
+
|
|
701
920
|
// ── 素材池(v1.9.3 三版):话题 / 聊天 × 活跃 / 归档,四个按钮各看一类 ──
|
|
702
921
|
// 和画像分区同一套 tab 交互,风格统一;一次只看一类。
|
|
703
922
|
function SeedsSection() {
|
|
704
|
-
// 面板版新增文案(不改 DICT,仅本函数使用)
|
|
705
|
-
const TXT = {
|
|
706
|
-
filterPlaceholder: "关键字过滤(匹配 文本 / 标签 / 来源)",
|
|
707
|
-
filterClear: "清除",
|
|
708
|
-
filterNoMatch: "没有匹配关键字的条目,换个词试试",
|
|
709
|
-
filterHint: (n) => "过滤后剩 " + n + " 条",
|
|
710
|
-
used: (n) => "已用 " + n + " 次",
|
|
711
|
-
};
|
|
712
923
|
const [data, setData] = React.useState(null);
|
|
713
924
|
const [error, setError] = React.useState(null);
|
|
714
925
|
const [tab, setTab] = React.useState("topic");
|
|
@@ -730,7 +941,7 @@ const LOCALE_NS = "heartbeat";
|
|
|
730
941
|
React.createElement("div", { style: { display: "flex", alignItems: "center", gap: 6, flexWrap: "wrap", marginBottom: 2 } },
|
|
731
942
|
React.createElement("span", { style: chip }, String(s.tag)),
|
|
732
943
|
React.createElement("span", { style: chip }, String(s.source)),
|
|
733
|
-
React.createElement("span", { style: hintStyle },
|
|
944
|
+
React.createElement("span", { style: hintStyle }, t("seeds.usedCount", { n: s.used || 0 })),
|
|
734
945
|
),
|
|
735
946
|
React.createElement("div", { style: { fontSize: 12.5, wordBreak: "break-word", color: "var(--dsw-alias-label-secondary)" }, title: s.text },
|
|
736
947
|
String(s.text || "").length > 80 ? String(s.text).slice(0, 80) + "…" : String(s.text || "")),
|
|
@@ -771,8 +982,8 @@ const LOCALE_NS = "heartbeat";
|
|
|
771
982
|
null,
|
|
772
983
|
React.createElement("div", { style: hintStyle }, L("seeds.activeSummary", { active: data.active.length, cap: data.cap, archived: data.archived.length })),
|
|
773
984
|
React.createElement("div", { style: rowStyle },
|
|
774
|
-
React.createElement("input", { style: { ...inputStyle, width: "100%", boxSizing: "border-box" }, placeholder:
|
|
775
|
-
kw ? React.createElement("button", { style: buttonGhost, onClick: () => setFilter("") },
|
|
985
|
+
React.createElement("input", { style: { ...inputStyle, width: "100%", boxSizing: "border-box" }, placeholder: t("seeds.filterPlaceholder"), value: filter, onChange: (e) => setFilter(e.target.value) }),
|
|
986
|
+
kw ? React.createElement("button", { style: buttonGhost, onClick: () => setFilter("") }, t("seeds.filterClear")) : null,
|
|
776
987
|
),
|
|
777
988
|
React.createElement("div", { style: tabRow },
|
|
778
989
|
tabButton("topic", t("seeds.tabTopic"), topics.length),
|
|
@@ -786,9 +997,9 @@ const LOCALE_NS = "heartbeat";
|
|
|
786
997
|
? React.createElement("div", { style: hintStyle },
|
|
787
998
|
categoryEmpty
|
|
788
999
|
? (archived ? t("seeds.emptyArchived") : t("seeds.empty"))
|
|
789
|
-
:
|
|
1000
|
+
: t("seeds.filterNoMatch"))
|
|
790
1001
|
: React.createElement("div", { style: scrollBox },
|
|
791
|
-
kw ? React.createElement("div", { style: { ...hintStyle, padding: "2px 0" } },
|
|
1002
|
+
kw ? React.createElement("div", { style: { ...hintStyle, padding: "2px 0" } }, t("seeds.filterHint", { n: list.length })) : null,
|
|
792
1003
|
list.map((s) => row(s, archived))),
|
|
793
1004
|
);
|
|
794
1005
|
}
|
|
@@ -797,12 +1008,6 @@ const LOCALE_NS = "heartbeat";
|
|
|
797
1008
|
// 首编继承出厂:第一次增删/存时段时,插件自动把出厂 interests.json
|
|
798
1009
|
// 完整复制进 data/settings/interests.json,之后卡片就是唯一入口。
|
|
799
1010
|
function InterestsSection() {
|
|
800
|
-
// 面板版新增文案(不改 DICT,仅本函数使用)
|
|
801
|
-
const TXT = {
|
|
802
|
-
stats: (n, m) => "当前兴趣 " + n + " 条 · 浏览时段 " + m + " 个",
|
|
803
|
-
// 如实说明:rpc 没有返回「出厂默认 / 已改过」标记字段,只能显示当前生效条数
|
|
804
|
-
statsNote: "面板暂无法区分出厂默认与已改过(接口未返回该标记),以上为当前生效条数",
|
|
805
|
-
};
|
|
806
1011
|
const [data, setData] = React.useState(null);
|
|
807
1012
|
const [error, setError] = React.useState(null);
|
|
808
1013
|
const [status, setStatus] = React.useState("");
|
|
@@ -843,8 +1048,8 @@ const LOCALE_NS = "heartbeat";
|
|
|
843
1048
|
"div",
|
|
844
1049
|
null,
|
|
845
1050
|
React.createElement("div", { style: { ...hintStyle, fontWeight: 600, color: "var(--dsw-alias-label-secondary)" } },
|
|
846
|
-
|
|
847
|
-
React.createElement("div", { style: hintStyle },
|
|
1051
|
+
t("interests.stats", { n: interests.length, m: windowsCount })),
|
|
1052
|
+
React.createElement("div", { style: hintStyle }, t("interests.statsNote")),
|
|
848
1053
|
React.createElement("div", { style: hintStyle }, t("interests.hint")),
|
|
849
1054
|
interests.map((item) => React.createElement("div", { key: item, style: rowList },
|
|
850
1055
|
React.createElement("span", { style: { flex: 1, fontSize: 12 } }, item),
|
|
@@ -892,8 +1097,6 @@ const LOCALE_NS = "heartbeat";
|
|
|
892
1097
|
// 「引擎室输入」视图。新增:单条正文过长(约超 4 行)时默认收起,
|
|
893
1098
|
// 点「展开全文」看全文;刷新 / 导出按钮保留。
|
|
894
1099
|
function ProfileSection() {
|
|
895
|
-
// 面板版新增文案(不改 DICT,仅本函数使用)
|
|
896
|
-
const TXT = { expand: "展开全文", collapse: "收起" };
|
|
897
1100
|
const [data, setData] = React.useState(null);
|
|
898
1101
|
const [digest, setDigest] = React.useState(null);
|
|
899
1102
|
const [tab, setTab] = React.useState("interest");
|
|
@@ -940,7 +1143,7 @@ const LOCALE_NS = "heartbeat";
|
|
|
940
1143
|
isLong(e.content) ? React.createElement("button", {
|
|
941
1144
|
style: { ...buttonGhost, height: 20, fontSize: 11, padding: "0 8px", marginTop: 2 },
|
|
942
1145
|
onClick: () => setExpanded((m) => ({ ...m, [key]: !open })),
|
|
943
|
-
}, open ?
|
|
1146
|
+
}, open ? t("profile.collapse") : t("profile.expand")) : null,
|
|
944
1147
|
);
|
|
945
1148
|
};
|
|
946
1149
|
const om = (digest && digest.omitted) || { tact: 0, topic: 0, wander: 0 };
|
|
@@ -994,6 +1197,9 @@ const LOCALE_NS = "heartbeat";
|
|
|
994
1197
|
const idleMode = !!value && value.idleMode === true;
|
|
995
1198
|
const tokenSaver = !!value && value.tokenSaver === true;
|
|
996
1199
|
const psyEnabled = !!value && value.psyEnabled === true;
|
|
1200
|
+
// 静默时段(v2.2):policy 用户层字段(gate.quietHours),保存后下一跳生效。
|
|
1201
|
+
const quietStart = value && typeof value.quietStart === "string" ? value.quietStart : "01:30";
|
|
1202
|
+
const quietEnd = value && typeof value.quietEnd === "string" ? value.quietEnd : "06:30";
|
|
997
1203
|
const [draftInterval, setDraftInterval] = React.useState(interval);
|
|
998
1204
|
const [draftCap, setDraftCap] = React.useState(cap);
|
|
999
1205
|
const [draftTimeInject, setDraftTimeInject] = React.useState(timeInject);
|
|
@@ -1001,22 +1207,16 @@ const LOCALE_NS = "heartbeat";
|
|
|
1001
1207
|
const [draftIdle, setDraftIdle] = React.useState(idleMode);
|
|
1002
1208
|
const [draftTokenSaver, setDraftTokenSaver] = React.useState(tokenSaver);
|
|
1003
1209
|
const [draftPsy, setDraftPsy] = React.useState(psyEnabled);
|
|
1210
|
+
const [draftQuietStart, setDraftQuietStart] = React.useState(quietStart);
|
|
1211
|
+
const [draftQuietEnd, setDraftQuietEnd] = React.useState(quietEnd);
|
|
1004
1212
|
const [status, setStatus] = React.useState("");
|
|
1005
|
-
React.useEffect(() => { setDraftInterval(interval); setDraftCap(cap); setDraftTimeInject(timeInject); setDraftStatusbar(statusbar); setDraftIdle(idleMode); setDraftTokenSaver(tokenSaver); setDraftPsy(psyEnabled); }, [interval, cap, timeInject, statusbar, idleMode, tokenSaver, psyEnabled]);
|
|
1006
|
-
// v2.1.0
|
|
1007
|
-
const GROUP_RHYTHM = "节律";
|
|
1008
|
-
const GROUP_RHYTHM_DESC = "心跳多久跳一次、一天最多说几条。";
|
|
1009
|
-
const GROUP_TIME = "时间与状态栏";
|
|
1010
|
-
const GROUP_TIME_DESC = "给日常会话注入精确时间、在会话里挂一条心跳状态。";
|
|
1011
|
-
const GROUP_EXPRESS = "表达";
|
|
1012
|
-
const GROUP_EXPRESS_DESC = "心跳说话的方式与开销。";
|
|
1013
|
-
const GROUP_FOCUS = "专注模式";
|
|
1014
|
-
const GROUP_FOCUS_DESC = "需要安静时手动暂停心跳,到点自动恢复。它是即时生效的独立开关:点按钮立刻暂停/恢复,不走下面的「保存」。";
|
|
1213
|
+
React.useEffect(() => { setDraftInterval(interval); setDraftCap(cap); setDraftTimeInject(timeInject); setDraftStatusbar(statusbar); setDraftIdle(idleMode); setDraftTokenSaver(tokenSaver); setDraftPsy(psyEnabled); setDraftQuietStart(quietStart); setDraftQuietEnd(quietEnd); }, [interval, cap, timeInject, statusbar, idleMode, tokenSaver, psyEnabled, quietStart, quietEnd]);
|
|
1214
|
+
// v2.1.0 面板改造:分组小节文案走 DICT 的 config.group.*。
|
|
1015
1215
|
// 「多久生效」依据 src/rpc.ts 的 config.set 实现判定:
|
|
1016
1216
|
// intervalMin → applyHeartbeatInterval 立即重排定时器(保存后立刻生效);
|
|
1017
1217
|
// 其余字段写入活引用/运行时 policy,每跳判定时读取(下一跳生效)。详见 manifest.md。
|
|
1018
|
-
const EFFECT_NOW = "
|
|
1019
|
-
const EFFECT_NEXT = "
|
|
1218
|
+
const EFFECT_NOW = t("config.effect.now");
|
|
1219
|
+
const EFFECT_NEXT = t("config.effect.next");
|
|
1020
1220
|
// 专注模式(v2.1.0 ①):即时动作,不走「保存」,和上面那堆参数分开。
|
|
1021
1221
|
// 状态取 rpc 合并值(内存 + data/focus.json),所以 CLI 设的暂停这里也看得见。
|
|
1022
1222
|
const [focus, setFocus] = React.useState(null);
|
|
@@ -1055,6 +1255,8 @@ const LOCALE_NS = "heartbeat";
|
|
|
1055
1255
|
idleMode: !!draftIdle,
|
|
1056
1256
|
tokenSaver: !!draftTokenSaver,
|
|
1057
1257
|
psyEnabled: !!draftPsy,
|
|
1258
|
+
quietStart: draftQuietStart,
|
|
1259
|
+
quietEnd: draftQuietEnd,
|
|
1058
1260
|
});
|
|
1059
1261
|
setValue(v);
|
|
1060
1262
|
setStatus(t("config.saved"));
|
|
@@ -1083,7 +1285,7 @@ const LOCALE_NS = "heartbeat";
|
|
|
1083
1285
|
"div",
|
|
1084
1286
|
null,
|
|
1085
1287
|
// ── 节律 ──
|
|
1086
|
-
groupTitle(
|
|
1288
|
+
groupTitle(t("config.group.rhythm"), t("config.group.rhythmDesc")),
|
|
1087
1289
|
paramRow(t("config.interval"),
|
|
1088
1290
|
React.createElement("input", { style: inputStyle, type: "number", min: 1, max: 1440, value: draftInterval, onChange: (e) => setDraftInterval(e.target.value) }),
|
|
1089
1291
|
null, EFFECT_NOW),
|
|
@@ -1091,18 +1293,26 @@ const LOCALE_NS = "heartbeat";
|
|
|
1091
1293
|
React.createElement("input", { style: inputStyle, type: "number", min: 1, max: 50, value: draftCap, onChange: (e) => setDraftCap(e.target.value) }),
|
|
1092
1294
|
null, EFFECT_NEXT),
|
|
1093
1295
|
// ── 时间与状态栏 ──
|
|
1094
|
-
groupTitle(
|
|
1296
|
+
groupTitle(t("config.group.time"), t("config.group.timeDesc")),
|
|
1095
1297
|
paramRow(t("config.timeInject"),
|
|
1096
1298
|
React.createElement("input", { style: inputStyle, type: "number", min: 0, max: 1440, value: draftTimeInject, onChange: (e) => setDraftTimeInject(e.target.value) }),
|
|
1097
1299
|
t("config.timeInjectOff"), EFFECT_NEXT),
|
|
1300
|
+
paramRow(t("config.quietHours"),
|
|
1301
|
+
React.createElement(
|
|
1302
|
+
"span",
|
|
1303
|
+
null,
|
|
1304
|
+
React.createElement("input", { style: inputStyle, type: "time", value: draftQuietStart, onChange: (e) => setDraftQuietStart(e.target.value) }),
|
|
1305
|
+
"–",
|
|
1306
|
+
React.createElement("input", { style: inputStyle, type: "time", value: draftQuietEnd, onChange: (e) => setDraftQuietEnd(e.target.value) })),
|
|
1307
|
+
t("config.quietHoursHint"), EFFECT_NEXT),
|
|
1098
1308
|
paramRow(t("config.statusbar"), toggleBtn(draftStatusbar, setDraftStatusbar), t("config.statusbarHint"), EFFECT_NEXT),
|
|
1099
1309
|
// ── 表达 ──
|
|
1100
|
-
groupTitle(
|
|
1310
|
+
groupTitle(t("config.group.express"), t("config.group.expressDesc")),
|
|
1101
1311
|
paramRow(t("config.tokenSaver"), toggleBtn(draftTokenSaver, setDraftTokenSaver), t("config.tokenSaverHint"), EFFECT_NEXT),
|
|
1102
1312
|
paramRow(t("config.psy"), toggleBtn(draftPsy, setDraftPsy), t("config.psyHint"), EFFECT_NEXT),
|
|
1103
1313
|
paramRow(t("config.idle"), toggleBtn(draftIdle, setDraftIdle), t("config.idleHint"), EFFECT_NEXT),
|
|
1104
1314
|
// ── 专注模式:即时动作,不进 draft 体系 ──
|
|
1105
|
-
groupTitle(
|
|
1315
|
+
groupTitle(t("config.group.focus"), t("config.group.focusDesc")),
|
|
1106
1316
|
React.createElement("div", { style: rowStyle },
|
|
1107
1317
|
React.createElement("span", { style: labelStyle }, t("config.focus")),
|
|
1108
1318
|
React.createElement("input", { style: inputStyle, type: "number", min: 1, max: 1440, value: draftFocusMin, onChange: (e) => setDraftFocusMin(e.target.value) }),
|
|
@@ -1127,7 +1337,6 @@ const LOCALE_NS = "heartbeat";
|
|
|
1127
1337
|
const [selected, setSelected] = React.useState("");
|
|
1128
1338
|
const [text, setText] = React.useState(null);
|
|
1129
1339
|
// v2.1.0 面板改造:正文收进「展开查看」折叠块,默认收起;列表与加载逻辑原样保留。
|
|
1130
|
-
const WEEKLY_SHOW = "展开查看报告正文";
|
|
1131
1340
|
const loadReport = React.useCallback((file) => {
|
|
1132
1341
|
setSelected(file);
|
|
1133
1342
|
rpc("weekly.get", { file }).then((r) => setText(r.text), (e) => setError(String(e).slice(0, 100)));
|
|
@@ -1158,7 +1367,7 @@ const LOCALE_NS = "heartbeat";
|
|
|
1158
1367
|
}, r.end.slice(0, 10))),
|
|
1159
1368
|
) : null,
|
|
1160
1369
|
text ? React.createElement("details", { style: { margin: "4px 0" } },
|
|
1161
|
-
React.createElement("summary", { style: summaryStyle },
|
|
1370
|
+
React.createElement("summary", { style: summaryStyle }, t("weekly.showBody")),
|
|
1162
1371
|
React.createElement("pre", { style: { whiteSpace: "pre-wrap", margin: "4px 0", fontSize: 12 } }, text),
|
|
1163
1372
|
) : null,
|
|
1164
1373
|
React.createElement("div", { style: rowStyle },
|
|
@@ -1178,8 +1387,6 @@ const LOCALE_NS = "heartbeat";
|
|
|
1178
1387
|
const busy = React.useRef(false);
|
|
1179
1388
|
// v2.1.0 面板改造:导入是危险操作(会用迁移包覆盖本机数据),加二次确认——
|
|
1180
1389
|
// 第一次点只亮红色确认态并提示,再点一次才真正执行。
|
|
1181
|
-
const IMPORT_CONFIRM_LABEL = "确认导入(覆盖本机数据)";
|
|
1182
|
-
const IMPORT_CONFIRM_HINT = "⚠ 危险操作:导入会用迁移包覆盖本机的心跳数据(被替换的文件会自动备份)。确认路径和口令无误后,再点一次「确认导入」才会执行。";
|
|
1183
1390
|
const [confirmImport, setConfirmImport] = React.useState(false);
|
|
1184
1391
|
const run = (fn) => {
|
|
1185
1392
|
if (busy.current) return;
|
|
@@ -1202,7 +1409,7 @@ const LOCALE_NS = "heartbeat";
|
|
|
1202
1409
|
const onImportClick = () => {
|
|
1203
1410
|
if (!confirmImport) {
|
|
1204
1411
|
setConfirmImport(true);
|
|
1205
|
-
setStatus(
|
|
1412
|
+
setStatus(t("migrate.confirmHint"));
|
|
1206
1413
|
return;
|
|
1207
1414
|
}
|
|
1208
1415
|
setConfirmImport(false);
|
|
@@ -1223,7 +1430,7 @@ const LOCALE_NS = "heartbeat";
|
|
|
1223
1430
|
React.createElement("input", { style: { ...inputStyle, width: 220 }, placeholder: t("migrate.filePlaceholder"), value: importFile, onChange: (e) => { setImportFile(e.target.value); setConfirmImport(false); } }),
|
|
1224
1431
|
React.createElement("input", { style: inputStyle, type: "password", placeholder: t("migrate.pwPlaceholderShort"), value: importPw, onChange: (e) => { setImportPw(e.target.value); setConfirmImport(false); } }),
|
|
1225
1432
|
confirmImport
|
|
1226
|
-
? React.createElement("button", { style: { ...buttonStyle, background: "#e5484d" }, onClick: onImportClick },
|
|
1433
|
+
? React.createElement("button", { style: { ...buttonStyle, background: "#e5484d" }, onClick: onImportClick }, t("migrate.confirmImport"))
|
|
1227
1434
|
: React.createElement("button", { style: buttonStyle, onClick: onImportClick }, t("migrate.importButton")),
|
|
1228
1435
|
),
|
|
1229
1436
|
status ? React.createElement("div", { style: hintStyle }, status) : null,
|
|
@@ -1307,7 +1514,12 @@ const LOCALE_NS = "heartbeat";
|
|
|
1307
1514
|
React.createElement("div", { className: "hb-body" },
|
|
1308
1515
|
tab === "status" ? React.createElement(StatusCard, null) : null,
|
|
1309
1516
|
tab === "sessions" ? card(t("panel.tab.sessions"), React.createElement(SessionsSection, null)) : null,
|
|
1310
|
-
tab === "seeds" ? card(t("panel.tab.seeds"), React.createElement(
|
|
1517
|
+
tab === "seeds" ? card(t("panel.tab.seeds"), React.createElement(
|
|
1518
|
+
"div",
|
|
1519
|
+
null,
|
|
1520
|
+
React.createElement(BiliLoginCard, { key: "bili-login" }),
|
|
1521
|
+
React.createElement(SeedsSection, null),
|
|
1522
|
+
)) : null,
|
|
1311
1523
|
tab === "interests" ? card(t("panel.tab.interests"), React.createElement(InterestsSection, null)) : null,
|
|
1312
1524
|
tab === "profile" ? card(t("panel.tab.profile"), React.createElement(ProfileSection, null)) : null,
|
|
1313
1525
|
tab === "weekly" ? card(t("panel.tab.weekly"), React.createElement(WeeklySection, null)) : null,
|