@kanadego/dsh-heartbeat 2.0.0 → 2.1.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 +86 -23
- package/client.js +952 -238
- package/config/interests.json +1 -1
- package/config/policy.json +3 -2
- package/dist/{chunk-TVX4HV4Y.js → chunk-63E5OYSI.js} +56 -5
- package/dist/chunk-63E5OYSI.js.map +1 -0
- package/dist/{chunk-NCPKOWS7.js → chunk-AT32XCCI.js} +2 -2
- package/dist/{chunk-DC5HMCJC.js → chunk-DLOYERAK.js} +3 -3
- package/dist/{chunk-544QOJN5.js → chunk-ECXYNTEV.js} +2 -2
- package/dist/{chunk-IFRMKVIC.js → chunk-HE6IF6OU.js} +5 -2
- package/dist/chunk-HE6IF6OU.js.map +1 -0
- package/dist/{chunk-DZ7YCFGX.js → chunk-KZLVR4J7.js} +2 -2
- package/dist/{chunk-6XM6KY7M.js → chunk-LPPRI53J.js} +39 -37
- package/dist/chunk-LPPRI53J.js.map +1 -0
- package/dist/chunk-LQKOYTRL.js +59 -0
- package/dist/chunk-LQKOYTRL.js.map +1 -0
- package/dist/{chunk-AKIJ4LS2.js → chunk-M72T5MZU.js} +44 -1
- package/dist/chunk-M72T5MZU.js.map +1 -0
- package/dist/{chunk-6MVKWICX.js → chunk-XCMGPIUQ.js} +99 -23
- package/dist/chunk-XCMGPIUQ.js.map +1 -0
- package/dist/cli/index.js +51 -11
- package/dist/cli/index.js.map +1 -1
- package/dist/focus-store-RNHBAFYS.js +20 -0
- package/dist/{inbox-OWBK6PE2.js → inbox-ZLX2MH7A.js} +3 -3
- package/dist/index.d.ts +16 -3
- package/dist/index.js +119 -69
- package/dist/index.js.map +1 -1
- package/dist/{migrate-TQ5PB2DI.js → migrate-XFZU5EBE.js} +3 -3
- package/dist/{orchestrator-P7AEWVYR.js → orchestrator-MNFCPH43.js} +27 -8
- package/dist/{pool-2T6TVS2L.js → pool-MAABBHC4.js} +9 -3
- package/dist/{snapshot-F5B2DD56.js → snapshot-SU2VGM4C.js} +4 -4
- package/dist/snapshot-SU2VGM4C.js.map +1 -0
- package/icon.svg +11 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +12 -6
- package/dist/chunk-6MVKWICX.js.map +0 -1
- package/dist/chunk-6XM6KY7M.js.map +0 -1
- package/dist/chunk-AKIJ4LS2.js.map +0 -1
- package/dist/chunk-IFRMKVIC.js.map +0 -1
- package/dist/chunk-TVX4HV4Y.js.map +0 -1
- /package/dist/{chunk-NCPKOWS7.js.map → chunk-AT32XCCI.js.map} +0 -0
- /package/dist/{chunk-DC5HMCJC.js.map → chunk-DLOYERAK.js.map} +0 -0
- /package/dist/{chunk-544QOJN5.js.map → chunk-ECXYNTEV.js.map} +0 -0
- /package/dist/{chunk-DZ7YCFGX.js.map → chunk-KZLVR4J7.js.map} +0 -0
- /package/dist/{inbox-OWBK6PE2.js.map → focus-store-RNHBAFYS.js.map} +0 -0
- /package/dist/{migrate-TQ5PB2DI.js.map → inbox-ZLX2MH7A.js.map} +0 -0
- /package/dist/{orchestrator-P7AEWVYR.js.map → migrate-XFZU5EBE.js.map} +0 -0
- /package/dist/{pool-2T6TVS2L.js.map → orchestrator-MNFCPH43.js.map} +0 -0
- /package/dist/{snapshot-F5B2DD56.js.map → pool-MAABBHC4.js.map} +0 -0
package/client.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
// dsh-heartbeat client half
|
|
1
|
+
// dsh-heartbeat client half: native bundle panel (v2.1.0+).
|
|
2
2
|
//
|
|
3
3
|
// Contract notes (verified against dsh-vision-router + dsh-client-ui-settings
|
|
4
4
|
// types on 0.1.1-rc.2; reworked for 0.1.7-rc.2 in v1.7.0):
|
|
5
5
|
// - the client module is applied as a CLIENT-SIDE cordis plugin; the
|
|
6
6
|
// ModuleLoader factory must return an object with an "apply" method;
|
|
7
|
-
// - the
|
|
8
|
-
//
|
|
9
|
-
// slot survives 0.1.7; the per-namespace settingsScope service does not);
|
|
7
|
+
// - the panel is an entry on 'plugins.bundle.config' (keyed by the bundle
|
|
8
|
+
// short name); the old settings.section card was retired in v2.1.0;
|
|
10
9
|
// - the rhythm editor rides the /api RPC channel (host persists to
|
|
11
10
|
// data/settings/ui.json and applies live) — no host settings API needed;
|
|
12
11
|
// - custom host data flows through an exact Fetch route under /api:
|
|
@@ -19,57 +18,504 @@ window.__ModuleLoader__.load({
|
|
|
19
18
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
20
19
|
const React = require("react");
|
|
21
20
|
|
|
21
|
+
// Locale namespace and dictionary. zh is the source of truth: a host
|
|
22
|
+
// without @deepseek-ai/dsh-client-locale falls back to it unchanged.
|
|
23
|
+
// ── 原生面板样式(一次注入,类名统一 hb- 前缀)──────────────────
|
|
24
|
+
// 只依赖宿主主题变量 + 半透明叠色,深浅色主题下都不会糊成一团。
|
|
25
|
+
const PANEL_CSS = [
|
|
26
|
+
".hb-panel{display:flex;flex-direction:column;gap:14px}",
|
|
27
|
+
".hb-hero{position:relative;overflow:hidden;border-radius:16px;padding:16px 18px;border:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.25));background:linear-gradient(120deg,rgba(51,156,255,.20),rgba(124,92,255,.14) 46%,rgba(51,156,255,0) 82%)}",
|
|
28
|
+
".hb-hero::after{content:\"\";position:absolute;right:-40px;top:-70px;width:220px;height:220px;border-radius:50%;background:radial-gradient(circle,rgba(51,156,255,.34),transparent 68%);filter:blur(6px);pointer-events:none}",
|
|
29
|
+
".hb-heroTop{position:relative;display:flex;align-items:center;gap:12px}",
|
|
30
|
+
".hb-logo{flex:none;width:40px;height:40px;border-radius:13px;display:grid;place-items:center;font-size:19px;line-height:1;background:linear-gradient(135deg,#339CFF,#7C5CFF);box-shadow:0 8px 20px rgba(51,156,255,.38)}",
|
|
31
|
+
".hb-heroText{display:flex;flex-direction:column;gap:3px;min-width:0}",
|
|
32
|
+
".hb-heroTitle{font-size:16px;font-weight:700;letter-spacing:.3px;color:var(--dsw-alias-label-primary)}",
|
|
33
|
+
".hb-heroSub{font-size:11.5px;letter-spacing:.6px;color:var(--dsw-alias-label-tertiary)}",
|
|
34
|
+
".hb-heroRight{margin-left:auto;display:flex;align-items:center;gap:8px;flex-wrap:wrap;justify-content:flex-end}",
|
|
35
|
+
// hero 在蓝色渐变上,普通 hb-badgeInfo 的深蓝字对比不足,这里覆盖成白字半透明底
|
|
36
|
+
".hb-heroRight .hb-badge{background:rgba(255,255,255,.22);color:#fff;border:1px solid rgba(255,255,255,.46)}",
|
|
37
|
+
".hb-badge{display:inline-flex;align-items:center;gap:6px;height:24px;padding:0 10px;border-radius:999px;font-size:11.5px;font-weight:600;white-space:nowrap}",
|
|
38
|
+
".hb-badgeOk{background:rgba(61,220,151,.16);color:#2fbf7f}",
|
|
39
|
+
".hb-badgeInfo{background:rgba(51,156,255,.16);color:#2b8fe8}",
|
|
40
|
+
".hb-badgeWarn{background:rgba(245,184,61,.20);color:#c98b12}",
|
|
41
|
+
".hb-badgeOff{background:rgba(140,150,170,.18);color:var(--dsw-alias-label-tertiary)}",
|
|
42
|
+
".hb-dot{width:7px;height:7px;border-radius:50%;background:currentColor;box-shadow:0 0 8px currentColor}",
|
|
43
|
+
".hb-tabs{display:flex;flex-wrap:wrap;gap:5px;padding:5px;border-radius:14px;border:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.25));background:var(--dsw-alias-bg-layer-2,rgba(127,127,127,.08))}",
|
|
44
|
+
".hb-tab{height:30px;padding:0 14px;border-radius:10px;border:none;background:transparent;color:var(--dsw-alias-label-secondary);font-size:12.5px;cursor:pointer;transition:background .15s,color .15s,box-shadow .15s}",
|
|
45
|
+
".hb-tab:hover{background:rgba(51,156,255,.12);color:var(--dsw-alias-label-primary)}",
|
|
46
|
+
".hb-tabOn,.hb-tabOn:hover{background:linear-gradient(135deg,#339CFF,#6b8bff);color:#fff;font-weight:600;box-shadow:0 5px 16px rgba(51,156,255,.34)}",
|
|
47
|
+
".hb-body{display:flex;flex-direction:column;gap:12px}",
|
|
48
|
+
".hb-card{border-radius:14px;border:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.25));background:var(--dsw-alias-bg-layer-2,rgba(127,127,127,.06));padding:14px 16px;display:flex;flex-direction:column;gap:10px}",
|
|
49
|
+
".hb-cardHead{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}",
|
|
50
|
+
".hb-cardTitle{display:flex;align-items:center;gap:8px;font-size:13.5px;font-weight:600;color:var(--dsw-alias-label-primary)}",
|
|
51
|
+
".hb-cardTitle::before{content:\"\";flex:none;width:3px;height:15px;border-radius:2px;background:linear-gradient(180deg,#339CFF,#7C5CFF)}",
|
|
52
|
+
".hb-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(158px,1fr));gap:10px}",
|
|
53
|
+
".hb-tile{border-radius:13px;border:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.22));background:var(--dsw-alias-bg-layer-1,rgba(127,127,127,.04));padding:11px 13px;display:flex;flex-direction:column;gap:5px;transition:transform .16s,border-color .16s,box-shadow .16s}",
|
|
54
|
+
".hb-tile:hover{transform:translateY(-2px);border-color:rgba(51,156,255,.55);box-shadow:0 8px 22px rgba(0,0,0,.16)}",
|
|
55
|
+
".hb-tileWide{grid-column:span 2}",
|
|
56
|
+
".hb-tileLabel{font-size:11px;letter-spacing:.5px;color:var(--dsw-alias-label-tertiary)}",
|
|
57
|
+
".hb-tileValue{font-size:14.5px;font-weight:600;line-height:1.4;color:var(--dsw-alias-label-primary);word-break:break-word}",
|
|
58
|
+
".hb-tileMono{font-family:ui-monospace,Consolas,monospace;font-size:12.5px;letter-spacing:-.2px}",
|
|
59
|
+
".hb-tileHint{font-size:11.5px;color:var(--dsw-alias-label-tertiary);word-break:break-word}",
|
|
60
|
+
".hb-tileAccent{background:linear-gradient(135deg,rgba(51,156,255,.16),rgba(124,92,255,.10))}",
|
|
61
|
+
".hb-row{display:flex;align-items:center;gap:8px;flex-wrap:wrap}",
|
|
62
|
+
".hb-hint{font-size:12px;color:var(--dsw-alias-label-tertiary)}",
|
|
63
|
+
".hb-mono{font-family:ui-monospace,Consolas,monospace;font-size:12px;word-break:break-all}",
|
|
64
|
+
".hb-btn{height:28px;padding:0 13px;border-radius:9px;border:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.3));background:transparent;color:var(--dsw-alias-label-primary);font-size:12px;cursor:pointer;flex:none;transition:background .15s,border-color .15s,transform .1s}",
|
|
65
|
+
".hb-btn:hover{border-color:rgba(51,156,255,.6);background:rgba(51,156,255,.10)}",
|
|
66
|
+
".hb-btn:active{transform:translateY(1px)}",
|
|
67
|
+
".hb-btnOn{border-color:rgba(51,156,255,.65);background:rgba(51,156,255,.18);color:#2b8fe8;font-weight:600}",
|
|
68
|
+
".hb-btnPrimary{border:none;background:linear-gradient(135deg,#339CFF,#6b8bff);color:#fff;font-weight:600;box-shadow:0 5px 16px rgba(51,156,255,.32)}",
|
|
69
|
+
".hb-btnPrimary:hover{background:linear-gradient(135deg,#2f8fe8,#5f7ff0)}",
|
|
70
|
+
".hb-btnDanger{border:none;background:#e5484d;color:#fff;font-weight:600}",
|
|
71
|
+
".hb-input{height:28px;border-radius:9px;border:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.3));background:var(--dsw-alias-bg-layer-1,transparent);color:var(--dsw-alias-label-primary);padding:0 9px;font-size:12.5px;outline:none;transition:border-color .15s,box-shadow .15s}",
|
|
72
|
+
".hb-input:focus{border-color:rgba(51,156,255,.7);box-shadow:0 0 0 3px rgba(51,156,255,.18)}",
|
|
73
|
+
".hb-chip{display:inline-flex;align-items:center;height:20px;padding:0 7px;border-radius:6px;font-size:11px;background:rgba(127,127,127,.16);color:var(--dsw-alias-label-secondary)}",
|
|
74
|
+
".hb-divider{height:1px;background:var(--dsw-alias-border-l2,rgba(127,127,127,.2));margin:2px 0}",
|
|
75
|
+
".hb-list{display:flex;flex-direction:column;gap:7px}",
|
|
76
|
+
".hb-item{border-radius:10px;border:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.2));padding:8px 10px;display:flex;flex-direction:column;gap:5px;font-size:12px;transition:border-color .15s}",
|
|
77
|
+
".hb-item:hover{border-color:rgba(51,156,255,.45)}",
|
|
78
|
+
".hb-itemHead{display:flex;align-items:center;gap:8px;flex-wrap:wrap}",
|
|
79
|
+
".hb-bar{height:8px;border-radius:999px;overflow:hidden;background:rgba(127,127,127,.22)}",
|
|
80
|
+
".hb-barFill{height:100%;border-radius:999px;background:linear-gradient(90deg,#339CFF,#7C5CFF);transition:width .3s}",
|
|
81
|
+
".hb-barFillWarn{background:linear-gradient(90deg,#f5b83d,#e5484d)}",
|
|
82
|
+
".hb-err{font-size:12px;color:#e5484d;border:1px solid rgba(229,72,77,.5);border-radius:9px;padding:6px 10px;word-break:break-all;background:rgba(229,72,77,.08)}",
|
|
83
|
+
".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)}",
|
|
84
|
+
".hb-scroll{max-height:340px;overflow-y:auto;padding:2px}",
|
|
85
|
+
".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)}",
|
|
86
|
+
].join("");
|
|
87
|
+
function ensurePanelStyle() {
|
|
88
|
+
try {
|
|
89
|
+
if (typeof document === "undefined" || !document.head) return;
|
|
90
|
+
if (document.getElementById("dsh-heartbeat-style")) return;
|
|
91
|
+
const tag = document.createElement("style");
|
|
92
|
+
tag.id = "dsh-heartbeat-style";
|
|
93
|
+
tag.textContent = PANEL_CSS;
|
|
94
|
+
document.head.appendChild(tag);
|
|
95
|
+
} catch { /* 非 DOM 环境(冒烟测试)忽略 */ }
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const LOCALE_NS = "heartbeat";
|
|
99
|
+
const DICT = {
|
|
100
|
+
zh: {
|
|
101
|
+
"common.loading": "加载中…",
|
|
102
|
+
"common.loadFailed": "加载失败:{error}",
|
|
103
|
+
"common.confirmDelete": "确认删除",
|
|
104
|
+
"common.delete": "删除",
|
|
105
|
+
"common.empty": "(空)",
|
|
106
|
+
"common.labelWithCount": "{label}({count})",
|
|
107
|
+
"common.off": "关闭",
|
|
108
|
+
"common.on": "开启",
|
|
109
|
+
"common.refresh": "刷新",
|
|
110
|
+
"common.remove": "移除",
|
|
111
|
+
"common.save": "保存",
|
|
112
|
+
"common.unknown": "未知",
|
|
113
|
+
"common.add": "添加",
|
|
114
|
+
"error.rpcUnavailable": "RPC 通道不可用(请确认 DSH 正在运行)",
|
|
115
|
+
"error.rpcFailed": "RPC 调用失败",
|
|
116
|
+
"status.loadFailed": "状态获取失败:{error}",
|
|
117
|
+
"status.spoke": "说了:{text}",
|
|
118
|
+
"status.silent": "沉默({reason})",
|
|
119
|
+
"status.spokeFailed": "投递失败({reason})",
|
|
120
|
+
"status.error": "心跳异常({reason})",
|
|
121
|
+
"status.none": "尚无记录",
|
|
122
|
+
"status.currentWithNote": "心跳此刻:{scene}——{note}",
|
|
123
|
+
"status.current": "心跳此刻:{scene}",
|
|
124
|
+
"status.currentEmpty": "心跳此刻:(还没有状态记录)",
|
|
125
|
+
"status.version": "插件版本:v{version}",
|
|
126
|
+
"status.lastBeat": "上次心跳:",
|
|
127
|
+
"status.result": "结果:",
|
|
128
|
+
"status.today": "今日表达:{used} / {max} 条",
|
|
129
|
+
"status.quiet": "当前:静默时段内",
|
|
130
|
+
"status.rhythm": "当前:正常节律(间隔 {interval} 分钟)",
|
|
131
|
+
"status.statusbarOff": "{status}(状态栏已关闭)",
|
|
132
|
+
"status.timeInject": "时间注入:",
|
|
133
|
+
"status.timeInjectOff": "已关闭",
|
|
134
|
+
"status.lastBeatShort": "上次心跳",
|
|
135
|
+
"status.resultShort": "上次结果",
|
|
136
|
+
"status.versionShort": "插件版本",
|
|
137
|
+
"status.todaySimple": "今日表达",
|
|
138
|
+
"status.timeInjectShort": "时间注入",
|
|
139
|
+
"status.currentShort": "此刻动态",
|
|
140
|
+
"status.timeInjectEvery": "每 {interval} 分钟,最近 {last}",
|
|
141
|
+
"status.never": "未发生过",
|
|
142
|
+
"scene.quietHours": "静默时段,世界睡了",
|
|
143
|
+
"scene.justSpoke": "刚去和你说过话",
|
|
144
|
+
"scene.wandering": "正在闲逛看新东西",
|
|
145
|
+
"scene.busy": "看到你在忙,不去打扰",
|
|
146
|
+
"scene.present": "在场待着",
|
|
147
|
+
"scene.away": "你不在,自己待着",
|
|
148
|
+
"sessions.homeName": "心跳正身(引擎室)",
|
|
149
|
+
"sessions.hint": "绑定 = 表达投递 + 对话观察(D13),两个开关可以同时开,也可以在下面逐个切换。心跳正身的思考轮次固定在其自身会话,不受绑定影响。",
|
|
150
|
+
"sessions.boundRow": "🔗 {name}({modes})",
|
|
151
|
+
"sessions.deliverTitleOn": "点击关闭投递",
|
|
152
|
+
"sessions.deliverTitleOff": "点击开启投递",
|
|
153
|
+
"sessions.observeTitleOn": "点击关闭观察",
|
|
154
|
+
"sessions.observeTitleOff": "点击开启观察",
|
|
155
|
+
"sessions.deliver": "投递",
|
|
156
|
+
"sessions.observe": "观察",
|
|
157
|
+
"sessions.unbind": "解绑",
|
|
158
|
+
"sessions.noBound": "(暂无绑定会话——表达只出现在心跳正身会话)",
|
|
159
|
+
"sessions.collapseUnbound": "收起未绑定列表",
|
|
160
|
+
"sessions.bindOthers": "绑定其他会话({count})",
|
|
161
|
+
"sessions.filterPlaceholder": "按会话名或 id 过滤…",
|
|
162
|
+
"sessions.noMatch": "(无匹配会话)",
|
|
163
|
+
"sessions.homeNoBind": "(心跳正身,无需绑定)",
|
|
164
|
+
"sessions.bindDeliver": "绑定投递",
|
|
165
|
+
"sessions.bindObserve": "绑定观察",
|
|
166
|
+
"sessions.modesBoth": "投递+观察",
|
|
167
|
+
"seeds.activeSummary": "活跃 {active} / {cap} 条;归档 {archived} 条",
|
|
168
|
+
"seeds.tabTopic": "话题素材",
|
|
169
|
+
"seeds.tabChat": "聊天素材",
|
|
170
|
+
"seeds.tabArchivedTopic": "话题·归档",
|
|
171
|
+
"seeds.tabArchivedChat": "聊天·归档",
|
|
172
|
+
"seeds.hintArchivedChat": "归档的聊天素材:不再被挑中,可以恢复",
|
|
173
|
+
"seeds.hintArchivedTopic": "归档的话题素材:不再被挑中,可以恢复",
|
|
174
|
+
"seeds.hintChat": "对话里长出来的:说过一次就算用掉",
|
|
175
|
+
"seeds.hintTopic": "浏览流、手写、画像喂进来的:随机挑,可重复用",
|
|
176
|
+
"seeds.emptyArchived": "(这类还没有归档条目)",
|
|
177
|
+
"seeds.empty": "(这类还没有条目)",
|
|
178
|
+
"seeds.restore": "恢复",
|
|
179
|
+
"seeds.archive": "归档",
|
|
180
|
+
"seeds.used": " used:{used}",
|
|
181
|
+
"interests.added": "已添加",
|
|
182
|
+
"interests.addFailed": "添加失败:{error}",
|
|
183
|
+
"interests.deleted": "已删除",
|
|
184
|
+
"interests.deleteFailed": "删除失败:{error}",
|
|
185
|
+
"interests.savedWindows": "浏览时段已保存",
|
|
186
|
+
"interests.saveFailed": "保存失败:{error}",
|
|
187
|
+
"interests.hint": "闲逛搜索按这份清单轮换挑焦点(同一条 3 天内不重复)。增删后即时生效,无需重启。",
|
|
188
|
+
"interests.empty": "(清单是空的——闲逛将没有焦点可挑)",
|
|
189
|
+
"interests.placeholder": "新兴趣,如:天文摄影",
|
|
190
|
+
"interests.windowsHint": "浏览时段(闲逛只在这些窗口内发生;起始须早于结束,多个时段不能重叠):",
|
|
191
|
+
"interests.to": "到",
|
|
192
|
+
"interests.addWindow": "加一个时段",
|
|
193
|
+
"interests.saveWindows": "保存时段",
|
|
194
|
+
"profile.tabInterest": "兴趣",
|
|
195
|
+
"profile.tabProjects": "进行中",
|
|
196
|
+
"profile.tabComm": "沟通偏好",
|
|
197
|
+
"profile.tabPsy": "心理",
|
|
198
|
+
"profile.exported": "已导出:{path}",
|
|
199
|
+
"profile.engine": "引擎室输入",
|
|
200
|
+
"profile.digest": "共 {total} / {budget} 字符({budgetState});按预算省略:处境 {tact} 条、话题 {topic} 条、兴趣 {wander} 条",
|
|
201
|
+
"profile.withinBudget": "在预算内",
|
|
202
|
+
"profile.overBudget": "超预算",
|
|
203
|
+
"profile.tactFacet": "处境切面",
|
|
204
|
+
"profile.topicFacet": "话题切面",
|
|
205
|
+
"profile.wanderFacet": "兴趣切面",
|
|
206
|
+
"profile.valid": "有效 {valid} 条 / 历史 {historical} 条(过期条目不进引擎室输入,也不在这里列出)",
|
|
207
|
+
"profile.emptyPartition": "(这个分区还没有条目)",
|
|
208
|
+
"profile.conf": " conf {value}",
|
|
209
|
+
"profile.temporal": " {value}",
|
|
210
|
+
"profile.stale": " 久未验证",
|
|
211
|
+
"profile.updated": " 更新 {date}",
|
|
212
|
+
"profile.exportMarkdown": "导出 Markdown",
|
|
213
|
+
"config.saved": "已保存(即时生效,无需重启)",
|
|
214
|
+
"config.saveFailed": "保存失败:{error}",
|
|
215
|
+
"config.interval": "心跳间隔(分钟)",
|
|
216
|
+
"config.cap": "每日表达上限(条)",
|
|
217
|
+
"config.timeInject": "时间注入间隔(分钟)",
|
|
218
|
+
"config.timeInjectOff": "0 = 关闭",
|
|
219
|
+
"config.statusbar": "状态栏",
|
|
220
|
+
"config.statusbarHint": "日常会话中的心跳状态感知(会额外消耗token)",
|
|
221
|
+
"config.idle": "闲着模式",
|
|
222
|
+
"config.idleHint": "素材池空时用画像话题兜底主动搭话(闸门仍生效)",
|
|
223
|
+
"config.tokenSaver": "节省 token 模式",
|
|
224
|
+
"config.tokenSaverHint": "你离开(闲置 ≥30 分钟)或锁屏时整跳暂停,回来自动恢复",
|
|
225
|
+
"config.psy": "psy 分区",
|
|
226
|
+
"config.psyHint": "允许画像记录 psy 分区(警告,开启后模型会主动猜测用户心理并计入用户画像,关闭时画像内容计入内容较少)",
|
|
227
|
+
"config.saveHint": "全部参数保存后即时生效,无需重启",
|
|
228
|
+
"config.focus": "专注模式",
|
|
229
|
+
"config.focusHint": "暂停期间不心跳、不计每日条数、不耗 token,到点自动恢复",
|
|
230
|
+
"config.focusPause": "暂停",
|
|
231
|
+
"config.focusResume": "恢复",
|
|
232
|
+
"config.focusPaused": "已暂停至 {clock}",
|
|
233
|
+
"config.focusMinutes": "分钟",
|
|
234
|
+
"config.focusFailed": "操作失败:{error}",
|
|
235
|
+
"weekly.intro": "每 7 天生成一份:本周表达与静默、新认识、账本、素材池与活跃高峰。报告只陈述事实,由后台「心跳」署名。",
|
|
236
|
+
"weekly.empty": "(还没有周报——装好一周后自动出第一期)",
|
|
237
|
+
"migrate.processing": "处理中…",
|
|
238
|
+
"migrate.failed": "失败:{error}",
|
|
239
|
+
"migrate.pwMismatch": "两次口令不一致或为空",
|
|
240
|
+
"migrate.exported": "已打包 {count} 个文件 → {path}(可拷贝到新机器,口令别丢)",
|
|
241
|
+
"migrate.needInput": "需要容器路径与口令",
|
|
242
|
+
"migrate.imported": "恢复 {restored} 个文件,备份 {backedUp} 个,跳过 {skipped} 个——重启 DSH 后生效",
|
|
243
|
+
"migrate.intro": "换电脑/重装系统时把心跳的记忆带走:导出一个口令加密的迁移包,在新机器上导入。口令丢失无法破解,容器可安全走网盘。",
|
|
244
|
+
"migrate.exportHeading": "① 在这台机器上导出",
|
|
245
|
+
"migrate.pwPlaceholder": "设置口令",
|
|
246
|
+
"migrate.pwAgainPlaceholder": "再输入一次",
|
|
247
|
+
"migrate.exportButton": "导出迁移包",
|
|
248
|
+
"migrate.importHeading": "② 在新机器上导入",
|
|
249
|
+
"migrate.filePlaceholder": "迁移包完整路径(.hbmig)",
|
|
250
|
+
"migrate.pwPlaceholderShort": "口令",
|
|
251
|
+
"migrate.importButton": "导入",
|
|
252
|
+
"section.status": "心跳状态",
|
|
253
|
+
"section.sessions": "会话绑定",
|
|
254
|
+
"section.seeds": "素材池",
|
|
255
|
+
"section.interests": "兴趣范围",
|
|
256
|
+
"section.profile": "用户画像(只读)",
|
|
257
|
+
"section.ledger": "账本",
|
|
258
|
+
"section.excerpt": "摘抄本",
|
|
259
|
+
"section.weekly": "周报",
|
|
260
|
+
"section.migrate": "换机迁移",
|
|
261
|
+
"section.config": "节律配置",
|
|
262
|
+
"ledger.opened": "已打开:{path}",
|
|
263
|
+
"ledger.failed": "失败:{error}",
|
|
264
|
+
"ledger.open": "一键打开账本",
|
|
265
|
+
"ledger.hint": "账本是心跳 agent 的待办与话题来源,可直接手编",
|
|
266
|
+
"excerpt.opened": "已打开:{path}",
|
|
267
|
+
"excerpt.failed": "失败:{error}",
|
|
268
|
+
"excerpt.open": "一键打开摘抄本",
|
|
269
|
+
"excerpt.hint": "留句子和小事的地方:只增不减,直接手编也不会被覆盖",
|
|
270
|
+
"panel.title": "心跳",
|
|
271
|
+
"panel.subtitle": "dsh-heartbeat",
|
|
272
|
+
"panel.badgeNative": "原生面板",
|
|
273
|
+
"panel.tab.status": "状态",
|
|
274
|
+
"panel.tab.sessions": "会话",
|
|
275
|
+
"panel.tab.seeds": "素材",
|
|
276
|
+
"panel.tab.interests": "兴趣",
|
|
277
|
+
"panel.tab.profile": "画像",
|
|
278
|
+
"panel.tab.weekly": "周报",
|
|
279
|
+
"panel.tab.config": "设置",
|
|
280
|
+
},
|
|
281
|
+
en: {
|
|
282
|
+
"common.loading": "Loading…",
|
|
283
|
+
"common.loadFailed": "Failed to load: {error}",
|
|
284
|
+
"common.confirmDelete": "Confirm delete",
|
|
285
|
+
"common.delete": "Delete",
|
|
286
|
+
"common.empty": "(empty)",
|
|
287
|
+
"common.labelWithCount": "{label} ({count})",
|
|
288
|
+
"common.off": "Off",
|
|
289
|
+
"common.on": "On",
|
|
290
|
+
"common.refresh": "Refresh",
|
|
291
|
+
"common.remove": "Remove",
|
|
292
|
+
"common.save": "Save",
|
|
293
|
+
"common.unknown": "unknown",
|
|
294
|
+
"common.add": "Add",
|
|
295
|
+
"error.rpcUnavailable": "RPC channel unavailable (make sure DSH is running)",
|
|
296
|
+
"error.rpcFailed": "RPC call failed",
|
|
297
|
+
"status.loadFailed": "Failed to fetch status: {error}",
|
|
298
|
+
"status.spoke": "Said: {text}",
|
|
299
|
+
"status.silent": "Silent ({reason})",
|
|
300
|
+
"status.spokeFailed": "Delivery failed ({reason})",
|
|
301
|
+
"status.error": "Heartbeat error ({reason})",
|
|
302
|
+
"status.none": "No record yet",
|
|
303
|
+
"status.currentWithNote": "Heartbeat now: {scene} — {note}",
|
|
304
|
+
"status.current": "Heartbeat now: {scene}",
|
|
305
|
+
"status.currentEmpty": "Heartbeat now: (no status record yet)",
|
|
306
|
+
"status.version": "Plugin version: v{version}",
|
|
307
|
+
"status.lastBeat": "Last heartbeat:",
|
|
308
|
+
"status.result": "Result:",
|
|
309
|
+
"status.today": "Expressions today: {used} / {max}",
|
|
310
|
+
"status.quiet": "Now: in quiet hours",
|
|
311
|
+
"status.rhythm": "Now: normal rhythm (every {interval} min)",
|
|
312
|
+
"status.statusbarOff": "{status} (status bar off)",
|
|
313
|
+
"status.timeInject": "Time injection:",
|
|
314
|
+
"status.timeInjectOff": "Off",
|
|
315
|
+
"status.lastBeatShort": "Last beat",
|
|
316
|
+
"status.resultShort": "Last result",
|
|
317
|
+
"status.versionShort": "Version",
|
|
318
|
+
"status.todaySimple": "Spoken today",
|
|
319
|
+
"status.timeInjectShort": "Time injection",
|
|
320
|
+
"status.currentShort": "Right now",
|
|
321
|
+
"status.timeInjectEvery": "Every {interval} min, last {last}",
|
|
322
|
+
"status.never": "never",
|
|
323
|
+
"scene.quietHours": "Quiet hours — the world is asleep",
|
|
324
|
+
"scene.justSpoke": "Just talked to you",
|
|
325
|
+
"scene.wandering": "Wandering around, looking at something new",
|
|
326
|
+
"scene.busy": "You look busy, so I am staying out of the way",
|
|
327
|
+
"scene.present": "Here with you",
|
|
328
|
+
"scene.away": "You are away, so I am on my own",
|
|
329
|
+
"sessions.homeName": "Heartbeat itself (engine room)",
|
|
330
|
+
"sessions.hint": "Binding = expression delivery + conversation observation (D13). Both switches can be on at once, or toggled individually below. The heartbeat itself always thinks in its own session, regardless of bindings.",
|
|
331
|
+
"sessions.boundRow": "🔗 {name} ({modes})",
|
|
332
|
+
"sessions.deliverTitleOn": "Click to turn delivery off",
|
|
333
|
+
"sessions.deliverTitleOff": "Click to turn delivery on",
|
|
334
|
+
"sessions.observeTitleOn": "Click to turn observation off",
|
|
335
|
+
"sessions.observeTitleOff": "Click to turn observation on",
|
|
336
|
+
"sessions.deliver": "Deliver",
|
|
337
|
+
"sessions.observe": "Observe",
|
|
338
|
+
"sessions.unbind": "Unbind",
|
|
339
|
+
"sessions.noBound": "(No bound sessions — expressions only appear in the heartbeat's own session)",
|
|
340
|
+
"sessions.collapseUnbound": "Hide unbound sessions",
|
|
341
|
+
"sessions.bindOthers": "Bind other sessions ({count})",
|
|
342
|
+
"sessions.filterPlaceholder": "Filter by session name or id…",
|
|
343
|
+
"sessions.noMatch": "(No matching sessions)",
|
|
344
|
+
"sessions.homeNoBind": "(The heartbeat itself does not need binding)",
|
|
345
|
+
"sessions.bindDeliver": "Bind delivery",
|
|
346
|
+
"sessions.bindObserve": "Bind observation",
|
|
347
|
+
"sessions.modesBoth": "Deliver + observe",
|
|
348
|
+
"seeds.activeSummary": "Active {active} / {cap} entries; archived {archived}",
|
|
349
|
+
"seeds.tabTopic": "Topics",
|
|
350
|
+
"seeds.tabChat": "Chat",
|
|
351
|
+
"seeds.tabArchivedTopic": "Topics · archived",
|
|
352
|
+
"seeds.tabArchivedChat": "Chat · archived",
|
|
353
|
+
"seeds.hintArchivedChat": "Archived chat material: no longer picked, but can be restored",
|
|
354
|
+
"seeds.hintArchivedTopic": "Archived topic material: no longer picked, but can be restored",
|
|
355
|
+
"seeds.hintChat": "Grown from conversations: used once and then spent",
|
|
356
|
+
"seeds.hintTopic": "From browsing, handwriting, and the profile: picked at random and reusable",
|
|
357
|
+
"seeds.emptyArchived": "(No archived entries of this kind yet)",
|
|
358
|
+
"seeds.empty": "(No entries of this kind yet)",
|
|
359
|
+
"seeds.restore": "Restore",
|
|
360
|
+
"seeds.archive": "Archive",
|
|
361
|
+
"seeds.used": " used: {used}",
|
|
362
|
+
"interests.added": "Added",
|
|
363
|
+
"interests.addFailed": "Failed to add: {error}",
|
|
364
|
+
"interests.deleted": "Deleted",
|
|
365
|
+
"interests.deleteFailed": "Failed to delete: {error}",
|
|
366
|
+
"interests.savedWindows": "Browsing windows saved",
|
|
367
|
+
"interests.saveFailed": "Failed to save: {error}",
|
|
368
|
+
"interests.hint": "Wandering searches rotate through this list for focus (the same entry is not reused within 3 days). Changes take effect immediately, no restart needed.",
|
|
369
|
+
"interests.empty": "(The list is empty — wandering will have no focus to pick)",
|
|
370
|
+
"interests.placeholder": "New interest, e.g. astrophotography",
|
|
371
|
+
"interests.windowsHint": "Browsing windows (wandering only happens inside these; start must be before end, and windows must not overlap):",
|
|
372
|
+
"interests.to": "to",
|
|
373
|
+
"interests.addWindow": "Add a window",
|
|
374
|
+
"interests.saveWindows": "Save windows",
|
|
375
|
+
"profile.tabInterest": "Interests",
|
|
376
|
+
"profile.tabProjects": "In progress",
|
|
377
|
+
"profile.tabComm": "Communication preferences",
|
|
378
|
+
"profile.tabPsy": "Psychology",
|
|
379
|
+
"profile.exported": "Exported: {path}",
|
|
380
|
+
"profile.engine": "Engine room input",
|
|
381
|
+
"profile.digest": "{total} / {budget} characters ({budgetState}); omitted to fit the budget — situation: {tact}, topic: {topic}, interest: {wander}",
|
|
382
|
+
"profile.withinBudget": "within budget",
|
|
383
|
+
"profile.overBudget": "over budget",
|
|
384
|
+
"profile.tactFacet": "Situation facet",
|
|
385
|
+
"profile.topicFacet": "Topic facet",
|
|
386
|
+
"profile.wanderFacet": "Interest facet",
|
|
387
|
+
"profile.valid": "Valid {valid} / historical {historical} entries (expired entries are neither sent to the engine room nor listed here)",
|
|
388
|
+
"profile.emptyPartition": "(This partition has no entries yet)",
|
|
389
|
+
"profile.conf": " · confidence {value}",
|
|
390
|
+
"profile.temporal": " · {value}",
|
|
391
|
+
"profile.stale": " · not verified for a while",
|
|
392
|
+
"profile.updated": " · updated {date}",
|
|
393
|
+
"profile.exportMarkdown": "Export Markdown",
|
|
394
|
+
"config.saved": "Saved (takes effect immediately, no restart needed)",
|
|
395
|
+
"config.saveFailed": "Failed to save: {error}",
|
|
396
|
+
"config.interval": "Heartbeat interval (minutes)",
|
|
397
|
+
"config.cap": "Daily expression limit",
|
|
398
|
+
"config.timeInject": "Time injection interval (minutes)",
|
|
399
|
+
"config.timeInjectOff": "0 = off",
|
|
400
|
+
"config.statusbar": "Status bar",
|
|
401
|
+
"config.statusbarHint": "Show heartbeat status in everyday conversations (uses extra tokens)",
|
|
402
|
+
"config.idle": "Idle mode",
|
|
403
|
+
"config.idleHint": "When the material pool is empty, fall back to profile topics and start a conversation (gates still apply)",
|
|
404
|
+
"config.tokenSaver": "Token-saver mode",
|
|
405
|
+
"config.tokenSaverHint": "Pause all beats while you are away (idle for 30+ min) or the screen is locked, and resume automatically when you return",
|
|
406
|
+
"config.psy": "Psychology partition",
|
|
407
|
+
"config.psyHint": "Allow the profile to record the psychology partition (warning: when enabled, the model will guess your psychology and add it to your profile; when disabled, the profile contains less content)",
|
|
408
|
+
"config.saveHint": "All settings take effect immediately after saving, no restart needed",
|
|
409
|
+
"config.focus": "Focus mode",
|
|
410
|
+
"config.focusHint": "While paused: no beats, no daily count, no tokens; resumes automatically at the lift time",
|
|
411
|
+
"config.focusPause": "Pause",
|
|
412
|
+
"config.focusResume": "Resume",
|
|
413
|
+
"config.focusPaused": "Paused until {clock}",
|
|
414
|
+
"config.focusMinutes": "min",
|
|
415
|
+
"config.focusFailed": "Failed: {error}",
|
|
416
|
+
"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.",
|
|
417
|
+
"weekly.empty": "(No weekly report yet — the first one appears a week after installation)",
|
|
418
|
+
"migrate.processing": "Working…",
|
|
419
|
+
"migrate.failed": "Failed: {error}",
|
|
420
|
+
"migrate.pwMismatch": "The two passphrases do not match, or are empty",
|
|
421
|
+
"migrate.exported": "Packed {count} files → {path} (copy it to the new machine, and do not lose the passphrase)",
|
|
422
|
+
"migrate.needInput": "A container path and passphrase are required",
|
|
423
|
+
"migrate.imported": "Restored {restored} files, backed up {backedUp}, skipped {skipped} — restart DSH to apply",
|
|
424
|
+
"migrate.intro": "Take the heartbeat's memory with you when changing computers or reinstalling: export a passphrase-encrypted migration package, then import it on the new machine. A lost passphrase cannot be cracked, and the container is safe to put on cloud storage.",
|
|
425
|
+
"migrate.exportHeading": "1. Export on this machine",
|
|
426
|
+
"migrate.pwPlaceholder": "Set a passphrase",
|
|
427
|
+
"migrate.pwAgainPlaceholder": "Enter it again",
|
|
428
|
+
"migrate.exportButton": "Export migration package",
|
|
429
|
+
"migrate.importHeading": "2. Import on the new machine",
|
|
430
|
+
"migrate.filePlaceholder": "Full path to the migration package (.hbmig)",
|
|
431
|
+
"migrate.pwPlaceholderShort": "Passphrase",
|
|
432
|
+
"migrate.importButton": "Import",
|
|
433
|
+
"section.status": "Heartbeat status",
|
|
434
|
+
"section.sessions": "Session bindings",
|
|
435
|
+
"section.seeds": "Material pool",
|
|
436
|
+
"section.interests": "Interest scope",
|
|
437
|
+
"section.profile": "User profile (read-only)",
|
|
438
|
+
"section.ledger": "Ledger",
|
|
439
|
+
"section.excerpt": "Excerpt book",
|
|
440
|
+
"section.weekly": "Weekly report",
|
|
441
|
+
"section.migrate": "Migrate to a new machine",
|
|
442
|
+
"section.config": "Rhythm settings",
|
|
443
|
+
"ledger.opened": "Opened: {path}",
|
|
444
|
+
"ledger.failed": "Failed: {error}",
|
|
445
|
+
"ledger.open": "Open the ledger",
|
|
446
|
+
"ledger.hint": "The ledger is the heartbeat agent's source of todos and topics, and can be edited by hand",
|
|
447
|
+
"excerpt.opened": "Opened: {path}",
|
|
448
|
+
"excerpt.failed": "Failed: {error}",
|
|
449
|
+
"excerpt.open": "Open the excerpt book",
|
|
450
|
+
"excerpt.hint": "A place for sentences and small things: it only grows, and hand edits are never overwritten",
|
|
451
|
+
"panel.title": "Heartbeat",
|
|
452
|
+
"panel.subtitle": "dsh-heartbeat",
|
|
453
|
+
"panel.badgeNative": "Native panel",
|
|
454
|
+
"panel.tab.status": "Status",
|
|
455
|
+
"panel.tab.sessions": "Sessions",
|
|
456
|
+
"panel.tab.seeds": "Material",
|
|
457
|
+
"panel.tab.interests": "Interests",
|
|
458
|
+
"panel.tab.profile": "Profile",
|
|
459
|
+
"panel.tab.weekly": "Weekly",
|
|
460
|
+
"panel.tab.config": "Settings",
|
|
461
|
+
},
|
|
462
|
+
};
|
|
463
|
+
const fill = (text, params) => String(text).replace(/\{(\w+)\}/g, (match, key) => (params && key in params ? String(params[key]) : match));
|
|
464
|
+
let localeSvc = null;
|
|
465
|
+
const t = (key, params) => {
|
|
466
|
+
if (localeSvc) return localeSvc.bind(LOCALE_NS)(key, params);
|
|
467
|
+
const text = DICT.zh[key];
|
|
468
|
+
return text === undefined ? key : fill(text, params);
|
|
469
|
+
};
|
|
470
|
+
const L = (key, params) => t(key, params);
|
|
471
|
+
|
|
22
472
|
const rowStyle = { display: "flex", alignItems: "center", gap: 8, margin: "6px 0" };
|
|
23
473
|
const labelStyle = { minWidth: 140, fontSize: 13, color: "var(--dsw-alias-label-secondary)", flex: "none" };
|
|
24
|
-
const inputStyle = { width: 90, height:
|
|
25
|
-
const buttonStyle = { height:
|
|
26
|
-
const buttonGhost = { ...buttonStyle, background: "var(--dsw-alias-
|
|
27
|
-
const hintStyle = { fontSize: 12, color: "var(--dsw-alias-label-tertiary)", margin: "
|
|
28
|
-
|
|
29
|
-
const summaryStyle = { fontSize: 13, fontWeight: 600, color: "var(--dsw-alias-label-primary)", cursor: "pointer" };
|
|
30
|
-
const listStyle = { listStyle: "none", margin: "4px 0", padding: 0, fontSize: 12, color: "var(--dsw-alias-label-secondary)" };
|
|
31
|
-
const rowList = { display: "flex", alignItems: "center", gap:
|
|
474
|
+
const inputStyle = { width: 90, height: 30, borderRadius: 9, border: "1px solid var(--dsw-alias-border-l2)", background: "var(--dsw-specific-input-bg, rgba(127,127,127,.08))", color: "var(--dsw-alias-label-primary)", padding: "0 10px", fontSize: 12.5, outline: "none" };
|
|
475
|
+
const buttonStyle = { height: 28, padding: "0 14px", borderRadius: 9, border: "none", background: "linear-gradient(135deg, #339CFF, #5b8cff)", color: "#fff", fontSize: 12, fontWeight: 600, cursor: "pointer", flex: "none", boxShadow: "0 4px 14px rgba(51,156,255,.26)" };
|
|
476
|
+
const buttonGhost = { ...buttonStyle, background: "rgba(127,127,127,.14)", color: "var(--dsw-alias-label-primary)", border: "1px solid var(--dsw-alias-border-l2)", boxShadow: "none" };
|
|
477
|
+
const hintStyle = { fontSize: 12, lineHeight: 1.6, color: "var(--dsw-alias-label-tertiary)", margin: "5px 0" };
|
|
478
|
+
|
|
479
|
+
const summaryStyle = { fontSize: 13, fontWeight: 600, color: "var(--dsw-alias-label-primary)", cursor: "pointer", padding: "6px 0" };
|
|
480
|
+
const listStyle = { listStyle: "none", margin: "4px 0", padding: 0, fontSize: 12.5, color: "var(--dsw-alias-label-secondary)", display: "flex", flexDirection: "column", gap: 6 };
|
|
481
|
+
const rowList = { display: "flex", alignItems: "center", gap: 10, padding: "5px 0" };
|
|
482
|
+
const panelBox = { padding: "2px 0" };
|
|
483
|
+
const panelHead = { display: "flex", alignItems: "baseline", justifyContent: "space-between", margin: "2px 0 8px" };
|
|
484
|
+
const panelTitle = { fontSize: 15, fontWeight: 600, color: "var(--dsw-alias-label-primary)" };
|
|
485
|
+
const panelSub = { fontSize: 12, color: "var(--dsw-alias-label-tertiary)" };
|
|
486
|
+
const panelTabs = { display: "flex", flexWrap: "wrap", gap: 6, margin: "0 0 8px", borderBottom: "1px solid var(--dsw-alias-border-l2)", paddingBottom: 8 };
|
|
487
|
+
const panelTab = { height: 27, padding: "0 13px", borderRadius: 9, border: "1px solid var(--dsw-alias-border-l2)", background: "transparent", color: "var(--dsw-alias-label-secondary)", fontSize: 12, cursor: "pointer" };
|
|
488
|
+
const panelTabOn = { ...panelTab, background: "#339CFF", borderColor: "#339CFF", color: "#fff" };
|
|
489
|
+
const blockHead = { fontSize: 13, fontWeight: 600, color: "var(--dsw-alias-label-primary)", margin: "14px 0 6px", paddingLeft: 9, borderLeft: "3px solid #339CFF" };
|
|
32
490
|
|
|
33
491
|
function apply(ctx) {
|
|
34
492
|
// settingsScope was removed in DSH 0.1.7 — never bound here again.
|
|
35
493
|
// The rhythm editor rides the RPC channel (data/settings/ui.json on
|
|
36
494
|
// the host), so the card works identically on every host generation.
|
|
495
|
+
const locale = ctx.get("locale");
|
|
496
|
+
if (locale && typeof locale.register === "function" && typeof locale.bind === "function") {
|
|
497
|
+
localeSvc = locale;
|
|
498
|
+
ctx.effect(() => locale.register(LOCALE_NS, { zh: DICT.zh, en: DICT.en }));
|
|
499
|
+
}
|
|
37
500
|
const getConnection = () => {
|
|
38
501
|
try { return ctx.get("connection"); } catch { return undefined; }
|
|
39
502
|
};
|
|
40
503
|
const rpc = async (endpoint, payload) => {
|
|
41
504
|
const conn = getConnection();
|
|
42
505
|
if (!conn || !conn.rpc || typeof conn.rpc.call !== "function") {
|
|
43
|
-
throw new Error("
|
|
506
|
+
throw new Error(t("error.rpcUnavailable"));
|
|
44
507
|
}
|
|
45
508
|
// C21:0.1.5 起自定义 rpc.handle 通道不可用,宿主侧改为 /api 下的精确
|
|
46
509
|
// Fetch 路由;端点名走 payload.endpoint 字段(信封与 /api 同构)。
|
|
47
510
|
const result = await conn.rpc.call("/api", "heartbeat", { endpoint, ...(payload ?? {}) }, undefined);
|
|
48
511
|
if (!result || result.ok !== true) {
|
|
49
|
-
throw new Error((result && result.error && result.error.message) || "
|
|
512
|
+
throw new Error((result && result.error && result.error.message) || t("error.rpcFailed"));
|
|
50
513
|
}
|
|
51
514
|
return result.value;
|
|
52
515
|
};
|
|
53
|
-
// 会话名来自 client 自己的会话存储(侧边栏同名数据源);拿不到则回退 id。
|
|
54
|
-
const sessionName = (id) => {
|
|
55
|
-
try {
|
|
56
|
-
const list = typeof ctx.sessions?.list === "function" ? ctx.sessions.list() : undefined;
|
|
57
|
-
const hit = Array.isArray(list) ? list.find((s) => s && (s.id === id || s.sessionId === id)) : undefined;
|
|
58
|
-
const name = hit && (hit.title || hit.name || hit.displayName);
|
|
59
|
-
return name ? String(name) : null;
|
|
60
|
-
} catch { return null; }
|
|
61
|
-
};
|
|
62
516
|
|
|
63
517
|
// ── 通用小组件 ────────────────────────────────────────────────
|
|
64
|
-
|
|
65
|
-
const [open, setOpen] = React.useState(props.open === true);
|
|
66
|
-
return React.createElement(
|
|
67
|
-
"details",
|
|
68
|
-
{ open, style: sectionStyle, onToggle: (e) => setOpen(e.target.open) },
|
|
69
|
-
React.createElement("summary", { style: summaryStyle }, props.title),
|
|
70
|
-
open ? React.createElement("div", { style: { paddingTop: 4 } }, props.children) : null,
|
|
71
|
-
);
|
|
72
|
-
}
|
|
518
|
+
|
|
73
519
|
function useAsync(fetcher, deps) {
|
|
74
520
|
const [state, setState] = React.useState({ loading: true, error: null, value: null });
|
|
75
521
|
React.useEffect(() => {
|
|
@@ -83,52 +529,100 @@ window.__ModuleLoader__.load({
|
|
|
83
529
|
}, deps || []);
|
|
84
530
|
return state;
|
|
85
531
|
}
|
|
532
|
+
// 时间格式跟随界面语言:宿主 locale 服务的快照带 active('zh' | 'en'),
|
|
533
|
+
// zh 映射成 zh-CN,其余直接当 BCP 47 用。取不到就退回 zh-CN——和旧行为一致,
|
|
534
|
+
// 不会因为宿主版本差异把时间显示成空。
|
|
535
|
+
const localeTag = () => {
|
|
536
|
+
try {
|
|
537
|
+
const snap = localeSvc && typeof localeSvc.getLocale === "function" ? localeSvc.getLocale() : null;
|
|
538
|
+
const active = snap && snap.active;
|
|
539
|
+
if (!active) return "zh-CN";
|
|
540
|
+
return active === "zh" ? "zh-CN" : String(active);
|
|
541
|
+
} catch { return "zh-CN"; }
|
|
542
|
+
};
|
|
86
543
|
const fmtTime = (iso) => {
|
|
87
|
-
try {
|
|
544
|
+
try {
|
|
545
|
+
const d = new Date(iso);
|
|
546
|
+
if (Number.isNaN(d.getTime())) return String(iso);
|
|
547
|
+
return d.toLocaleString(localeTag(), { hour12: false });
|
|
548
|
+
} catch { return String(iso); }
|
|
88
549
|
};
|
|
89
550
|
|
|
90
551
|
// ── 心跳状态卡片 ──────────────────────────────────────────────
|
|
91
552
|
function StatusCard() {
|
|
92
553
|
const { loading, error, value } = useAsync(() => rpc("status"), []);
|
|
93
554
|
React.useEffect(() => {
|
|
94
|
-
const
|
|
95
|
-
return () => clearInterval(
|
|
555
|
+
const timer = setInterval(() => { rpc("status").then((v) => setStateSafe(v)).catch(() => {}); }, 30000);
|
|
556
|
+
return () => clearInterval(timer);
|
|
96
557
|
}, []);
|
|
97
558
|
const stateRef = React.useRef(null);
|
|
98
559
|
function setStateSafe(v) { stateRef.current = v; force(); }
|
|
99
560
|
const [, force] = React.useReducer((x) => x + 1, 0);
|
|
100
561
|
const view = stateRef.current || value;
|
|
101
|
-
if (loading && !view) return React.createElement("div", { style: hintStyle }, "
|
|
102
|
-
if (error) return React.createElement("div", { style: hintStyle }, "
|
|
562
|
+
if (loading && !view) return React.createElement("div", { style: hintStyle }, t("common.loading"));
|
|
563
|
+
if (error) return React.createElement("div", { style: hintStyle }, L("status.loadFailed", { error }));
|
|
103
564
|
const lb = view.lastBeat || {};
|
|
104
|
-
const verdictText = lb.verdict === "spoke" ? "
|
|
105
|
-
: lb.verdict === "silent" ? "
|
|
106
|
-
: lb.verdict === "spoke_failed" ? "
|
|
107
|
-
: lb.verdict === "error" ? "
|
|
565
|
+
const verdictText = lb.verdict === "spoke" ? L("status.spoke", { text: (lb.text || "").slice(0, 60) })
|
|
566
|
+
: lb.verdict === "silent" ? L("status.silent", { reason: lb.reason || "" })
|
|
567
|
+
: lb.verdict === "spoke_failed" ? L("status.spokeFailed", { reason: lb.reason || "" })
|
|
568
|
+
: lb.verdict === "error" ? L("status.error", { reason: lb.reason || "" }) : t("status.none");
|
|
108
569
|
const sb = view.statusbar || {};
|
|
109
|
-
const
|
|
110
|
-
"quiet-hours": "
|
|
111
|
-
"just-spoke": "
|
|
112
|
-
"wandering": "
|
|
113
|
-
"busy": "
|
|
114
|
-
"present": "
|
|
115
|
-
"away": "
|
|
570
|
+
const SCENE_KEYS = {
|
|
571
|
+
"quiet-hours": "scene.quietHours",
|
|
572
|
+
"just-spoke": "scene.justSpoke",
|
|
573
|
+
"wandering": "scene.wandering",
|
|
574
|
+
"busy": "scene.busy",
|
|
575
|
+
"present": "scene.present",
|
|
576
|
+
"away": "scene.away",
|
|
116
577
|
};
|
|
578
|
+
const sceneLabel = sb.lastStatus ? (SCENE_KEYS[sb.lastStatus.scene] ? t(SCENE_KEYS[sb.lastStatus.scene]) : sb.lastStatus.scene) : "";
|
|
117
579
|
const statusText = sb.lastStatus
|
|
118
|
-
?
|
|
119
|
-
|
|
580
|
+
? (sb.lastStatus.note
|
|
581
|
+
? L("status.currentWithNote", { scene: sceneLabel, note: sb.lastStatus.note })
|
|
582
|
+
: L("status.current", { scene: sceneLabel }))
|
|
583
|
+
: t("status.currentEmpty");
|
|
584
|
+
const usedNum = (view.cap && Number(view.cap.used)) || 0;
|
|
585
|
+
const maxNum = (view.cap && Number(view.cap.max)) || 0;
|
|
586
|
+
const ratio = maxNum > 0 ? Math.min(1, usedNum / maxNum) : 0;
|
|
587
|
+
const tile = (label, value, hint, extra) => React.createElement(
|
|
588
|
+
"div",
|
|
589
|
+
{ className: "hb-tile" + (extra ? " " + extra : "") },
|
|
590
|
+
React.createElement("span", { className: "hb-tileLabel" }, label),
|
|
591
|
+
React.createElement("span", { className: "hb-tileValue" }, value),
|
|
592
|
+
hint ? React.createElement("span", { className: "hb-tileHint" }, hint) : null,
|
|
593
|
+
);
|
|
594
|
+
const mood = view.quiet
|
|
595
|
+
? { cls: "hb-badgeOff", text: t("status.quiet") }
|
|
596
|
+
: { cls: "hb-badgeOk", text: L("status.rhythm", { interval: view.intervalMin }) };
|
|
597
|
+
const timeInjectText = sb.timeInjectMin === 0 ? t("status.timeInjectOff")
|
|
598
|
+
: L("status.timeInjectEvery", { interval: sb.timeInjectMin, last: sb.lastTimeInjectAt ? fmtTime(sb.lastTimeInjectAt) : t("status.never") });
|
|
599
|
+
const barClass = ratio >= 1 ? "hb-barFill hb-barFillWarn" : "hb-barFill";
|
|
120
600
|
return React.createElement(
|
|
121
601
|
"div",
|
|
122
|
-
{
|
|
123
|
-
React.createElement(
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
602
|
+
{ className: "hb-body" },
|
|
603
|
+
React.createElement(
|
|
604
|
+
"div",
|
|
605
|
+
{ className: "hb-card" },
|
|
606
|
+
React.createElement("div", { className: "hb-cardHead" },
|
|
607
|
+
React.createElement("span", { className: "hb-cardTitle" }, t("section.status")),
|
|
608
|
+
React.createElement("span", { className: "hb-badge " + mood.cls },
|
|
609
|
+
React.createElement("i", { className: "hb-dot" }),
|
|
610
|
+
mood.text)),
|
|
611
|
+
React.createElement("div", { className: "hb-grid" },
|
|
612
|
+
tile(t("status.lastBeatShort"), lb.at ? fmtTime(lb.at) : t("common.unknown")),
|
|
613
|
+
tile(t("status.versionShort"), "v" + (view.version || t("common.unknown"))),
|
|
614
|
+
React.createElement("div", { className: "hb-tile" },
|
|
615
|
+
React.createElement("span", { className: "hb-tileLabel" }, t("status.todaySimple")),
|
|
616
|
+
React.createElement("span", { className: "hb-tileValue" }, usedNum + " / " + maxNum),
|
|
617
|
+
React.createElement("div", { className: "hb-bar" },
|
|
618
|
+
React.createElement("div", { className: barClass, style: { width: Math.round(ratio * 100) + "%" } }))),
|
|
619
|
+
tile(t("status.timeInjectShort"), timeInjectText),
|
|
620
|
+
tile(t("status.resultShort"), verdictText, null, "hb-tileWide"),
|
|
621
|
+
tile(t("status.currentShort"),
|
|
622
|
+
sb.enabled === false ? L("status.statusbarOff", { status: statusText }) : statusText,
|
|
623
|
+
null, "hb-tileWide hb-tileAccent"),
|
|
624
|
+
),
|
|
625
|
+
),
|
|
132
626
|
);
|
|
133
627
|
}
|
|
134
628
|
|
|
@@ -145,8 +639,8 @@ window.__ModuleLoader__.load({
|
|
|
145
639
|
);
|
|
146
640
|
}, []);
|
|
147
641
|
React.useEffect(() => { reload(); }, [reload]);
|
|
148
|
-
if (error) return React.createElement("div", { style: hintStyle }, "
|
|
149
|
-
if (!data) return React.createElement("div", { style: hintStyle }, "
|
|
642
|
+
if (error) return React.createElement("div", { style: hintStyle }, L("common.loadFailed", { error }));
|
|
643
|
+
if (!data) return React.createElement("div", { style: hintStyle }, t("common.loading"));
|
|
150
644
|
const bound = data.sessions.filter((s) => s.deliver || s.observe);
|
|
151
645
|
const doUnbind = (id) => rpc("bindings.remove", { sessionId: id }).then(reload, (e) => setError(String(e).slice(0, 100)));
|
|
152
646
|
const doBind = (id, deliver, observe) => rpc("bindings.add", { sessionId: id, deliver, observe }).then(reload, (e) => setError(String(e).slice(0, 100)));
|
|
@@ -160,39 +654,41 @@ window.__ModuleLoader__.load({
|
|
|
160
654
|
};
|
|
161
655
|
const flagStyle = (on) => (on ? buttonGhost : { ...buttonGhost, opacity: 0.5 });
|
|
162
656
|
// 会话名:宿主从 projcache 取 title;无 title 时回退 id 前缀
|
|
163
|
-
const nameOf = (s) => s.title || (s.home ? "
|
|
657
|
+
const nameOf = (s) => s.title || (s.home ? t("sessions.homeName") : s.id.slice(0, 19) + "…");
|
|
164
658
|
const q = query.trim().toLowerCase();
|
|
165
659
|
const matches = (s) => !q || nameOf(s).toLowerCase().includes(q) || s.id.toLowerCase().includes(q);
|
|
166
660
|
const unbound = data.sessions.filter((s) => !s.deliver && !s.observe && matches(s));
|
|
661
|
+
const modesOf = (s) => (s.deliver && s.observe ? t("sessions.modesBoth") : s.deliver ? t("sessions.deliver") : t("sessions.observe"));
|
|
167
662
|
return React.createElement(
|
|
168
663
|
"div",
|
|
169
664
|
null,
|
|
170
|
-
React.createElement("div", { style:
|
|
665
|
+
React.createElement("div", { style: blockHead }, t("section.sessions")),
|
|
666
|
+
React.createElement("div", { style: hintStyle }, t("sessions.hint")),
|
|
171
667
|
bound.map((s) => React.createElement("div", { key: s.id, style: rowList },
|
|
172
668
|
React.createElement("span", { style: { flex: 1, fontSize: 12 } },
|
|
173
|
-
"
|
|
669
|
+
L("sessions.boundRow", { name: nameOf(s), modes: modesOf(s) })),
|
|
174
670
|
React.createElement("span", { style: { display: "flex", gap: 4 } },
|
|
175
|
-
React.createElement("button", { style: flagStyle(s.deliver), title: s.deliver ? "
|
|
176
|
-
React.createElement("button", { style: flagStyle(s.observe), title: s.observe ? "
|
|
177
|
-
React.createElement("button", { style: buttonGhost, onClick: () => doUnbind(s.id) }, "
|
|
671
|
+
React.createElement("button", { style: flagStyle(s.deliver), title: s.deliver ? t("sessions.deliverTitleOn") : t("sessions.deliverTitleOff"), onClick: () => setFlags(s.id, !s.deliver, s.observe) }, (s.deliver ? "☑ " : "☐ ") + t("sessions.deliver")),
|
|
672
|
+
React.createElement("button", { style: flagStyle(s.observe), title: s.observe ? t("sessions.observeTitleOn") : t("sessions.observeTitleOff"), onClick: () => setFlags(s.id, s.deliver, !s.observe) }, (s.observe ? "☑ " : "☐ ") + t("sessions.observe")),
|
|
673
|
+
React.createElement("button", { style: buttonGhost, onClick: () => doUnbind(s.id) }, t("sessions.unbind")),
|
|
178
674
|
),
|
|
179
675
|
)),
|
|
180
|
-
bound.length === 0 ? React.createElement("div", { style: hintStyle }, "
|
|
676
|
+
bound.length === 0 ? React.createElement("div", { style: hintStyle }, t("sessions.noBound")) : null,
|
|
181
677
|
React.createElement("div", { style: rowStyle },
|
|
182
|
-
React.createElement("button", { style: buttonGhost, onClick: () => setShowUnbound(!showUnbound) }, showUnbound ? "
|
|
678
|
+
React.createElement("button", { style: buttonGhost, onClick: () => setShowUnbound(!showUnbound) }, showUnbound ? t("sessions.collapseUnbound") : L("sessions.bindOthers", { count: unbound.length }))),
|
|
183
679
|
showUnbound ? React.createElement(
|
|
184
680
|
"div",
|
|
185
681
|
null,
|
|
186
|
-
React.createElement("input", { style: { ...inputStyle, width: "100%", margin: "4px 0", boxSizing: "border-box" }, placeholder: "
|
|
187
|
-
unbound.length === 0 ? React.createElement("div", { style: hintStyle }, "
|
|
682
|
+
React.createElement("input", { style: { ...inputStyle, width: "100%", margin: "4px 0", boxSizing: "border-box" }, placeholder: t("sessions.filterPlaceholder"), value: query, onChange: (e) => setQuery(e.target.value) }),
|
|
683
|
+
unbound.length === 0 ? React.createElement("div", { style: hintStyle }, t("sessions.noMatch")) : null,
|
|
188
684
|
unbound.map((s) => React.createElement("div", { key: s.id, style: rowList },
|
|
189
|
-
React.createElement("span", { style: { flex: 1, fontSize: 12 } }, nameOf(s), s.home ? "
|
|
685
|
+
React.createElement("span", { style: { flex: 1, fontSize: 12 } }, nameOf(s), s.home ? t("sessions.homeNoBind") : ""),
|
|
190
686
|
s.home ? null : React.createElement(
|
|
191
687
|
"span",
|
|
192
688
|
{ style: { display: "flex", gap: 4 } },
|
|
193
|
-
React.createElement("button", { style: buttonStyle, onClick: () => doBind(s.id, true, false) }, "
|
|
194
|
-
React.createElement("button", { style: buttonGhost, onClick: () => doBind(s.id, false, true) }, "
|
|
195
|
-
React.createElement("button", { style: buttonGhost, onClick: () => doBind(s.id, true, true) }, "
|
|
689
|
+
React.createElement("button", { style: buttonStyle, onClick: () => doBind(s.id, true, false) }, t("sessions.bindDeliver")),
|
|
690
|
+
React.createElement("button", { style: buttonGhost, onClick: () => doBind(s.id, false, true) }, t("sessions.bindObserve")),
|
|
691
|
+
React.createElement("button", { style: buttonGhost, onClick: () => doBind(s.id, true, true) }, t("sessions.modesBoth")),
|
|
196
692
|
),
|
|
197
693
|
)),
|
|
198
694
|
) : null,
|
|
@@ -202,26 +698,48 @@ window.__ModuleLoader__.load({
|
|
|
202
698
|
// ── 素材池(v1.9.3 三版):话题 / 聊天 × 活跃 / 归档,四个按钮各看一类 ──
|
|
203
699
|
// 和画像分区同一套 tab 交互,风格统一;一次只看一类。
|
|
204
700
|
function SeedsSection() {
|
|
701
|
+
// 面板版新增文案(不改 DICT,仅本函数使用)
|
|
702
|
+
const TXT = {
|
|
703
|
+
filterPlaceholder: "关键字过滤(匹配 文本 / 标签 / 来源)",
|
|
704
|
+
filterClear: "清除",
|
|
705
|
+
filterNoMatch: "没有匹配关键字的条目,换个词试试",
|
|
706
|
+
filterHint: (n) => "过滤后剩 " + n + " 条",
|
|
707
|
+
used: (n) => "已用 " + n + " 次",
|
|
708
|
+
};
|
|
205
709
|
const [data, setData] = React.useState(null);
|
|
206
710
|
const [error, setError] = React.useState(null);
|
|
207
711
|
const [tab, setTab] = React.useState("topic");
|
|
208
712
|
const [confirmId, setConfirmId] = React.useState(null);
|
|
713
|
+
const [filter, setFilter] = React.useState("");
|
|
209
714
|
const reload = React.useCallback(() => {
|
|
210
715
|
rpc("seeds.list").then(setData, (e) => setError(String(e).slice(0, 100)));
|
|
211
716
|
}, []);
|
|
212
717
|
React.useEffect(() => { reload(); }, [reload]);
|
|
213
|
-
if (error) return React.createElement("div", { style: hintStyle }, "
|
|
214
|
-
if (!data) return React.createElement("div", { style: hintStyle }, "
|
|
718
|
+
if (error) return React.createElement("div", { style: hintStyle }, L("common.loadFailed", { error }));
|
|
719
|
+
if (!data) return React.createElement("div", { style: hintStyle }, t("common.loading"));
|
|
215
720
|
const act = (endpoint, id) => rpc(endpoint, { id }).then(reload, (e) => setError(String(e).slice(0, 100)));
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
721
|
+
// 两栏行:左侧标签行(tag/source 徽标 + 使用次数)+ 截断正文,
|
|
722
|
+
// 右侧操作按钮组;鼠标悬停正文可通过 title 看全文。
|
|
723
|
+
const seedRow = { ...rowList, alignItems: "flex-start", padding: "5px 0", borderBottom: "1px solid var(--dsw-alias-border-l2)" };
|
|
724
|
+
const chip = { flex: "none", fontSize: 11, lineHeight: "18px", padding: "0 6px", borderRadius: 6, background: "var(--dsw-alias-interactive-bg-hover, #444)", color: "var(--dsw-alias-label-secondary)" };
|
|
725
|
+
const row = (s, archived) => React.createElement("div", { key: s.id, style: seedRow },
|
|
726
|
+
React.createElement("div", { style: { flex: 1, minWidth: 0 } },
|
|
727
|
+
React.createElement("div", { style: { display: "flex", alignItems: "center", gap: 6, flexWrap: "wrap", marginBottom: 2 } },
|
|
728
|
+
React.createElement("span", { style: chip }, String(s.tag)),
|
|
729
|
+
React.createElement("span", { style: chip }, String(s.source)),
|
|
730
|
+
React.createElement("span", { style: hintStyle }, TXT.used(s.used || 0)),
|
|
731
|
+
),
|
|
732
|
+
React.createElement("div", { style: { fontSize: 12.5, wordBreak: "break-word", color: "var(--dsw-alias-label-secondary)" }, title: s.text },
|
|
733
|
+
String(s.text || "").length > 80 ? String(s.text).slice(0, 80) + "…" : String(s.text || "")),
|
|
734
|
+
),
|
|
735
|
+
React.createElement("span", { style: { display: "flex", gap: 4, flex: "none", paddingTop: 2 } },
|
|
736
|
+
archived
|
|
737
|
+
? React.createElement("button", { style: buttonGhost, onClick: () => act("seeds.restore", s.id) }, t("seeds.restore"))
|
|
738
|
+
: React.createElement("button", { style: buttonGhost, onClick: () => act("seeds.archive", s.id) }, t("seeds.archive")),
|
|
739
|
+
confirmId === s.id
|
|
740
|
+
? React.createElement("button", { style: { ...buttonStyle, background: "#e5484d" }, onClick: () => { setConfirmId(null); act("seeds.delete", s.id); } }, t("common.confirmDelete"))
|
|
741
|
+
: React.createElement("button", { style: buttonGhost, onClick: () => setConfirmId(s.id) }, t("common.delete")),
|
|
742
|
+
),
|
|
225
743
|
);
|
|
226
744
|
const isChat = (s) => (s.category || "topic") === "chat";
|
|
227
745
|
const topics = data.active.filter((s) => !isChat(s));
|
|
@@ -230,27 +748,45 @@ window.__ModuleLoader__.load({
|
|
|
230
748
|
const arcChats = data.archived.filter(isChat);
|
|
231
749
|
const archived = tab.indexOf("arc") === 0;
|
|
232
750
|
const chat = tab.indexOf("chat") >= 0;
|
|
233
|
-
const
|
|
751
|
+
const fullList = archived ? (chat ? arcChats : arcTopics) : (chat ? chats : topics);
|
|
752
|
+
// 本地关键字过滤:匹配 text / tag / source,大小写不敏感,不发请求
|
|
753
|
+
const kw = filter.trim().toLowerCase();
|
|
754
|
+
const hit = (s) => !kw
|
|
755
|
+
|| String(s.text || "").toLowerCase().indexOf(kw) >= 0
|
|
756
|
+
|| String(s.tag || "").toLowerCase().indexOf(kw) >= 0
|
|
757
|
+
|| String(s.source || "").toLowerCase().indexOf(kw) >= 0;
|
|
758
|
+
const list = fullList.filter(hit);
|
|
234
759
|
const tabButton = (key, label, count) => React.createElement("button", {
|
|
235
760
|
key,
|
|
236
761
|
style: tab === key ? buttonStyle : buttonGhost,
|
|
237
762
|
onClick: () => setTab(key),
|
|
238
|
-
},
|
|
763
|
+
}, L("common.labelWithCount", { label, count }));
|
|
764
|
+
// 空态二分:分类本身为空 vs 有关键字过滤后无结果,文案分开
|
|
765
|
+
const categoryEmpty = fullList.length === 0;
|
|
239
766
|
return React.createElement(
|
|
240
767
|
"div",
|
|
241
768
|
null,
|
|
242
|
-
React.createElement("div", { style: hintStyle }, "
|
|
769
|
+
React.createElement("div", { style: hintStyle }, L("seeds.activeSummary", { active: data.active.length, cap: data.cap, archived: data.archived.length })),
|
|
770
|
+
React.createElement("div", { style: rowStyle },
|
|
771
|
+
React.createElement("input", { style: { ...inputStyle, width: "100%", boxSizing: "border-box" }, placeholder: TXT.filterPlaceholder, value: filter, onChange: (e) => setFilter(e.target.value) }),
|
|
772
|
+
kw ? React.createElement("button", { style: buttonGhost, onClick: () => setFilter("") }, TXT.filterClear) : null,
|
|
773
|
+
),
|
|
243
774
|
React.createElement("div", { style: tabRow },
|
|
244
|
-
tabButton("topic", "
|
|
245
|
-
tabButton("chat", "
|
|
246
|
-
tabButton("arc-topic", "
|
|
247
|
-
tabButton("arc-chat", "
|
|
775
|
+
tabButton("topic", t("seeds.tabTopic"), topics.length),
|
|
776
|
+
tabButton("chat", t("seeds.tabChat"), chats.length),
|
|
777
|
+
tabButton("arc-topic", t("seeds.tabArchivedTopic"), arcTopics.length),
|
|
778
|
+
tabButton("arc-chat", t("seeds.tabArchivedChat"), arcChats.length)),
|
|
248
779
|
React.createElement("div", { style: hintStyle }, archived
|
|
249
|
-
? (chat ? "
|
|
250
|
-
: (chat ? "
|
|
780
|
+
? (chat ? t("seeds.hintArchivedChat") : t("seeds.hintArchivedTopic"))
|
|
781
|
+
: (chat ? t("seeds.hintChat") : t("seeds.hintTopic"))),
|
|
251
782
|
list.length === 0
|
|
252
|
-
? React.createElement("div", { style: hintStyle },
|
|
253
|
-
|
|
783
|
+
? React.createElement("div", { style: hintStyle },
|
|
784
|
+
categoryEmpty
|
|
785
|
+
? (archived ? t("seeds.emptyArchived") : t("seeds.empty"))
|
|
786
|
+
: TXT.filterNoMatch)
|
|
787
|
+
: React.createElement("div", { style: scrollBox },
|
|
788
|
+
kw ? React.createElement("div", { style: { ...hintStyle, padding: "2px 0" } }, TXT.filterHint(list.length)) : null,
|
|
789
|
+
list.map((s) => row(s, archived))),
|
|
254
790
|
);
|
|
255
791
|
}
|
|
256
792
|
|
|
@@ -258,6 +794,12 @@ window.__ModuleLoader__.load({
|
|
|
258
794
|
// 首编继承出厂:第一次增删/存时段时,插件自动把出厂 interests.json
|
|
259
795
|
// 完整复制进 data/settings/interests.json,之后卡片就是唯一入口。
|
|
260
796
|
function InterestsSection() {
|
|
797
|
+
// 面板版新增文案(不改 DICT,仅本函数使用)
|
|
798
|
+
const TXT = {
|
|
799
|
+
stats: (n, m) => "当前兴趣 " + n + " 条 · 浏览时段 " + m + " 个",
|
|
800
|
+
// 如实说明:rpc 没有返回「出厂默认 / 已改过」标记字段,只能显示当前生效条数
|
|
801
|
+
statsNote: "面板暂无法区分出厂默认与已改过(接口未返回该标记),以上为当前生效条数",
|
|
802
|
+
};
|
|
261
803
|
const [data, setData] = React.useState(null);
|
|
262
804
|
const [error, setError] = React.useState(null);
|
|
263
805
|
const [status, setStatus] = React.useState("");
|
|
@@ -271,91 +813,101 @@ window.__ModuleLoader__.load({
|
|
|
271
813
|
}, (e) => setError(String(e).slice(0, 100)));
|
|
272
814
|
}, []);
|
|
273
815
|
React.useEffect(() => { reload(); }, [reload]);
|
|
274
|
-
if (error) return React.createElement("div", { style: hintStyle }, "
|
|
275
|
-
if (!data) return React.createElement("div", { style: hintStyle }, "
|
|
816
|
+
if (error) return React.createElement("div", { style: hintStyle }, L("common.loadFailed", { error }));
|
|
817
|
+
if (!data) return React.createElement("div", { style: hintStyle }, t("common.loading"));
|
|
276
818
|
const interests = data.interests || [];
|
|
819
|
+
const windowsCount = (data._schedule?.windows || []).length;
|
|
277
820
|
const doAdd = () => {
|
|
278
821
|
const text = draft.trim();
|
|
279
822
|
if (!text) return;
|
|
280
823
|
rpc("interests.add", { text }).then(
|
|
281
|
-
() => { setDraft(""); setStatus("
|
|
282
|
-
(e) => setStatus("
|
|
824
|
+
() => { setDraft(""); setStatus(t("interests.added")); reload(); },
|
|
825
|
+
(e) => setStatus(L("interests.addFailed", { error: String(e).slice(0, 80) })),
|
|
283
826
|
);
|
|
284
827
|
};
|
|
285
828
|
const doRemove = (text) => rpc("interests.remove", { text }).then(
|
|
286
|
-
() => { setConfirmText(null); setStatus("
|
|
287
|
-
(e) => { setConfirmText(null); setStatus("
|
|
829
|
+
() => { setConfirmText(null); setStatus(t("interests.deleted")); reload(); },
|
|
830
|
+
(e) => { setConfirmText(null); setStatus(L("interests.deleteFailed", { error: String(e).slice(0, 80) })); },
|
|
288
831
|
);
|
|
289
832
|
const saveWindows = () => {
|
|
290
833
|
rpc("interests.setWindows", { windows: draftWindows }).then(
|
|
291
|
-
() => { setStatus("
|
|
292
|
-
(e) => setStatus("
|
|
834
|
+
() => { setStatus(t("interests.savedWindows")); reload(); },
|
|
835
|
+
(e) => setStatus(L("interests.saveFailed", { error: String(e).slice(0, 80) })),
|
|
293
836
|
);
|
|
294
837
|
};
|
|
295
838
|
const editWindow = (idx, field, value) => setDraftWindows((ws) => ws.map((w, i) => (i === idx ? { ...w, [field]: value } : w)));
|
|
296
839
|
return React.createElement(
|
|
297
840
|
"div",
|
|
298
841
|
null,
|
|
299
|
-
React.createElement("div", { style: hintStyle
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
842
|
+
React.createElement("div", { style: { ...hintStyle, fontWeight: 600, color: "var(--dsw-alias-label-secondary)" } },
|
|
843
|
+
TXT.stats(interests.length, windowsCount)),
|
|
844
|
+
React.createElement("div", { style: hintStyle }, TXT.statsNote),
|
|
845
|
+
React.createElement("div", { style: hintStyle }, t("interests.hint")),
|
|
846
|
+
interests.map((item) => React.createElement("div", { key: item, style: rowList },
|
|
847
|
+
React.createElement("span", { style: { flex: 1, fontSize: 12 } }, item),
|
|
848
|
+
confirmText === item
|
|
849
|
+
? React.createElement("button", { style: { ...buttonStyle, background: "#e5484d" }, onClick: () => doRemove(item) }, t("common.confirmDelete"))
|
|
850
|
+
: React.createElement("button", { style: buttonGhost, onClick: () => setConfirmText(item) }, t("common.delete")),
|
|
305
851
|
)),
|
|
306
|
-
interests.length === 0 ? React.createElement("div", { style: hintStyle }, "
|
|
852
|
+
interests.length === 0 ? React.createElement("div", { style: hintStyle }, t("interests.empty")) : null,
|
|
307
853
|
React.createElement("div", { style: rowStyle },
|
|
308
|
-
React.createElement("input", { style: { ...inputStyle, width: 240 }, placeholder: "
|
|
309
|
-
React.createElement("button", { style: buttonStyle, onClick: doAdd }, "
|
|
854
|
+
React.createElement("input", { style: { ...inputStyle, width: 240 }, placeholder: t("interests.placeholder"), value: draft, onChange: (e) => setDraft(e.target.value), onKeyDown: (e) => { if (e.key === "Enter") doAdd(); } }),
|
|
855
|
+
React.createElement("button", { style: buttonStyle, onClick: doAdd }, t("common.add")),
|
|
310
856
|
),
|
|
311
|
-
React.createElement("div", { style: { ...hintStyle, marginTop: 10 } }, "
|
|
857
|
+
React.createElement("div", { style: { ...hintStyle, marginTop: 10 } }, t("interests.windowsHint")),
|
|
312
858
|
(draftWindows || []).map((w, idx) => React.createElement("div", { key: idx, style: rowList },
|
|
313
859
|
React.createElement("input", { style: inputStyle, type: "time", value: w.start, onChange: (e) => editWindow(idx, "start", e.target.value) }),
|
|
314
|
-
React.createElement("span", { style: hintStyle }, "
|
|
860
|
+
React.createElement("span", { style: hintStyle }, t("interests.to")),
|
|
315
861
|
React.createElement("input", { style: inputStyle, type: "time", value: w.end, onChange: (e) => editWindow(idx, "end", e.target.value) }),
|
|
316
|
-
(draftWindows.length > 1) ? React.createElement("button", { style: buttonGhost, onClick: () => setDraftWindows((ws) => ws.filter((_, i) => i !== idx)) }, "
|
|
862
|
+
(draftWindows.length > 1) ? React.createElement("button", { style: buttonGhost, onClick: () => setDraftWindows((ws) => ws.filter((_, i) => i !== idx)) }, t("common.remove")) : null,
|
|
317
863
|
)),
|
|
318
864
|
React.createElement("div", { style: rowStyle },
|
|
319
|
-
React.createElement("button", { style: buttonGhost, onClick: () => setDraftWindows((ws) => [...(ws || []), { id: "", start: "11:00", end: "13:00" }]) }, "
|
|
320
|
-
React.createElement("button", { style: buttonStyle, onClick: saveWindows }, "
|
|
865
|
+
React.createElement("button", { style: buttonGhost, onClick: () => setDraftWindows((ws) => [...(ws || []), { id: "", start: "11:00", end: "13:00" }]) }, t("interests.addWindow")),
|
|
866
|
+
React.createElement("button", { style: buttonStyle, onClick: saveWindows }, t("interests.saveWindows")),
|
|
321
867
|
),
|
|
322
868
|
status ? React.createElement("div", { style: hintStyle }, status) : null,
|
|
323
869
|
);
|
|
324
870
|
}
|
|
325
871
|
|
|
326
|
-
// ──
|
|
327
|
-
// 一次只看一个分区,条目一条一块、正文自动换行;另给一个只读的
|
|
328
|
-
// 「引擎室输入」视图,直接回答「截断后引擎室到底看到了什么」。
|
|
872
|
+
// ── 画像入口共享常量(仅 ProfileSection 使用)────────────────────
|
|
329
873
|
const PARTITIONS = [
|
|
330
|
-
{ key: "interest",
|
|
331
|
-
{ key: "projects",
|
|
332
|
-
{ key: "comm",
|
|
333
|
-
{ key: "psy",
|
|
874
|
+
{ key: "interest", labelKey: "profile.tabInterest" },
|
|
875
|
+
{ key: "projects", labelKey: "profile.tabProjects" },
|
|
876
|
+
{ key: "comm", labelKey: "profile.tabComm" },
|
|
877
|
+
{ key: "psy", labelKey: "profile.tabPsy" },
|
|
334
878
|
];
|
|
335
879
|
const entryBox = { borderLeft: "2px solid var(--dsw-alias-border-l2)", paddingLeft: 8, margin: "6px 0" };
|
|
336
880
|
// v1.9.3:分区条目一多就顶到屏幕外,给个固定高度的滚动区。
|
|
337
881
|
const scrollBox = { maxHeight: 320, overflowY: "auto", padding: "4px 6px", border: "1px solid var(--dsw-alias-border-l2)", borderRadius: 6 };
|
|
338
|
-
|
|
882
|
+
|
|
339
883
|
const entryHead = { fontSize: 12, color: "var(--dsw-alias-label-tertiary)", marginBottom: 2, wordBreak: "break-word" };
|
|
340
884
|
const entryBody = { fontSize: 12.5, lineHeight: 1.65, whiteSpace: "pre-wrap", wordBreak: "break-word", color: "var(--dsw-alias-label-secondary)", margin: "2px 0" };
|
|
341
885
|
const tabRow = { display: "flex", flexWrap: "wrap", gap: 6, margin: "6px 0" };
|
|
886
|
+
|
|
887
|
+
// ── 画像入口(v2.0 → v2.1.0 面板版):四个分区 + 引擎室输入 ─────
|
|
888
|
+
// 一次只看一个分区,条目一条一块、正文自动换行;另给一个只读的
|
|
889
|
+
// 「引擎室输入」视图。新增:单条正文过长(约超 4 行)时默认收起,
|
|
890
|
+
// 点「展开全文」看全文;刷新 / 导出按钮保留。
|
|
342
891
|
function ProfileSection() {
|
|
892
|
+
// 面板版新增文案(不改 DICT,仅本函数使用)
|
|
893
|
+
const TXT = { expand: "展开全文", collapse: "收起" };
|
|
343
894
|
const [data, setData] = React.useState(null);
|
|
344
895
|
const [digest, setDigest] = React.useState(null);
|
|
345
896
|
const [tab, setTab] = React.useState("interest");
|
|
346
897
|
const [error, setError] = React.useState(null);
|
|
347
898
|
const [status, setStatus] = React.useState("");
|
|
899
|
+
const [expanded, setExpanded] = React.useState({});
|
|
348
900
|
const load = React.useCallback(() => {
|
|
349
901
|
rpc("profile.partitions").then(setData, (e) => setError(String(e).slice(0, 120)));
|
|
350
902
|
rpc("profile.digest").then(setDigest, () => { /* 引擎室输入是附加视图,失败不挡分区 */ });
|
|
351
903
|
}, []);
|
|
352
904
|
React.useEffect(() => { load(); }, [load]);
|
|
353
905
|
const doExport = () => rpc("profile.export").then(
|
|
354
|
-
(v) => setStatus("
|
|
906
|
+
(v) => setStatus(L("profile.exported", { path: v.path })),
|
|
355
907
|
(e) => setError(String(e).slice(0, 120)),
|
|
356
908
|
);
|
|
357
|
-
if (error) return React.createElement("div", { style: hintStyle }, "
|
|
358
|
-
if (!data) return React.createElement("div", { style: hintStyle }, "
|
|
909
|
+
if (error) return React.createElement("div", { style: hintStyle }, L("common.loadFailed", { error }));
|
|
910
|
+
if (!data) return React.createElement("div", { style: hintStyle }, t("common.loading"));
|
|
359
911
|
const groups = data.partitions || {};
|
|
360
912
|
const group = groups[tab] || { total: 0, valid: 0, entries: [] };
|
|
361
913
|
const entries = group.entries || [];
|
|
@@ -363,44 +915,61 @@ window.__ModuleLoader__.load({
|
|
|
363
915
|
key,
|
|
364
916
|
style: tab === key ? buttonStyle : buttonGhost,
|
|
365
917
|
onClick: () => setTab(key),
|
|
366
|
-
}, count === undefined ? label :
|
|
918
|
+
}, count === undefined ? label : L("common.labelWithCount", { label, count }));
|
|
919
|
+
// 单条折叠:超过约 4 行(>160 字符或 >4 个换行)才给折叠按钮;
|
|
920
|
+
// 展开状态按条目 key 记在组件 state,切换 tab / 刷新后回到收起态。
|
|
921
|
+
const isLong = (str) => { const s = String(str || ""); return s.length > 160 || s.split("\n").length > 4; };
|
|
922
|
+
const bodyStyle = (open) => open ? entryBody : {
|
|
923
|
+
...entryBody, display: "-webkit-box", WebkitLineClamp: 4, WebkitBoxOrient: "vertical", overflow: "hidden",
|
|
924
|
+
};
|
|
925
|
+
const entryKey = (e) => e.id || (String(e.topic) + String(e.content).slice(0, 12));
|
|
926
|
+
const entryView = (e) => {
|
|
927
|
+
const key = entryKey(e);
|
|
928
|
+
const open = expanded[key] === true;
|
|
929
|
+
return React.createElement("div", { key, style: entryBox },
|
|
930
|
+
React.createElement("div", { style: entryHead },
|
|
931
|
+
(e.topic || "") + "/" + (e.subTopic || "")
|
|
932
|
+
+ L("profile.conf", { value: Number(e.confidence || 0).toFixed(2) })
|
|
933
|
+
+ (e.temporal ? L("profile.temporal", { value: e.temporal }) : "")
|
|
934
|
+
+ (e.lowActivity ? t("profile.stale") : "")
|
|
935
|
+
+ (e.updatedAt ? L("profile.updated", { date: String(e.updatedAt).slice(0, 10) }) : "")),
|
|
936
|
+
React.createElement("div", { style: bodyStyle(open) }, e.content || ""),
|
|
937
|
+
isLong(e.content) ? React.createElement("button", {
|
|
938
|
+
style: { ...buttonGhost, height: 20, fontSize: 11, padding: "0 8px", marginTop: 2 },
|
|
939
|
+
onClick: () => setExpanded((m) => ({ ...m, [key]: !open })),
|
|
940
|
+
}, open ? TXT.collapse : TXT.expand) : null,
|
|
941
|
+
);
|
|
942
|
+
};
|
|
367
943
|
const om = (digest && digest.omitted) || { tact: 0, topic: 0, wander: 0 };
|
|
368
944
|
return React.createElement(
|
|
369
945
|
"div",
|
|
370
946
|
{ style: listStyle },
|
|
371
947
|
React.createElement("div", { style: tabRow },
|
|
372
|
-
PARTITIONS.map((p) => tabButton(p.key, p.
|
|
373
|
-
tabButton("__engine", "
|
|
948
|
+
PARTITIONS.map((p) => tabButton(p.key, t(p.labelKey), (groups[p.key] || {}).valid || 0)),
|
|
949
|
+
tabButton("__engine", t("profile.engine"))),
|
|
374
950
|
tab === "__engine"
|
|
375
951
|
? React.createElement("div", null,
|
|
376
952
|
React.createElement("div", { style: hintStyle }, digest
|
|
377
|
-
? "
|
|
378
|
-
: "
|
|
953
|
+
? L("profile.digest", { total: digest.totalChars, budget: digest.budgetChars, budgetState: digest.withinBudget ? t("profile.withinBudget") : t("profile.overBudget"), tact: om.tact, topic: om.topic, wander: om.wander })
|
|
954
|
+
: t("common.loading")),
|
|
379
955
|
React.createElement("div", { style: scrollBox },
|
|
380
956
|
React.createElement("div", null,
|
|
381
|
-
React.createElement("b", null, "
|
|
382
|
-
React.createElement("div", { style: entryBody }, (digest && digest.tact) ||
|
|
957
|
+
React.createElement("b", null, t("profile.tactFacet")),
|
|
958
|
+
React.createElement("div", { style: entryBody }, (digest && digest.tact) || t("common.empty"))),
|
|
383
959
|
React.createElement("div", null,
|
|
384
|
-
React.createElement("b", null, "
|
|
385
|
-
React.createElement("div", { style: entryBody }, (digest && digest.topic) ||
|
|
960
|
+
React.createElement("b", null, t("profile.topicFacet")),
|
|
961
|
+
React.createElement("div", { style: entryBody }, (digest && digest.topic) || t("common.empty"))),
|
|
386
962
|
React.createElement("div", null,
|
|
387
|
-
React.createElement("b", null, "
|
|
388
|
-
React.createElement("div", { style: entryBody }, (digest && digest.wander) ||
|
|
963
|
+
React.createElement("b", null, t("profile.wanderFacet")),
|
|
964
|
+
React.createElement("div", { style: entryBody }, (digest && digest.wander) || t("common.empty")))))
|
|
389
965
|
: React.createElement("div", null,
|
|
390
|
-
React.createElement("div", { style: hintStyle }, "
|
|
966
|
+
React.createElement("div", { style: hintStyle }, L("profile.valid", { valid: group.valid, historical: group.total - group.valid })),
|
|
391
967
|
entries.length === 0
|
|
392
|
-
? React.createElement("div", { style: hintStyle }, "
|
|
393
|
-
: React.createElement("div", { style: scrollBox }, entries.map((e) =>
|
|
394
|
-
React.createElement("div", { style: entryHead },
|
|
395
|
-
(e.topic || "") + "/" + (e.subTopic || "")
|
|
396
|
-
+ " conf " + Number(e.confidence || 0).toFixed(2)
|
|
397
|
-
+ (e.temporal ? " " + e.temporal : "")
|
|
398
|
-
+ (e.lowActivity ? " 久未验证" : "")
|
|
399
|
-
+ (e.updatedAt ? " 更新 " + String(e.updatedAt).slice(0, 10) : "")),
|
|
400
|
-
React.createElement("div", { style: entryBody }, e.content || ""))))),
|
|
968
|
+
? React.createElement("div", { style: hintStyle }, t("profile.emptyPartition"))
|
|
969
|
+
: React.createElement("div", { style: scrollBox }, entries.map((e) => entryView(e)))),
|
|
401
970
|
React.createElement("div", { style: rowStyle },
|
|
402
|
-
React.createElement("button", { style: buttonGhost, onClick: () => { load(); } }, "
|
|
403
|
-
React.createElement("button", { style: buttonGhost, onClick: () => { void doExport(); } }, "
|
|
971
|
+
React.createElement("button", { style: buttonGhost, onClick: () => { load(); } }, t("common.refresh")),
|
|
972
|
+
React.createElement("button", { style: buttonGhost, onClick: () => { void doExport(); } }, t("profile.exportMarkdown"))),
|
|
404
973
|
status ? React.createElement("div", { style: hintStyle }, status) : null,
|
|
405
974
|
);
|
|
406
975
|
}
|
|
@@ -431,6 +1000,45 @@ window.__ModuleLoader__.load({
|
|
|
431
1000
|
const [draftPsy, setDraftPsy] = React.useState(psyEnabled);
|
|
432
1001
|
const [status, setStatus] = React.useState("");
|
|
433
1002
|
React.useEffect(() => { setDraftInterval(interval); setDraftCap(cap); setDraftTimeInject(timeInject); setDraftStatusbar(statusbar); setDraftIdle(idleMode); setDraftTokenSaver(tokenSaver); setDraftPsy(psyEnabled); }, [interval, cap, timeInject, statusbar, idleMode, tokenSaver, psyEnabled]);
|
|
1003
|
+
// v2.1.0 面板改造:分组小节文案(局部常量,不进 DICT,暂只做中文)。
|
|
1004
|
+
const GROUP_RHYTHM = "节律";
|
|
1005
|
+
const GROUP_RHYTHM_DESC = "心跳多久跳一次、一天最多说几条。";
|
|
1006
|
+
const GROUP_TIME = "时间与状态栏";
|
|
1007
|
+
const GROUP_TIME_DESC = "给日常会话注入精确时间、在会话里挂一条心跳状态。";
|
|
1008
|
+
const GROUP_EXPRESS = "表达";
|
|
1009
|
+
const GROUP_EXPRESS_DESC = "心跳说话的方式与开销。";
|
|
1010
|
+
const GROUP_FOCUS = "专注模式";
|
|
1011
|
+
const GROUP_FOCUS_DESC = "需要安静时手动暂停心跳,到点自动恢复。它是即时生效的独立开关:点按钮立刻暂停/恢复,不走下面的「保存」。";
|
|
1012
|
+
// 「多久生效」依据 src/rpc.ts 的 config.set 实现判定:
|
|
1013
|
+
// intervalMin → applyHeartbeatInterval 立即重排定时器(保存后立刻生效);
|
|
1014
|
+
// 其余字段写入活引用/运行时 policy,每跳判定时读取(下一跳生效)。详见 manifest.md。
|
|
1015
|
+
const EFFECT_NOW = "多久生效:保存后定时器立刻按新间隔重排,下一次心跳就按新间隔走(无需重启)。";
|
|
1016
|
+
const EFFECT_NEXT = "多久生效:保存后从下一跳开始生效(无需重启)。";
|
|
1017
|
+
// 专注模式(v2.1.0 ①):即时动作,不走「保存」,和上面那堆参数分开。
|
|
1018
|
+
// 状态取 rpc 合并值(内存 + data/focus.json),所以 CLI 设的暂停这里也看得见。
|
|
1019
|
+
const [focus, setFocus] = React.useState(null);
|
|
1020
|
+
const [draftFocusMin, setDraftFocusMin] = React.useState(30);
|
|
1021
|
+
const [focusBusy, setFocusBusy] = React.useState(false);
|
|
1022
|
+
React.useEffect(() => {
|
|
1023
|
+
rpc("focus.status").then(setFocus, () => { /* 旧宿主无此端点:不显示状态,按钮仍可试 */ });
|
|
1024
|
+
}, []);
|
|
1025
|
+
const toggleFocus = async (pause) => {
|
|
1026
|
+
if (focusBusy) return;
|
|
1027
|
+
setFocusBusy(true);
|
|
1028
|
+
try {
|
|
1029
|
+
if (pause) {
|
|
1030
|
+
const minutes = Math.max(1, Math.min(1440, Math.floor(Number(draftFocusMin) || 30)));
|
|
1031
|
+
setFocus(await rpc("focus.pause", { minutes }));
|
|
1032
|
+
} else {
|
|
1033
|
+
await rpc("focus.resume");
|
|
1034
|
+
setFocus({ paused: false });
|
|
1035
|
+
}
|
|
1036
|
+
} catch (e) {
|
|
1037
|
+
setStatus(L("config.focusFailed", { error: String(e).slice(0, 80) }));
|
|
1038
|
+
} finally {
|
|
1039
|
+
setFocusBusy(false);
|
|
1040
|
+
}
|
|
1041
|
+
};
|
|
434
1042
|
const save = async () => {
|
|
435
1043
|
try {
|
|
436
1044
|
const di = Math.max(1, Math.min(1440, Math.floor(Number(draftInterval) || 0)));
|
|
@@ -446,45 +1054,64 @@ window.__ModuleLoader__.load({
|
|
|
446
1054
|
psyEnabled: !!draftPsy,
|
|
447
1055
|
});
|
|
448
1056
|
setValue(v);
|
|
449
|
-
setStatus("
|
|
1057
|
+
setStatus(t("config.saved"));
|
|
450
1058
|
} catch (e) {
|
|
451
|
-
setStatus("
|
|
1059
|
+
setStatus(L("config.saveFailed", { error: String(e).slice(0, 80) }));
|
|
452
1060
|
}
|
|
453
1061
|
};
|
|
454
|
-
if (loadErr && !value) return React.createElement("div", { style: hintStyle }, "
|
|
455
|
-
if (!value) return React.createElement("div", { style: hintStyle }, "
|
|
456
|
-
|
|
1062
|
+
if (loadErr && !value) return React.createElement("div", { style: hintStyle }, L("common.loadFailed", { error: loadErr }));
|
|
1063
|
+
if (!value) return React.createElement("div", { style: hintStyle }, t("common.loading"));
|
|
1064
|
+
// 分组小节的标题 + 一句人话说明;生效说明按 label 宽度(140 + gap 8)缩进对齐。
|
|
1065
|
+
const groupTitle = (title, desc) => React.createElement(
|
|
457
1066
|
"div",
|
|
458
1067
|
null,
|
|
1068
|
+
React.createElement("div", { style: { fontSize: 13, fontWeight: 600, margin: "10px 0 0" } }, title),
|
|
1069
|
+
React.createElement("div", { style: { ...hintStyle, margin: "2px 0" } }, desc));
|
|
1070
|
+
const paramRow = (label, control, hint, effect) => React.createElement(
|
|
1071
|
+
"div",
|
|
1072
|
+
{ style: { margin: "4px 0" } },
|
|
459
1073
|
React.createElement("div", { style: rowStyle },
|
|
460
|
-
React.createElement("span", { style: labelStyle },
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
1074
|
+
React.createElement("span", { style: labelStyle }, label),
|
|
1075
|
+
control,
|
|
1076
|
+
hint ? React.createElement("span", { style: hintStyle }, hint) : null),
|
|
1077
|
+
effect ? React.createElement("div", { style: { ...hintStyle, marginLeft: 148 } }, effect) : null);
|
|
1078
|
+
const toggleBtn = (on, set) => React.createElement("button", { style: on ? buttonStyle : buttonGhost, onClick: () => set(!on) }, on ? "☑ " + t("common.on") : "☐ " + t("common.off"));
|
|
1079
|
+
return React.createElement(
|
|
1080
|
+
"div",
|
|
1081
|
+
null,
|
|
1082
|
+
// ── 节律 ──
|
|
1083
|
+
groupTitle(GROUP_RHYTHM, GROUP_RHYTHM_DESC),
|
|
1084
|
+
paramRow(t("config.interval"),
|
|
1085
|
+
React.createElement("input", { style: inputStyle, type: "number", min: 1, max: 1440, value: draftInterval, onChange: (e) => setDraftInterval(e.target.value) }),
|
|
1086
|
+
null, EFFECT_NOW),
|
|
1087
|
+
paramRow(t("config.cap"),
|
|
1088
|
+
React.createElement("input", { style: inputStyle, type: "number", min: 1, max: 50, value: draftCap, onChange: (e) => setDraftCap(e.target.value) }),
|
|
1089
|
+
null, EFFECT_NEXT),
|
|
1090
|
+
// ── 时间与状态栏 ──
|
|
1091
|
+
groupTitle(GROUP_TIME, GROUP_TIME_DESC),
|
|
1092
|
+
paramRow(t("config.timeInject"),
|
|
467
1093
|
React.createElement("input", { style: inputStyle, type: "number", min: 0, max: 1440, value: draftTimeInject, onChange: (e) => setDraftTimeInject(e.target.value) }),
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
1094
|
+
t("config.timeInjectOff"), EFFECT_NEXT),
|
|
1095
|
+
paramRow(t("config.statusbar"), toggleBtn(draftStatusbar, setDraftStatusbar), t("config.statusbarHint"), EFFECT_NEXT),
|
|
1096
|
+
// ── 表达 ──
|
|
1097
|
+
groupTitle(GROUP_EXPRESS, GROUP_EXPRESS_DESC),
|
|
1098
|
+
paramRow(t("config.tokenSaver"), toggleBtn(draftTokenSaver, setDraftTokenSaver), t("config.tokenSaverHint"), EFFECT_NEXT),
|
|
1099
|
+
paramRow(t("config.psy"), toggleBtn(draftPsy, setDraftPsy), t("config.psyHint"), EFFECT_NEXT),
|
|
1100
|
+
paramRow(t("config.idle"), toggleBtn(draftIdle, setDraftIdle), t("config.idleHint"), EFFECT_NEXT),
|
|
1101
|
+
// ── 专注模式:即时动作,不进 draft 体系 ──
|
|
1102
|
+
groupTitle(GROUP_FOCUS, GROUP_FOCUS_DESC),
|
|
473
1103
|
React.createElement("div", { style: rowStyle },
|
|
474
|
-
React.createElement("span", { style: labelStyle }, "
|
|
475
|
-
React.createElement("
|
|
476
|
-
React.createElement("span", { style: hintStyle }, "
|
|
1104
|
+
React.createElement("span", { style: labelStyle }, t("config.focus")),
|
|
1105
|
+
React.createElement("input", { style: inputStyle, type: "number", min: 1, max: 1440, value: draftFocusMin, onChange: (e) => setDraftFocusMin(e.target.value) }),
|
|
1106
|
+
React.createElement("span", { style: hintStyle }, t("config.focusMinutes")),
|
|
1107
|
+
focus && focus.paused
|
|
1108
|
+
? React.createElement("button", { style: buttonStyle, disabled: focusBusy, onClick: () => { void toggleFocus(false); } }, t("config.focusResume"))
|
|
1109
|
+
: React.createElement("button", { style: buttonGhost, disabled: focusBusy, onClick: () => { void toggleFocus(true); } }, t("config.focusPause"))),
|
|
1110
|
+
React.createElement("div", { style: { ...hintStyle, marginLeft: 148 } }, focus && focus.paused ? L("config.focusPaused", { clock: focus.clock || "" }) : t("config.focusHint")),
|
|
1111
|
+
// ── 保存固定在分组最后;成功/失败提示沿用现有 status 逻辑 ──
|
|
477
1112
|
React.createElement("div", { style: rowStyle },
|
|
478
|
-
React.createElement("
|
|
479
|
-
React.createElement("
|
|
480
|
-
React.createElement("span", { style: hintStyle }, "你离开(闲置 ≥30 分钟)或锁屏时整跳暂停,回来自动恢复")),
|
|
481
|
-
React.createElement("div", { style: rowStyle },
|
|
482
|
-
React.createElement("span", { style: labelStyle }, "psy 分区"),
|
|
483
|
-
React.createElement("button", { style: draftPsy ? buttonStyle : buttonGhost, onClick: () => setDraftPsy(!draftPsy) }, draftPsy ? "☑ 开启" : "☐ 关闭"),
|
|
484
|
-
React.createElement("span", { style: hintStyle }, "允许画像记录 psy 分区(警告,开启后模型会主动猜测用户心理并计入用户画像,关闭时画像内容计入内容较少)")),
|
|
485
|
-
React.createElement("div", { style: rowStyle },
|
|
486
|
-
React.createElement("button", { style: buttonStyle, onClick: () => { void save(); } }, "保存"),
|
|
487
|
-
React.createElement("span", { style: hintStyle }, status || "全部参数保存后即时生效,无需重启")),
|
|
1113
|
+
React.createElement("button", { style: buttonStyle, onClick: () => { void save(); } }, t("common.save")),
|
|
1114
|
+
React.createElement("span", { style: status ? { ...hintStyle, fontWeight: 600 } : hintStyle }, status || t("config.saveHint"))),
|
|
488
1115
|
);
|
|
489
1116
|
}
|
|
490
1117
|
|
|
@@ -496,6 +1123,8 @@ window.__ModuleLoader__.load({
|
|
|
496
1123
|
const [error, setError] = React.useState(null);
|
|
497
1124
|
const [selected, setSelected] = React.useState("");
|
|
498
1125
|
const [text, setText] = React.useState(null);
|
|
1126
|
+
// v2.1.0 面板改造:正文收进「展开查看」折叠块,默认收起;列表与加载逻辑原样保留。
|
|
1127
|
+
const WEEKLY_SHOW = "展开查看报告正文";
|
|
499
1128
|
const loadReport = React.useCallback((file) => {
|
|
500
1129
|
setSelected(file);
|
|
501
1130
|
rpc("weekly.get", { file }).then((r) => setText(r.text), (e) => setError(String(e).slice(0, 100)));
|
|
@@ -511,13 +1140,13 @@ window.__ModuleLoader__.load({
|
|
|
511
1140
|
);
|
|
512
1141
|
}, [loadReport]);
|
|
513
1142
|
React.useEffect(() => { reload(); }, [reload]);
|
|
514
|
-
if (error) return React.createElement("div", { style: hintStyle }, "
|
|
515
|
-
if (!data) return React.createElement("div", { style: hintStyle }, "
|
|
1143
|
+
if (error) return React.createElement("div", { style: hintStyle }, L("common.loadFailed", { error }));
|
|
1144
|
+
if (!data) return React.createElement("div", { style: hintStyle }, t("common.loading"));
|
|
516
1145
|
return React.createElement(
|
|
517
1146
|
"div",
|
|
518
1147
|
null,
|
|
519
|
-
React.createElement("div", { style: hintStyle }, "
|
|
520
|
-
data.length === 0 ? React.createElement("div", { style: hintStyle }, "
|
|
1148
|
+
React.createElement("div", { style: hintStyle }, t("weekly.intro")),
|
|
1149
|
+
data.length === 0 ? React.createElement("div", { style: hintStyle }, t("weekly.empty")) : null,
|
|
521
1150
|
data.length > 1 ? React.createElement("div", { style: rowStyle },
|
|
522
1151
|
data.map((r) => React.createElement("button", {
|
|
523
1152
|
key: r.file,
|
|
@@ -525,9 +1154,12 @@ window.__ModuleLoader__.load({
|
|
|
525
1154
|
onClick: () => loadReport(r.file),
|
|
526
1155
|
}, r.end.slice(0, 10))),
|
|
527
1156
|
) : null,
|
|
528
|
-
text ? React.createElement("
|
|
1157
|
+
text ? React.createElement("details", { style: { margin: "4px 0" } },
|
|
1158
|
+
React.createElement("summary", { style: summaryStyle }, WEEKLY_SHOW),
|
|
1159
|
+
React.createElement("pre", { style: { whiteSpace: "pre-wrap", margin: "4px 0", fontSize: 12 } }, text),
|
|
1160
|
+
) : null,
|
|
529
1161
|
React.createElement("div", { style: rowStyle },
|
|
530
|
-
React.createElement("button", { style: buttonGhost, onClick: () => { void reload(); } }, "
|
|
1162
|
+
React.createElement("button", { style: buttonGhost, onClick: () => { void reload(); } }, t("common.refresh"))),
|
|
531
1163
|
);
|
|
532
1164
|
}
|
|
533
1165
|
|
|
@@ -541,100 +1173,182 @@ window.__ModuleLoader__.load({
|
|
|
541
1173
|
const [importPw, setImportPw] = React.useState("");
|
|
542
1174
|
const [status, setStatus] = React.useState("");
|
|
543
1175
|
const busy = React.useRef(false);
|
|
1176
|
+
// v2.1.0 面板改造:导入是危险操作(会用迁移包覆盖本机数据),加二次确认——
|
|
1177
|
+
// 第一次点只亮红色确认态并提示,再点一次才真正执行。
|
|
1178
|
+
const IMPORT_CONFIRM_LABEL = "确认导入(覆盖本机数据)";
|
|
1179
|
+
const IMPORT_CONFIRM_HINT = "⚠ 危险操作:导入会用迁移包覆盖本机的心跳数据(被替换的文件会自动备份)。确认路径和口令无误后,再点一次「确认导入」才会执行。";
|
|
1180
|
+
const [confirmImport, setConfirmImport] = React.useState(false);
|
|
544
1181
|
const run = (fn) => {
|
|
545
1182
|
if (busy.current) return;
|
|
546
1183
|
busy.current = true;
|
|
547
|
-
setStatus("
|
|
548
|
-
fn().catch((e) => setStatus("
|
|
1184
|
+
setStatus(t("migrate.processing"));
|
|
1185
|
+
fn().catch((e) => setStatus(L("migrate.failed", { error: String(e).slice(0, 120) }))).finally(() => { busy.current = false; });
|
|
549
1186
|
};
|
|
550
1187
|
const doExport = () => run(async () => {
|
|
551
|
-
if (!pw1 || pw1 !== pw2) { setStatus("
|
|
1188
|
+
if (!pw1 || pw1 !== pw2) { setStatus(t("migrate.pwMismatch")); return; }
|
|
552
1189
|
const v = await rpc("migrate.export", { passphrase: pw1 });
|
|
553
1190
|
setPw1(""); setPw2("");
|
|
554
|
-
setStatus("
|
|
1191
|
+
setStatus(L("migrate.exported", { count: v.count, path: v.path }));
|
|
555
1192
|
});
|
|
556
1193
|
const doImport = () => run(async () => {
|
|
557
|
-
if (!importFile || !importPw) { setStatus("
|
|
1194
|
+
if (!importFile || !importPw) { setStatus(t("migrate.needInput")); return; }
|
|
558
1195
|
const v = await rpc("migrate.import", { file: importFile.trim(), passphrase: importPw });
|
|
559
1196
|
setImportPw("");
|
|
560
|
-
setStatus("
|
|
1197
|
+
setStatus(L("migrate.imported", { restored: v.restored.length, backedUp: v.backedUp.length, skipped: v.skipped.length }));
|
|
561
1198
|
});
|
|
1199
|
+
const onImportClick = () => {
|
|
1200
|
+
if (!confirmImport) {
|
|
1201
|
+
setConfirmImport(true);
|
|
1202
|
+
setStatus(IMPORT_CONFIRM_HINT);
|
|
1203
|
+
return;
|
|
1204
|
+
}
|
|
1205
|
+
setConfirmImport(false);
|
|
1206
|
+
void doImport();
|
|
1207
|
+
};
|
|
562
1208
|
return React.createElement(
|
|
563
1209
|
"div",
|
|
564
1210
|
null,
|
|
565
|
-
React.createElement("div", { style: hintStyle }, "
|
|
566
|
-
React.createElement("div", { style: { ...hintStyle, marginTop: 6, fontWeight: 600 } }, "
|
|
1211
|
+
React.createElement("div", { style: hintStyle }, t("migrate.intro")),
|
|
1212
|
+
React.createElement("div", { style: { ...hintStyle, marginTop: 6, fontWeight: 600 } }, t("migrate.exportHeading")),
|
|
567
1213
|
React.createElement("div", { style: rowStyle },
|
|
568
|
-
React.createElement("input", { style: inputStyle, type: "password", placeholder: "
|
|
569
|
-
React.createElement("input", { style: inputStyle, type: "password", placeholder: "
|
|
570
|
-
React.createElement("button", { style: buttonStyle, onClick: () => { void doExport(); } }, "
|
|
1214
|
+
React.createElement("input", { style: inputStyle, type: "password", placeholder: t("migrate.pwPlaceholder"), value: pw1, onChange: (e) => setPw1(e.target.value) }),
|
|
1215
|
+
React.createElement("input", { style: inputStyle, type: "password", placeholder: t("migrate.pwAgainPlaceholder"), value: pw2, onChange: (e) => setPw2(e.target.value) }),
|
|
1216
|
+
React.createElement("button", { style: buttonStyle, onClick: () => { void doExport(); } }, t("migrate.exportButton")),
|
|
571
1217
|
),
|
|
572
|
-
React.createElement("div", { style: { ...hintStyle, marginTop: 6, fontWeight: 600 } }, "
|
|
1218
|
+
React.createElement("div", { style: { ...hintStyle, marginTop: 6, fontWeight: 600 } }, t("migrate.importHeading")),
|
|
573
1219
|
React.createElement("div", { style: rowStyle },
|
|
574
|
-
React.createElement("input", { style: { ...inputStyle, width: 220 }, placeholder: "
|
|
575
|
-
React.createElement("input", { style: inputStyle, type: "password", placeholder: "
|
|
576
|
-
|
|
1220
|
+
React.createElement("input", { style: { ...inputStyle, width: 220 }, placeholder: t("migrate.filePlaceholder"), value: importFile, onChange: (e) => { setImportFile(e.target.value); setConfirmImport(false); } }),
|
|
1221
|
+
React.createElement("input", { style: inputStyle, type: "password", placeholder: t("migrate.pwPlaceholderShort"), value: importPw, onChange: (e) => { setImportPw(e.target.value); setConfirmImport(false); } }),
|
|
1222
|
+
confirmImport
|
|
1223
|
+
? React.createElement("button", { style: { ...buttonStyle, background: "#e5484d" }, onClick: onImportClick }, IMPORT_CONFIRM_LABEL)
|
|
1224
|
+
: React.createElement("button", { style: buttonStyle, onClick: onImportClick }, t("migrate.importButton")),
|
|
577
1225
|
),
|
|
578
1226
|
status ? React.createElement("div", { style: hintStyle }, status) : null,
|
|
579
1227
|
);
|
|
580
1228
|
}
|
|
581
1229
|
|
|
582
1230
|
// ── 主卡片 ────────────────────────────────────────────────────
|
|
583
|
-
|
|
1231
|
+
const PANEL_TABS = [
|
|
1232
|
+
{ id: "status", labelKey: "panel.tab.status" },
|
|
1233
|
+
{ id: "sessions", labelKey: "panel.tab.sessions" },
|
|
1234
|
+
{ id: "seeds", labelKey: "panel.tab.seeds" },
|
|
1235
|
+
{ id: "interests", labelKey: "panel.tab.interests" },
|
|
1236
|
+
{ id: "profile", labelKey: "panel.tab.profile" },
|
|
1237
|
+
{ id: "weekly", labelKey: "panel.tab.weekly" },
|
|
1238
|
+
{ id: "config", labelKey: "panel.tab.config" },
|
|
1239
|
+
];
|
|
1240
|
+
// 账本 + 摘抄本:原 HeartbeatSection 内联块原样迁出(含两条 rpc 调用)。
|
|
1241
|
+
function LedgerExcerptBlocks() {
|
|
584
1242
|
const [ledgerMsg, setLedgerMsg] = React.useState("");
|
|
585
1243
|
const openLedger = () => rpc("ledger.open").then(
|
|
586
|
-
(v) => setLedgerMsg("
|
|
587
|
-
(e) => setLedgerMsg("
|
|
1244
|
+
(v) => setLedgerMsg(L("ledger.opened", { path: v.path })),
|
|
1245
|
+
(e) => setLedgerMsg(L("ledger.failed", { error: String(e).slice(0, 80) })),
|
|
588
1246
|
);
|
|
589
1247
|
const [excerptMsg, setExcerptMsg] = React.useState("");
|
|
590
1248
|
const openExcerpt = () => rpc("excerpt.open").then(
|
|
591
|
-
(v) => setExcerptMsg("
|
|
592
|
-
(e) => setExcerptMsg("
|
|
1249
|
+
(v) => setExcerptMsg(L("excerpt.opened", { path: v.path })),
|
|
1250
|
+
(e) => setExcerptMsg(L("excerpt.failed", { error: String(e).slice(0, 80) })),
|
|
593
1251
|
);
|
|
594
1252
|
return React.createElement(
|
|
595
1253
|
"div",
|
|
596
|
-
|
|
597
|
-
React.createElement(
|
|
598
|
-
React.createElement(
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
React.createElement(
|
|
602
|
-
React.createElement(
|
|
603
|
-
"
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
))
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
1254
|
+
null,
|
|
1255
|
+
React.createElement("div", { style: blockHead }, t("section.ledger")),
|
|
1256
|
+
React.createElement("div", { style: rowStyle },
|
|
1257
|
+
React.createElement("button", { style: buttonStyle, onClick: () => { void openLedger(); } }, t("ledger.open")),
|
|
1258
|
+
React.createElement("span", { style: hintStyle }, ledgerMsg || t("ledger.hint"))),
|
|
1259
|
+
React.createElement("div", { style: blockHead }, t("section.excerpt")),
|
|
1260
|
+
React.createElement("div", { style: rowStyle },
|
|
1261
|
+
React.createElement("button", { style: buttonStyle, onClick: () => { void openExcerpt(); } }, t("excerpt.open")),
|
|
1262
|
+
React.createElement("span", { style: hintStyle }, excerptMsg || t("excerpt.hint"))),
|
|
1263
|
+
);
|
|
1264
|
+
}
|
|
1265
|
+
function HeartbeatSection(props) {
|
|
1266
|
+
ensurePanelStyle();
|
|
1267
|
+
const [tab, setTab] = React.useState("status");
|
|
1268
|
+
// 槽位契约(PluginConfigViewProps.view):'page' 是主视图;'summary' 只回
|
|
1269
|
+
// 一行标题。shiori 参考实现完全忽略 view 且生产可用(契约也标注 page
|
|
1270
|
+
// only),这里防御性处理,不影响 page 路径。
|
|
1271
|
+
if (props && props.view === "summary") {
|
|
1272
|
+
return React.createElement("div", { className: "hb-row" },
|
|
1273
|
+
React.createElement("span", { className: "hb-badge hb-badgeInfo" }, t("panel.title")));
|
|
1274
|
+
}
|
|
1275
|
+
// 非状态页统一套一张卡(带卡头标题),视觉上和其他卡对齐
|
|
1276
|
+
const card = (title, node) => React.createElement("div", { className: "hb-card" },
|
|
1277
|
+
React.createElement("div", { className: "hb-cardHead" },
|
|
1278
|
+
React.createElement("span", { className: "hb-cardTitle" }, title)),
|
|
1279
|
+
node);
|
|
1280
|
+
return React.createElement(
|
|
1281
|
+
"div",
|
|
1282
|
+
{ className: "hb-panel" },
|
|
1283
|
+
React.createElement("div", { className: "hb-hero" },
|
|
1284
|
+
React.createElement("div", { className: "hb-heroTop" },
|
|
1285
|
+
React.createElement("div", { className: "hb-logo" },
|
|
1286
|
+
React.createElement("svg", { width: 21, height: 21, viewBox: "0 0 24 24", fill: "none" },
|
|
1287
|
+
React.createElement("path", {
|
|
1288
|
+
d: "M2 12h4l2.2-5.2 3.2 10.4 2.6-5.2H22",
|
|
1289
|
+
stroke: "#fff", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round",
|
|
1290
|
+
}))),
|
|
1291
|
+
React.createElement("div", { className: "hb-heroText" },
|
|
1292
|
+
React.createElement("span", { className: "hb-heroTitle" }, t("panel.title")),
|
|
1293
|
+
React.createElement("span", { className: "hb-heroSub" }, t("panel.subtitle"))),
|
|
1294
|
+
React.createElement("div", { className: "hb-heroRight" },
|
|
1295
|
+
React.createElement("span", { className: "hb-badge hb-badgeInfo" }, t("panel.badgeNative"))))),
|
|
1296
|
+
// tab 栏:状态 / 会话 / 素材 / 兴趣 / 画像 / 周报 / 设置,状态默认选中
|
|
1297
|
+
React.createElement("div", { className: "hb-tabs" }, PANEL_TABS.map((entry) =>
|
|
1298
|
+
React.createElement("button", {
|
|
1299
|
+
key: entry.id,
|
|
1300
|
+
className: tab === entry.id ? "hb-tab hb-tabOn" : "hb-tab",
|
|
1301
|
+
onClick: () => setTab(entry.id),
|
|
1302
|
+
}, t(entry.labelKey)))),
|
|
1303
|
+
// 内容区:容器只切换,不装业务逻辑
|
|
1304
|
+
React.createElement("div", { className: "hb-body" },
|
|
1305
|
+
tab === "status" ? React.createElement(StatusCard, null) : null,
|
|
1306
|
+
tab === "sessions" ? card(t("panel.tab.sessions"), React.createElement(SessionsSection, null)) : null,
|
|
1307
|
+
tab === "seeds" ? card(t("panel.tab.seeds"), React.createElement(SeedsSection, null)) : null,
|
|
1308
|
+
tab === "interests" ? card(t("panel.tab.interests"), React.createElement(InterestsSection, null)) : null,
|
|
1309
|
+
tab === "profile" ? card(t("panel.tab.profile"), React.createElement(ProfileSection, null)) : null,
|
|
1310
|
+
tab === "weekly" ? card(t("panel.tab.weekly"), React.createElement(WeeklySection, null)) : null,
|
|
1311
|
+
tab === "config" ? React.createElement(
|
|
1312
|
+
"div",
|
|
1313
|
+
{ className: "hb-body" },
|
|
1314
|
+
React.createElement("div", { className: "hb-card" },
|
|
1315
|
+
React.createElement("div", { className: "hb-cardHead" },
|
|
1316
|
+
React.createElement("span", { className: "hb-cardTitle" }, t("section.config"))),
|
|
1317
|
+
React.createElement(ConfigSection, null)),
|
|
1318
|
+
React.createElement("div", { className: "hb-card" },
|
|
1319
|
+
React.createElement("div", { className: "hb-cardHead" },
|
|
1320
|
+
React.createElement("span", { className: "hb-cardTitle" }, t("section.migrate"))),
|
|
1321
|
+
React.createElement(MigrateSection, null)),
|
|
1322
|
+
React.createElement("div", { className: "hb-card" },
|
|
1323
|
+
React.createElement(LedgerExcerptBlocks, null)),
|
|
1324
|
+
) : null,
|
|
1325
|
+
),
|
|
619
1326
|
);
|
|
620
1327
|
}
|
|
621
1328
|
|
|
622
1329
|
try {
|
|
623
|
-
ctx.slots.inject("
|
|
624
|
-
|
|
625
|
-
|
|
1330
|
+
ctx.slots.inject("plugins.bundle.config", function () {
|
|
1331
|
+
const disposer = ctx.slots.register(
|
|
1332
|
+
// key 必须等于宿主报的 bundle 名(pkg.name),不是 npm 包名:
|
|
1333
|
+
// package.json 是 @kanadego/dsh-heartbeat,但 plugin-manager 的
|
|
1334
|
+
// packageView 取的是 bundle.name = "dsh-heartbeat"(详情页 data-plugin-name)。
|
|
1335
|
+
{ name: "plugins.bundle.config", key: "dsh-heartbeat" },
|
|
626
1336
|
HeartbeatSection,
|
|
627
1337
|
);
|
|
1338
|
+
return disposer;
|
|
628
1339
|
});
|
|
629
1340
|
} catch (e) {
|
|
630
|
-
|
|
1341
|
+
// v2.1.0 起旧设置页面板退役:不再往 settings.section 挂第二份 UI。
|
|
1342
|
+
// 宿主 0.2.1 起就有 plugins.bundle.config,宿主过旧时面板不可用,
|
|
1343
|
+
// 这里只留下一条明确提示,不再造一个观感落后的降级副本。
|
|
1344
|
+
console.warn("[dsh-heartbeat] plugins.bundle.config 注册失败,面板不可用(需要 DSH 0.2.1 及以上):" + ((e && e.message) || e));
|
|
631
1345
|
}
|
|
632
1346
|
}
|
|
633
1347
|
|
|
634
1348
|
// settingsScope deliberately absent: removed in DSH 0.1.7 (its client
|
|
635
1349
|
// service no longer exists; declaring it stalls the whole client bundle
|
|
636
1350
|
// on a "waiting for service" and blocks the web UI from booting).
|
|
637
|
-
exports.inject = ["slots", "sessions"];
|
|
1351
|
+
exports.inject = ["slots", "sessions", "locale"];
|
|
638
1352
|
exports.apply = apply;
|
|
639
1353
|
return module.exports;
|
|
640
1354
|
},
|