dsh-wechat-access 0.0.0-stage → 0.0.2
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/CHANGELOG.md +56 -0
- package/LICENSE +675 -0
- package/README.md +278 -2
- package/cordis.patch.yml +5 -0
- package/examples/config.example.json +98 -0
- package/index.mjs +123 -0
- package/lib/access.mjs +131 -0
- package/lib/anysearch.mjs +143 -0
- package/lib/capabilities.mjs +312 -0
- package/lib/client.js +2532 -0
- package/lib/config.mjs +509 -0
- package/lib/emotion-store.mjs +352 -0
- package/lib/emotion.mjs +428 -0
- package/lib/endocrine/LICENSE +21 -0
- package/lib/endocrine/README.md +39 -0
- package/lib/endocrine/diseases.js +791 -0
- package/lib/endocrine/engine.mjs +131 -0
- package/lib/endocrine/store.mjs +253 -0
- package/lib/endocrine/upstream.mjs +1230 -0
- package/lib/group-gate.mjs +305 -0
- package/lib/imagegen.mjs +360 -0
- package/lib/lock.mjs +204 -0
- package/lib/meme-classify.mjs +190 -0
- package/lib/memes.mjs +442 -0
- package/lib/memory.mjs +437 -0
- package/lib/normalize.mjs +230 -0
- package/lib/parser.mjs +602 -0
- package/lib/reply-settled.mjs +130 -0
- package/lib/runtime.mjs +3367 -0
- package/lib/startup.mjs +70 -0
- package/lib/steam-binding.mjs +144 -0
- package/lib/steam.mjs +334 -0
- package/lib/store.mjs +259 -0
- package/lib/thoughts.mjs +149 -0
- package/lib/time-context.mjs +182 -0
- package/lib/tools.mjs +583 -0
- package/lib/ui.mjs +997 -0
- package/lib/util.mjs +489 -0
- package/lib/virtual-life-generate.mjs +421 -0
- package/lib/virtual-life.mjs +971 -0
- package/lib/weather.mjs +172 -0
- package/lib/wechat-client.mjs +476 -0
- package/lib/wechat-events.mjs +269 -0
- package/locale/zh.json +6 -0
- package/package.json +77 -4
package/lib/client.js
ADDED
|
@@ -0,0 +1,2532 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "dsh-wechat-access",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
const module = { exports: {} };
|
|
5
|
+
const exports = module.exports;
|
|
6
|
+
const React = require("react");
|
|
7
|
+
const { createElement: h, useCallback, useEffect, useState } = React;
|
|
8
|
+
|
|
9
|
+
const API = "/dsh-wechat/api";
|
|
10
|
+
// 项目主页。只放图标按钮,不在界面上明文显示链接。
|
|
11
|
+
const REPO_URL = "https://github.com/Applepinea/dsh-wechat-access";
|
|
12
|
+
const WX_REPO_URL = "https://github.com/thisnick/agent-wechat";
|
|
13
|
+
const WX_RELEASE_URL = "https://github.com/thisnick/agent-wechat/releases";
|
|
14
|
+
const CSS_ID = "dsh-wechat-access/panel.css";
|
|
15
|
+
const CSS = [
|
|
16
|
+
".wxa{max-width:780px;display:flex;flex-direction:column;gap:14px;color:var(--dsw-alias-label-primary);height:100%;max-height:min(100%, calc(100vh - 88px));min-height:0;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;scrollbar-gutter:stable;scrollbar-width:thin;padding-right:8px;box-sizing:border-box}",
|
|
17
|
+
".wxa::-webkit-scrollbar{width:10px}",
|
|
18
|
+
".wxa::-webkit-scrollbar-thumb{background:rgba(127,127,127,.35);border-radius:999px;border:3px solid transparent;background-clip:content-box}",
|
|
19
|
+
".wxa::-webkit-scrollbar-thumb:hover{background:rgba(127,127,127,.55);background-clip:content-box}",
|
|
20
|
+
".wxa::-webkit-scrollbar-track{background:transparent}",
|
|
21
|
+
".wxa h2{margin:0;font-size:16px;font-weight:500;line-height:24px}",
|
|
22
|
+
".wxa .sub{color:var(--dsw-alias-label-tertiary);font-size:12.5px;line-height:19px;margin:0}",
|
|
23
|
+
".wxa .card{border:.5px solid var(--dsw-alias-border-l2);border-radius:10px;padding:14px 16px;display:flex;flex-direction:column;gap:10px}",
|
|
24
|
+
".wxa .cardT{font-size:13px;font-weight:600;line-height:20px;display:flex;align-items:center;gap:8px}",
|
|
25
|
+
".wxa .row{display:flex;justify-content:space-between;align-items:center;gap:10px 16px;flex-wrap:wrap}",
|
|
26
|
+
".wxa .row>div:first-child{flex:1;min-width:180px}",
|
|
27
|
+
".wxa .lbl{font-size:13px;line-height:19px}",
|
|
28
|
+
".wxa .hint{color:var(--dsw-alias-label-tertiary);font-size:11.5px;line-height:17px;margin-top:3px}",
|
|
29
|
+
".wxa input[type=text],.wxa input[type=number],.wxa select,.wxa textarea{background:transparent;border:1px solid var(--dsw-alias-border-l2);border-radius:6px;color:var(--dsw-alias-label-primary);font-size:12.5px;padding:5px 8px;outline:none;font-family:inherit}",
|
|
30
|
+
".wxa input[type=text],.wxa input[type=number],.wxa select{height:28px;min-width:170px}",
|
|
31
|
+
".wxa textarea{width:100%;min-height:110px;line-height:18px;resize:vertical}",
|
|
32
|
+
".wxa button{background:var(--dsw-alias-brand-primary);color:var(--dsw-alias-label-primary-foreground,#fff);border:none;border-radius:6px;font-size:12.5px;height:30px;padding:0 12px;cursor:pointer}",
|
|
33
|
+
".wxa button.ghost{background:transparent;border:1px solid var(--dsw-alias-border-l2);color:var(--dsw-alias-label-primary)}",
|
|
34
|
+
// 纯图标按钮:正方形、无文字。和 ghost 一样的外观,只是宽度收窄。
|
|
35
|
+
".wxa button.icon{width:30px;padding:0;display:inline-flex;align-items:center;justify-content:center}",
|
|
36
|
+
".wxa button.icon svg{display:block}",
|
|
37
|
+
".wxa button:disabled{opacity:.5;cursor:default}",
|
|
38
|
+
".wxa .badge{font-size:11px;line-height:16px;padding:1px 8px;border-radius:999px;background:rgba(127,127,127,.15);color:var(--dsw-alias-label-secondary)}",
|
|
39
|
+
".wxa .ok{background:rgba(46,160,67,.16);color:var(--dsw-alias-label-primary)}",
|
|
40
|
+
".wxa .bad{background:rgba(220,53,69,.16);color:var(--dsw-alias-label-primary)}",
|
|
41
|
+
".wxa .msg{font-size:12px;line-height:18px;white-space:pre-line}",
|
|
42
|
+
".wxa .msg.err{color:var(--dsw-alias-state-error-primary)}",
|
|
43
|
+
".wxa .sw{display:inline-flex;align-items:center;gap:6px;font-size:12.5px}",
|
|
44
|
+
".wxa .quicknav{display:flex;flex-wrap:wrap;gap:6px 10px;align-items:center;padding:8px 10px;border:.5px solid var(--dsw-alias-border-l2);border-radius:10px;background:rgba(127,127,127,.05)}",
|
|
45
|
+
".wxa .quicknav a{color:var(--dsw-alias-link,var(--dsw-alias-brand-primary));font-size:12px;line-height:18px;text-decoration:none;padding:2px 6px;border-radius:6px;white-space:nowrap}",
|
|
46
|
+
".wxa .quicknav a:hover{background:rgba(127,127,127,.12);text-decoration:underline}",
|
|
47
|
+
// 15 个链接平铺成一片时,找「生图」得一个一个念。按语义分成四组小胶囊,
|
|
48
|
+
// 每组前有 2 个字的组名,眼睛先跳到组再找条目,比线性扫快。
|
|
49
|
+
".wxa .quicknav .qngrp{display:inline-flex;flex-wrap:wrap;align-items:center;gap:0 2px;padding:1px 7px 1px 8px;border-radius:8px;background:rgba(127,127,127,.055)}",
|
|
50
|
+
".wxa .quicknav .qng{font-size:11px;line-height:18px;color:var(--dsw-alias-label-tertiary);margin-right:3px;user-select:none}",
|
|
51
|
+
".wxa .quicknav .qnlbl{font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary);margin-right:2px}",
|
|
52
|
+
// UI 优化:跳转条吸顶。面板有 18 张卡片,滚到中间时原来那条已经看不见了,
|
|
53
|
+
// 想跳到另一张卡只能先滚回顶部。sticky 在 .wxa 这个滚动容器里生效,不需要 JS。
|
|
54
|
+
".wxa .quicknav.sticky{position:sticky;top:0;z-index:6;background:var(--dsw-alias-bg-primary,#fff);box-shadow:0 2px 8px rgba(0,0,0,.05)}",
|
|
55
|
+
// 吸底保存条:只在页尾那一条,滚到任何位置都贴着底边。
|
|
56
|
+
// 原来保存按钮只在最上和最下,改中间的设置时两个都不在视野里,很容易改完忘了存。
|
|
57
|
+
".wxa .savebar{position:sticky;bottom:0;z-index:6;display:flex;align-items:center;gap:10px;padding:8px 10px;border:.5px solid var(--dsw-alias-border-l2);border-radius:10px;background:var(--dsw-alias-bg-primary,#fff);box-shadow:0 -2px 10px rgba(0,0,0,.06)}",
|
|
58
|
+
".wxa .savebar .grow{flex:1;min-width:0}",
|
|
59
|
+
// 卡片折叠按钮:放在标题行右端,纯图标。
|
|
60
|
+
".wxa .cardT button.fold{margin-left:auto;background:transparent;border:none;color:var(--dsw-alias-label-tertiary);height:22px;width:22px;padding:0;display:inline-flex;align-items:center;justify-content:center;border-radius:5px}",
|
|
61
|
+
".wxa .cardT button.fold:hover{background:rgba(127,127,127,.14);color:var(--dsw-alias-label-primary)}",
|
|
62
|
+
// 折叠后卡片只剩标题一行,加个浅底把「它被收起来了」和「它是空卡片」区分开。
|
|
63
|
+
".wxa .card.folded>.cardT{opacity:.75}",
|
|
64
|
+
".wxa .card.folded{padding:10px 16px;gap:0}",
|
|
65
|
+
].join("");
|
|
66
|
+
|
|
67
|
+
function ensureCss() {
|
|
68
|
+
if (document.getElementById(CSS_ID)) return;
|
|
69
|
+
const el = document.createElement("style");
|
|
70
|
+
el.id = CSS_ID;
|
|
71
|
+
el.textContent = CSS;
|
|
72
|
+
document.head.appendChild(el);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const splitIds = (value) => String(value ?? "").split(/[,\s]+/).map((x) => x.trim()).filter(Boolean);
|
|
76
|
+
|
|
77
|
+
const CARD_IDS = {
|
|
78
|
+
"模型": "card-model", "自动回复": "card-reply", "回复范围": "card-access",
|
|
79
|
+
"虚拟人生": "card-life", "情感与关系": "card-emotion", "内分泌": "card-endocrine",
|
|
80
|
+
"长期记忆": "card-memory", "表情包": "card-memes", "回复节奏": "card-rate",
|
|
81
|
+
"Steam": "card-steam", "生图": "card-image", "人格设定": "card-persona",
|
|
82
|
+
"归档": "card-archive", "链接解析": "card-link",
|
|
83
|
+
};
|
|
84
|
+
function Card(props) {
|
|
85
|
+
// UI 优化:按标题自动分配锚点 id,调用处写法不变(面板测试按源码文本校验)。
|
|
86
|
+
const domId = props.id || CARD_IDS[props.title];
|
|
87
|
+
// 18 张设置卡片平铺时一屏放不下一张半,想翻到「生图」要滚很久,所以可折叠。
|
|
88
|
+
//
|
|
89
|
+
// 只有拿到稳定 domId 的卡片才给折叠按钮。引导屏那几张(「接下来」
|
|
90
|
+
// 「配置教程」「管理员」)标题是动态的或没登记,domId 是 undefined —— 它们本来就
|
|
91
|
+
// 要求全文可见,折叠是干扰;而且共用同一个 undefined 键会让折叠状态互相串台。
|
|
92
|
+
//
|
|
93
|
+
// useState 无条件调用:Hook 数量必须恒定,即使这张卡不允许折叠。
|
|
94
|
+
const foldable = Boolean(domId);
|
|
95
|
+
const [foldedRaw, setFolded] = useState(() => {
|
|
96
|
+
if (!foldable) return false;
|
|
97
|
+
try { return window.localStorage.getItem("wxa.fold." + domId) === "1"; } catch (e) { return false; }
|
|
98
|
+
});
|
|
99
|
+
const folded = foldable && foldedRaw;
|
|
100
|
+
const toggleFold = () => {
|
|
101
|
+
if (!foldable) return;
|
|
102
|
+
setFolded((v) => {
|
|
103
|
+
const next = !v;
|
|
104
|
+
try { window.localStorage.setItem("wxa.fold." + domId, next ? "1" : "0"); } catch (e) { /* 隐私模式下不可写 */ }
|
|
105
|
+
return next;
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
return h("div", { className: "card" + (folded ? " folded" : ""), id: domId },
|
|
109
|
+
h("div", { className: "cardT" },
|
|
110
|
+
props.title,
|
|
111
|
+
foldable ? h("button", {
|
|
112
|
+
className: "fold", type: "button",
|
|
113
|
+
title: folded ? "展开" : "折叠",
|
|
114
|
+
"aria-label": folded ? "展开" : "折叠",
|
|
115
|
+
"aria-expanded": folded ? "false" : "true",
|
|
116
|
+
onClick: toggleFold,
|
|
117
|
+
}, folded ? "▸" : "▾") : null,
|
|
118
|
+
),
|
|
119
|
+
folded ? null : props.children,
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function Switch(props) {
|
|
124
|
+
return h("label", { className: "sw" },
|
|
125
|
+
h("input", { type: "checkbox", checked: Boolean(props.checked), onChange: (e) => props.onChange(e.target.checked), disabled: props.disabled }),
|
|
126
|
+
h("span", null, props.checked ? "已开启" : "已关闭"));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
// 常见城市的大致经纬度(市区级,误差几公里完全够用)。
|
|
131
|
+
// 唯一用途是交叉校验:面板里「城市」和经纬度有没有明显打架。
|
|
132
|
+
// 之前城市名被默认值覆盖过而经纬度没动,界面上看不出任何异常,
|
|
133
|
+
// 只能等查回来的天气不对才发现地点错了。
|
|
134
|
+
const CITY_POINTS = {
|
|
135
|
+
杭州: [30.27, 120.16], 上海: [31.23, 121.47], 北京: [39.90, 116.41],
|
|
136
|
+
广州: [23.13, 113.26], 深圳: [22.54, 114.06], 成都: [30.57, 104.07],
|
|
137
|
+
重庆: [29.56, 106.55], 南京: [32.06, 118.80], 武汉: [30.59, 114.31],
|
|
138
|
+
西安: [34.34, 108.94], 厦门: [24.48, 118.09], 天津: [39.13, 117.20],
|
|
139
|
+
苏州: [31.30, 120.58], 青岛: [36.07, 120.38], 长沙: [28.23, 112.94],
|
|
140
|
+
合肥: [31.82, 117.23], 郑州: [34.75, 113.63], 沈阳: [41.81, 123.43],
|
|
141
|
+
哈尔滨: [45.80, 126.53], 昆明: [25.04, 102.72], 福州: [26.07, 119.30],
|
|
142
|
+
宁波: [29.87, 121.55], 无锡: [31.49, 120.31], 温州: [27.99, 120.70],
|
|
143
|
+
南昌: [28.68, 115.86], 贵阳: [26.65, 106.63], 兰州: [36.06, 103.83],
|
|
144
|
+
济南: [36.65, 117.12], 大连: [38.91, 121.61], 太原: [37.87, 112.55],
|
|
145
|
+
香港: [22.32, 114.17], 台北: [25.03, 121.56], 澳门: [22.19, 113.54],
|
|
146
|
+
华盛顿: [38.90, -77.04], 纽约: [40.71, -74.01], 洛杉矶: [34.05, -118.24],
|
|
147
|
+
旧金山: [37.77, -122.42], 西雅图: [47.61, -122.33],
|
|
148
|
+
伦敦: [51.51, -0.13], 巴黎: [48.86, 2.35], 柏林: [52.52, 13.40],
|
|
149
|
+
东京: [35.68, 139.69], 大阪: [34.69, 135.50], 首尔: [37.57, 126.98],
|
|
150
|
+
新加坡: [1.35, 103.82], 吉隆坡: [3.14, 101.69], 曼谷: [13.76, 100.50],
|
|
151
|
+
悉尼: [-33.87, 151.21], 墨尔本: [-37.81, 144.96],
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
function haversineKm(lat1, lon1, lat2, lon2) {
|
|
155
|
+
const rad = Math.PI / 180;
|
|
156
|
+
const dLat = (lat2 - lat1) * rad;
|
|
157
|
+
const dLon = (lon2 - lon1) * rad;
|
|
158
|
+
const a = Math.sin(dLat / 2) ** 2 + Math.cos(lat1 * rad) * Math.cos(lat2 * rad) * Math.sin(dLon / 2) ** 2;
|
|
159
|
+
return 6371 * 2 * Math.asin(Math.min(1, Math.sqrt(a)));
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// 返回 { km } = 明显对不上;返回 null = 没法判断(城市不在表里,或经纬度不是数字)。
|
|
163
|
+
function cityDistanceWarning(city, lat, lon) {
|
|
164
|
+
const point = CITY_POINTS[String(city ?? "").trim()];
|
|
165
|
+
if (!point) return null;
|
|
166
|
+
// Number("") 是 0,会被当成合法坐标,所以空串要先挡掉。
|
|
167
|
+
if (String(lat ?? "").trim() === "" || String(lon ?? "").trim() === "") return null;
|
|
168
|
+
const la = Number(lat);
|
|
169
|
+
const lo = Number(lon);
|
|
170
|
+
if (!Number.isFinite(la) || !Number.isFinite(lo)) return null;
|
|
171
|
+
if (la < -90 || la > 90 || lo < -180 || lo > 180) return null;
|
|
172
|
+
const km = haversineKm(la, lo, point[0], point[1]);
|
|
173
|
+
return km > 200 ? { km: Math.round(km) } : null;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function WechatPanel() {
|
|
177
|
+
const [state, setState] = useState(null);
|
|
178
|
+
const [form, setForm] = useState(null);
|
|
179
|
+
const [busy, setBusy] = useState(false);
|
|
180
|
+
const [msg, setMsg] = useState("");
|
|
181
|
+
const [err, setErr] = useState("");
|
|
182
|
+
// Model picker state. `catalog` is what the Host can route right now;
|
|
183
|
+
// choosing "follow default" leaves config.model unset.
|
|
184
|
+
const [catalog, setCatalog] = useState({ groups: [], default: null, failures: [] });
|
|
185
|
+
// 「推理等级」的可选档位由宿主按「服务商 + 模型」现算:不同模型支持的档位不一样,
|
|
186
|
+
// 写死一份列表迟早会和服务端对不上,写进去的等级就会被 Host 拒掉。
|
|
187
|
+
const [reasoning, setReasoning] = useState({ provider: "", model: "", efforts: [], defaultEffort: null, supported: true, error: "" });
|
|
188
|
+
// Sticker library snapshot: stats + the two lists the panel renders.
|
|
189
|
+
const [memes, setMemes] = useState(null);
|
|
190
|
+
// Virtual life snapshot: the generated week plus wardrobe and meal pools.
|
|
191
|
+
const [life, setLife] = useState(null);
|
|
192
|
+
// Per-conversation proactive switches, loaded from the archive.
|
|
193
|
+
const [targets, setTargets] = useState([]);
|
|
194
|
+
// 主动发动态:调度快照 + 上次发布结果。
|
|
195
|
+
// 情感与关系:档案列表 + 统计。
|
|
196
|
+
const [emotion, setEmotion] = useState(null);
|
|
197
|
+
// 长期记忆:按人汇总的记忆档案。
|
|
198
|
+
const [memory, setMemory] = useState(null);
|
|
199
|
+
const [endocrine, setEndocrine] = useState(null);
|
|
200
|
+
// 本周安排默认折叠:一周 7 天的详细日程很长,默认展开会把下面所有设置挤下去。
|
|
201
|
+
const [weekOpen, setWeekOpen] = useState(false);
|
|
202
|
+
// 主动消息测试结果,只在点过按钮后显示。
|
|
203
|
+
const [proactiveTest, setProactiveTest] = useState(null);
|
|
204
|
+
// 有没有未保存的改动。只在用户改了表单之后置真,
|
|
205
|
+
// 加载和保存成功时清零 —— 否则刷新完就显示「有未保存修改」,等于误导。
|
|
206
|
+
const [dirty, setDirty] = useState(false);
|
|
207
|
+
// 首次配置:没有配置文件时面板只显示这一屏。
|
|
208
|
+
// 只问管理员号和守护进程地址;其余默认值由服务端 bootstrapConfig 生成,
|
|
209
|
+
// 让新用户手打密钥等于劝退。
|
|
210
|
+
const [boot, setBoot] = useState({ ownerId: "", baseUrl: "http://127.0.0.1:6174/v1", token: "", busy: false, done: false });
|
|
211
|
+
// 「配置教程」抽屉:首次配置流程。
|
|
212
|
+
// 很多人装完之后不知道守护进程在哪 ——
|
|
213
|
+
// 让他们不用去翻 GitHub 就能看到。
|
|
214
|
+
const [showGuide, setShowGuide] = useState(false);
|
|
215
|
+
// Steam 绑定表:只在面板里可改(聊天里没有绑定工具)。
|
|
216
|
+
const [steamBindings, setSteamBindings] = useState(null);
|
|
217
|
+
// 绑定表单做成「多行草稿」:绑定成功后那一行变成「✓ 已绑定」,
|
|
218
|
+
// 并自动多出一个空行,方便一次绑好几个账号,不用反复点。
|
|
219
|
+
const [steamDrafts, setSteamDrafts] = useState([{ id: 1, peer: "", steamId: "", done: false }]);
|
|
220
|
+
const [steamBindBusy, setSteamBindBusy] = useState(false);
|
|
221
|
+
|
|
222
|
+
const load = useCallback(async ({ keepSecrets = false } = {}) => {
|
|
223
|
+
setErr("");
|
|
224
|
+
try {
|
|
225
|
+
const res = await fetch(API + "/state", { credentials: "same-origin" });
|
|
226
|
+
const data = await res.json();
|
|
227
|
+
if (!data.ok) throw new Error(data.error || "读取失败");
|
|
228
|
+
setState(data);
|
|
229
|
+
// The catalog is advisory: a failure here must not break the whole panel.
|
|
230
|
+
try {
|
|
231
|
+
const cat = await (await fetch(API + "/models", { credentials: "same-origin" })).json();
|
|
232
|
+
if (cat.ok) setCatalog({ groups: cat.groups ?? [], default: cat.default ?? null, failures: cat.failures ?? [] });
|
|
233
|
+
} catch (e) { /* keep the previous catalog */ }
|
|
234
|
+
const chosen = data.config.model ?? null;
|
|
235
|
+
setForm((prev) => ({
|
|
236
|
+
replyPrivate: data.config.reply.private !== false,
|
|
237
|
+
replyGroup: data.config.reply.group ?? "off",
|
|
238
|
+
smartThreshold: data.config.reply.smartThreshold ?? 3,
|
|
239
|
+
selfNames: (data.config.reply.selfNames ?? []).join(","),
|
|
240
|
+
interests: (data.config.reply.interests ?? []).join(","),
|
|
241
|
+
learnInterests: data.config.reply.learnInterests !== false,
|
|
242
|
+
avoidRepeat: data.config.reply.avoidRepeat !== false,
|
|
243
|
+
repeatThreshold: data.config.reply.repeatThreshold ?? 0.7,
|
|
244
|
+
sharedAgent: data.config.reply.sharedAgent === true,
|
|
245
|
+
privateIds: (data.config.access.privateIds ?? []).join(","),
|
|
246
|
+
groupIds: (data.config.access.groupIds ?? []).join(","),
|
|
247
|
+
blockedUsers: (data.config.access.blockedUsers ?? []).join(","),
|
|
248
|
+
blockedGroups: (data.config.access.blockedGroups ?? []).join(","),
|
|
249
|
+
groupMode: data.config.access.groupMode ?? "all",
|
|
250
|
+
ownerIds: (data.config.ownerIds ?? []).join(","),
|
|
251
|
+
persona: data.config.persona ?? "",
|
|
252
|
+
retentionDays: data.config.retentionDays ?? 30,
|
|
253
|
+
retentionForever: Number(data.config.retentionDays ?? 30) === 0,
|
|
254
|
+
pollSeconds: Math.round((data.config.poll?.intervalMs ?? 60000) / 1000),
|
|
255
|
+
debounceSec: Math.round((data.config.reply?.debounceMs ?? 1200) / 1000 * 10) / 10,
|
|
256
|
+
commaSplit: data.config.reply?.commaSplit !== false,
|
|
257
|
+
pollEnabled: data.config.poll?.enabled !== false,
|
|
258
|
+
segmentMinSec: (data.config.rate?.segmentMinMs ?? 1000) / 1000,
|
|
259
|
+
segmentMaxSec: (data.config.rate?.segmentMaxMs ?? 10000) / 1000,
|
|
260
|
+
segmentPerCharMs: data.config.rate?.segmentPerCharMs ?? 60,
|
|
261
|
+
linkParse: data.config.reply?.linkParse !== false,
|
|
262
|
+
linkMaxImages: data.config.reply?.linkMaxImages ?? 9,
|
|
263
|
+
lifeEnabled: data.config.life?.enabled !== false,
|
|
264
|
+
lifeInject: data.config.life?.inject !== false,
|
|
265
|
+
lifeAutoRefresh: data.config.life?.autoRefresh !== false,
|
|
266
|
+
lifeProactive: data.config.life?.proactive === true,
|
|
267
|
+
lifeProactivePrivate: data.config.life?.proactivePrivate !== false,
|
|
268
|
+
lifeProactiveGroup: data.config.life?.proactiveGroup === true,
|
|
269
|
+
lifeMaxPerDay: data.config.life?.proactiveMaxPerDay ?? 5,
|
|
270
|
+
lifeSpread: data.config.life?.proactiveSpread ?? 0.5,
|
|
271
|
+
lifeMinGap: data.config.life?.proactiveMinGapMinutes ?? 90,
|
|
272
|
+
lifeJitter: data.config.life?.proactiveJitterMinutes ?? 45,
|
|
273
|
+
lifeGrace: data.config.life?.proactiveGraceMinutes ?? 30,
|
|
274
|
+
// 会话空闲多久回收,界面用分钟。0 = 永不回收。
|
|
275
|
+
idleMinutes: Math.round((data.config.reply?.idleMs ?? 1800000) / 60000),
|
|
276
|
+
// 开关状态由 idleMs === 0 推导,不单独存 —— 只存一个真值来源,避免两处打架。
|
|
277
|
+
neverEvict: Number(data.config.reply?.idleMs ?? 1800000) === 0,
|
|
278
|
+
contextMessages: data.config.reply?.contextMessages ?? 20,
|
|
279
|
+
maxLiveSessions: data.config.reply?.maxLiveSessions ?? 64,
|
|
280
|
+
lifeHint: data.config.life?.proactiveHint ?? '',
|
|
281
|
+
wxEnabled: data.config.weather?.enabled === true,
|
|
282
|
+
wxHost: data.config.weather?.apiHost ?? '',
|
|
283
|
+
// 服务端不回传明文 key。keepSecrets 时保留用户正在输入的草稿,
|
|
284
|
+
// 否则每次刷新都会把刚粘贴进去的 key 清掉,看起来像没保存成功。
|
|
285
|
+
wxKey: keepSecrets ? (prev.wxKey ?? '') : '',
|
|
286
|
+
wxHasKey: data.config.weather?.hasApiKey === true,
|
|
287
|
+
steamEnabled: data.config.steam?.enabled === true,
|
|
288
|
+
// 和 wxKey 同样的掩码规则:服务端不回传明文,留空表示不改。
|
|
289
|
+
steamKey: keepSecrets ? (prev.steamKey ?? '') : '',
|
|
290
|
+
steamHasKey: data.config.steam?.hasApiKey === true,
|
|
291
|
+
// 缓存时间用秒显示,配置里是毫秒。0 = 每次都查(调试时用)。
|
|
292
|
+
steamCacheSec: Math.round((data.config.steam?.cacheTtlMs ?? 60000) / 1000),
|
|
293
|
+
steamWithGames: data.config.steam?.withGames !== false,
|
|
294
|
+
steamInject: data.config.steam?.inject !== false,
|
|
295
|
+
steamInjectProactive: data.config.steam?.injectProactive !== false,
|
|
296
|
+
steamPrivateOnly: data.config.steam?.privateOnly !== false,
|
|
297
|
+
// 生图:走 DSH 的 provider 路由。默认豆包生图,但要用户明确打开。
|
|
298
|
+
imgEnabled: data.config.image?.enabled === true,
|
|
299
|
+
imgProvider: data.config.image?.provider ?? 'doubao',
|
|
300
|
+
imgModel: data.config.image?.model ?? 'image-gen',
|
|
301
|
+
imgTimeoutSec: Math.round((data.config.image?.timeoutMs ?? 120000) / 1000),
|
|
302
|
+
imgMaxPerTurn: data.config.image?.maxPerTurn ?? 3,
|
|
303
|
+
wxCity: data.config.weather?.city ?? '华盛顿',
|
|
304
|
+
wxLat: data.config.weather?.latitude ?? 38.90,
|
|
305
|
+
wxLon: data.config.weather?.longitude ?? -77.04,
|
|
306
|
+
// 这三个字段以前漏了初始化,导致面板永远显示「关」,
|
|
307
|
+
// 而且每次保存都把 true 写成 false —— 看起来就是「勾了没保存上」。
|
|
308
|
+
// 默认值必须和 config.mjs 的 normalize 保持一致,否则会互相打架。
|
|
309
|
+
memesEnabled: data.config.memes?.enabled !== false,
|
|
310
|
+
memesAutoCollect: data.config.memes?.autoCollect === true,
|
|
311
|
+
memesRequireApproval: data.config.memes?.requireApproval !== false,
|
|
312
|
+
memesVision: data.config.memes?.visionClassify !== false,
|
|
313
|
+
memesAutoSend: data.config.memes?.autoSend === true,
|
|
314
|
+
memesAutoSendChance: data.config.memes?.autoSendChance ?? 0.15,
|
|
315
|
+
emEnabled: data.config.emotion?.enabled === true,
|
|
316
|
+
emPerSession: data.config.emotion?.perSession === true,
|
|
317
|
+
emUseModel: data.config.emotion?.useModel !== false,
|
|
318
|
+
emProvider: data.config.emotion?.provider ?? "",
|
|
319
|
+
emModel: data.config.emotion?.model ?? "",
|
|
320
|
+
emInject: data.config.emotion?.inject !== false,
|
|
321
|
+
emPrivacy: data.config.emotion?.privacyLevel ?? 1,
|
|
322
|
+
emThreshold: data.config.emotion?.significanceThreshold ?? 5,
|
|
323
|
+
memEnabled: data.config.memory?.enabled === true,
|
|
324
|
+
memInject: data.config.memory?.inject !== false,
|
|
325
|
+
memUseModel: data.config.memory?.useModel === true,
|
|
326
|
+
memHalfLife: data.config.memory?.halfLifeDays ?? 30,
|
|
327
|
+
memRecall: data.config.memory?.recallLimit ?? 4,
|
|
328
|
+
memFacts: data.config.memory?.factLimit ?? 6,
|
|
329
|
+
memMinScore: data.config.memory?.minScore ?? 0.12,
|
|
330
|
+
memQuota: data.config.memory?.dailyQuota ?? 12,
|
|
331
|
+
modelFollowDefault: !chosen,
|
|
332
|
+
modelProvider: chosen?.provider ?? "",
|
|
333
|
+
modelId: chosen?.model ?? "",
|
|
334
|
+
modelReasoningEffort: chosen?.reasoningEffort ?? "",
|
|
335
|
+
endoEnabled: data.config.endocrine?.enabled === true,
|
|
336
|
+
endoInject: data.config.endocrine?.inject !== false,
|
|
337
|
+
endoScope: data.config.endocrine?.injectScope ?? "owner-private",
|
|
338
|
+
endoAutoEvents: data.config.endocrine?.autoEvents !== false,
|
|
339
|
+
endoAutoFlare: data.config.endocrine?.autoFlare === true,
|
|
340
|
+
endoMoodFromEmotion: data.config.endocrine?.moodFromEmotion !== false,
|
|
341
|
+
endoCycleLength: data.config.endocrine?.cycleLength ?? 28,
|
|
342
|
+
}));
|
|
343
|
+
// 表单刚和服务端对齐,此刻没有未保存的东西。
|
|
344
|
+
setDirty(false);
|
|
345
|
+
} catch (error) { setErr(String(error.message || error)); }
|
|
346
|
+
}, []);
|
|
347
|
+
|
|
348
|
+
const loadMemes = useCallback(async () => {
|
|
349
|
+
try {
|
|
350
|
+
const res = await fetch(API + "/memes", { credentials: "same-origin" });
|
|
351
|
+
const data = await res.json();
|
|
352
|
+
if (data.ok) setMemes(data);
|
|
353
|
+
} catch { /* the panel keeps the previous snapshot */ }
|
|
354
|
+
}, []);
|
|
355
|
+
|
|
356
|
+
// Steam 绑定表:只有面板能改。聊天里没有绑定工具 ——
|
|
357
|
+
// SteamID 是公开信息,群里任何人都能拿到别人的 ID 绑到自己身上。
|
|
358
|
+
const loadSteamBindings = useCallback(async () => {
|
|
359
|
+
try {
|
|
360
|
+
const res = await fetch(API + "/steam/bindings", { credentials: "same-origin" });
|
|
361
|
+
const data = await res.json();
|
|
362
|
+
if (data.ok) setSteamBindings(data.people || []);
|
|
363
|
+
} catch { /* 保留上一次的快照 */ }
|
|
364
|
+
}, []);
|
|
365
|
+
|
|
366
|
+
const steamAction = async (action, extra = {}) => {
|
|
367
|
+
setErr(""); setMsg("");
|
|
368
|
+
const res = await fetch(API + "/steam/action", {
|
|
369
|
+
method: "POST", credentials: "same-origin",
|
|
370
|
+
headers: { "content-type": "application/json" },
|
|
371
|
+
body: JSON.stringify({ action, ...extra }),
|
|
372
|
+
});
|
|
373
|
+
const data = await res.json();
|
|
374
|
+
if (!data.ok) throw new Error(data.error || "操作失败");
|
|
375
|
+
return data;
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
const setSteamDraft = (id, patch) => {
|
|
379
|
+
setSteamDrafts((list) => (list || []).map((d) => (d.id === id ? { ...d, ...patch } : d)));
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
const removeSteamDraft = (id) => {
|
|
383
|
+
setSteamDrafts((list) => {
|
|
384
|
+
const next = (list || []).filter((d) => d.id !== id);
|
|
385
|
+
// 至少留一行空的,否则界面上会出现「无处可填」的空区
|
|
386
|
+
return next.length ? next : [{ id: Date.now(), peer: "", steamId: "", done: false }];
|
|
387
|
+
});
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
const steamBindSubmit = async (draftId) => {
|
|
391
|
+
const draft = (steamDrafts || []).find((d) => d.id === draftId);
|
|
392
|
+
if (!draft) return;
|
|
393
|
+
const peer = String(draft.peer || "").trim();
|
|
394
|
+
const steamId = String(draft.steamId || "").trim();
|
|
395
|
+
if (!/^(?:wxid_[A-Za-z0-9_-]{3,64}|[A-Za-z][A-Za-z0-9_-]{1,63})$/.test(peer)) { setErr("微信号格式不对"); return; }
|
|
396
|
+
if (!/^\d{17}$/.test(steamId)) { setErr("SteamID 必须是 17 位数字(SteamID64)"); return; }
|
|
397
|
+
setSteamBindBusy(true); setErr(""); setMsg("");
|
|
398
|
+
try {
|
|
399
|
+
const data = await steamAction("bind", { peer, steamId });
|
|
400
|
+
// 这一行变成「✓ 已绑定」,然后自动补一个空行。
|
|
401
|
+
// 保留已绑定的行而不是清空,是为了让人看得见刚才绑了什么、
|
|
402
|
+
// 也方便发现「绑错了」当场解绑。
|
|
403
|
+
setSteamDrafts((list) => {
|
|
404
|
+
const marked = (list || []).map((d) => (d.id === draftId ? { ...d, done: true } : d));
|
|
405
|
+
const hasEmpty = marked.some((d) => !d.done);
|
|
406
|
+
return hasEmpty ? marked : [...marked, { id: Date.now(), peer: "", steamId: "", done: false }];
|
|
407
|
+
});
|
|
408
|
+
if (data.probed && data.probed.nickname) {
|
|
409
|
+
setMsg("已绑定:" + data.probed.nickname + "(" + (data.probed.inGame ? "正在玩 " + data.probed.inGame : data.probed.state) + ")");
|
|
410
|
+
} else if (data.probed && data.probed.error) {
|
|
411
|
+
setMsg("已绑定,但查询失败:" + data.probed.error);
|
|
412
|
+
} else {
|
|
413
|
+
setMsg(data.duplicate ? "这个绑定已经存在" : "已绑定");
|
|
414
|
+
}
|
|
415
|
+
await loadSteamBindings();
|
|
416
|
+
} catch (error) {
|
|
417
|
+
setErr(String(error.message || error));
|
|
418
|
+
// 失败时撤回「已绑定」标记,让这一行还能改着重试
|
|
419
|
+
setSteamDrafts((list) => (list || []).map((d) => (d.id === draftId ? { ...d, done: false } : d)));
|
|
420
|
+
}
|
|
421
|
+
finally { setSteamBindBusy(false); }
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
const steamUnbind = async (peer, steamId) => {
|
|
425
|
+
setErr(""); setMsg("");
|
|
426
|
+
try {
|
|
427
|
+
await steamAction("unbind", { peer, steamId });
|
|
428
|
+
setMsg("已解绑");
|
|
429
|
+
await loadSteamBindings();
|
|
430
|
+
} catch (error) { setErr(String(error.message || error)); }
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
const loadLife = useCallback(async () => {
|
|
434
|
+
try {
|
|
435
|
+
const res = await fetch(API + "/life", { credentials: "same-origin" });
|
|
436
|
+
const data = await res.json();
|
|
437
|
+
if (data.ok) setLife(data);
|
|
438
|
+
} catch { /* keep the previous snapshot */ }
|
|
439
|
+
}, []);
|
|
440
|
+
|
|
441
|
+
const loadMemory = useCallback(async () => {
|
|
442
|
+
try {
|
|
443
|
+
const res = await fetch(API + "/memory", { credentials: "same-origin" });
|
|
444
|
+
const data = await res.json();
|
|
445
|
+
if (data.ok) setMemory(data);
|
|
446
|
+
} catch { /* keep the previous snapshot */ }
|
|
447
|
+
}, []);
|
|
448
|
+
|
|
449
|
+
const loadEmotion = useCallback(async () => {
|
|
450
|
+
try {
|
|
451
|
+
const res = await fetch(API + "/emotion", { credentials: "same-origin" });
|
|
452
|
+
const data = await res.json();
|
|
453
|
+
if (data.ok) setEmotion(data);
|
|
454
|
+
} catch { /* keep the previous snapshot */ }
|
|
455
|
+
}, []);
|
|
456
|
+
|
|
457
|
+
const loadEndocrine = useCallback(async () => {
|
|
458
|
+
try {
|
|
459
|
+
const res = await fetch(API + "/endocrine", { credentials: "same-origin" });
|
|
460
|
+
const data = await res.json();
|
|
461
|
+
if (data.ok) setEndocrine(data);
|
|
462
|
+
} catch { /* keep the previous snapshot */ }
|
|
463
|
+
}, []);
|
|
464
|
+
|
|
465
|
+
const endocrineAction = async (action, extra = {}) => {
|
|
466
|
+
setBusy(true); setErr(""); setMsg("");
|
|
467
|
+
try {
|
|
468
|
+
const res = await fetch(API + "/endocrine/action", {
|
|
469
|
+
method: "POST", credentials: "same-origin",
|
|
470
|
+
headers: { "content-type": "application/json" },
|
|
471
|
+
body: JSON.stringify({ action, ...extra }),
|
|
472
|
+
});
|
|
473
|
+
const data = await res.json();
|
|
474
|
+
if (!data.ok) throw new Error(data.error || "操作失败");
|
|
475
|
+
setEndocrine(data);
|
|
476
|
+
setMsg("已更新内分泌状态");
|
|
477
|
+
} catch (error) { setErr(String(error.message || error)); }
|
|
478
|
+
finally { setBusy(false); }
|
|
479
|
+
};
|
|
480
|
+
|
|
481
|
+
const loadTargets = useCallback(async () => {
|
|
482
|
+
try {
|
|
483
|
+
const res = await fetch(API + "/life/targets", { credentials: "same-origin" });
|
|
484
|
+
const data = await res.json();
|
|
485
|
+
if (data.ok) setTargets(data.conversations ?? []);
|
|
486
|
+
} catch { /* keep the previous list */ }
|
|
487
|
+
}, []);
|
|
488
|
+
const saveTargets = async () => {
|
|
489
|
+
setBusy(true); setErr(""); setMsg("");
|
|
490
|
+
try {
|
|
491
|
+
// 只把勾上的发过去。服务端拿到的就是完整的目标列表,
|
|
492
|
+
// 取消勾选等于从列表里移除,不需要额外的删除语义。
|
|
493
|
+
const picked = targets
|
|
494
|
+
.filter((t) => t.selected === true)
|
|
495
|
+
.map((t) => ({ kind: t.kind, peerId: t.peerId, enabled: t.enabled !== false }));
|
|
496
|
+
const res = await fetch(API + "/life/targets", {
|
|
497
|
+
method: "POST", credentials: "same-origin",
|
|
498
|
+
headers: { "content-type": "application/json" },
|
|
499
|
+
body: JSON.stringify({ targets: picked }),
|
|
500
|
+
});
|
|
501
|
+
const data = await res.json();
|
|
502
|
+
if (!data.ok) throw new Error(data.error || "保存失败");
|
|
503
|
+
setMsg("已保存 " + data.saved + " 个会话");
|
|
504
|
+
await loadTargets();
|
|
505
|
+
} catch (error) { setErr(String(error.message || error)); }
|
|
506
|
+
finally { setBusy(false); }
|
|
507
|
+
};
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
useEffect(() => { ensureCss(); load(); loadMemes(); loadLife(); loadSteamBindings(); loadTargets(); loadEmotion(); loadMemory(); loadEndocrine(); }, [load, loadMemes, loadLife, loadTargets, loadEmotion, loadMemory, loadEndocrine]);
|
|
511
|
+
|
|
512
|
+
// 关页面/刷新前的二次确认。面板很长,用户改了上面的设置后
|
|
513
|
+
// 往往滚不到底部,看不到那个「有未保存的修改」。
|
|
514
|
+
useEffect(() => {
|
|
515
|
+
if (!dirty) return undefined;
|
|
516
|
+
const onBeforeUnload = (e) => { e.preventDefault(); e.returnValue = ''; };
|
|
517
|
+
window.addEventListener('beforeunload', onBeforeUnload);
|
|
518
|
+
return () => window.removeEventListener('beforeunload', onBeforeUnload);
|
|
519
|
+
}, [dirty]);
|
|
520
|
+
|
|
521
|
+
// 换了服务商或模型就把档位菜单重新问一遍宿主。
|
|
522
|
+
// 请求回来时用户可能已经又切走了,那时的结果要丢掉(alive 标记),
|
|
523
|
+
// 否则面板会拿上一个模型的档位去配当前模型。
|
|
524
|
+
useEffect(() => {
|
|
525
|
+
if (!form || form.modelFollowDefault) return undefined;
|
|
526
|
+
const provider = form.modelProvider;
|
|
527
|
+
const model = form.modelId;
|
|
528
|
+
if (!provider || !model) return undefined;
|
|
529
|
+
let alive = true;
|
|
530
|
+
(async () => {
|
|
531
|
+
try {
|
|
532
|
+
const res = await fetch(
|
|
533
|
+
API + "/model-reasoning?provider=" + encodeURIComponent(provider) + "&model=" + encodeURIComponent(model),
|
|
534
|
+
{ credentials: "same-origin" },
|
|
535
|
+
);
|
|
536
|
+
const data = await res.json();
|
|
537
|
+
if (!alive) return;
|
|
538
|
+
setReasoning({
|
|
539
|
+
provider,
|
|
540
|
+
model,
|
|
541
|
+
efforts: Array.isArray(data.efforts) ? data.efforts : [],
|
|
542
|
+
defaultEffort: data.defaultEffort ?? null,
|
|
543
|
+
supported: data.supported !== false,
|
|
544
|
+
error: data.ok === false ? String(data.error ?? "") : "",
|
|
545
|
+
});
|
|
546
|
+
} catch (error) {
|
|
547
|
+
if (alive) setReasoning({ provider, model, efforts: [], defaultEffort: null, supported: true, error: String(error.message || error) });
|
|
548
|
+
}
|
|
549
|
+
})();
|
|
550
|
+
return () => { alive = false; };
|
|
551
|
+
}, [form?.modelFollowDefault, form?.modelProvider, form?.modelId]);
|
|
552
|
+
|
|
553
|
+
// 只影响界面、不进入保存请求的字段。改它们不该提示「有未保存的修改」。
|
|
554
|
+
//
|
|
555
|
+
// 目前只有一个:memeFolder 是「导入文件夹」按钮的临时参数,
|
|
556
|
+
// 传完就丢,不写进 config.json。
|
|
557
|
+
//
|
|
558
|
+
// 其余看起来像「界面开关」的(modelFollowDefault、retentionForever、
|
|
559
|
+
// emUseModel 这些)都别加进来 —— 它们虽然只控制显示哪个输入框,
|
|
560
|
+
// 但会改变实际提交的值,改了必须保存。
|
|
561
|
+
const TRANSIENT_FIELDS = new Set(['memeFolder', 'neverEvict']);
|
|
562
|
+
|
|
563
|
+
// 所有表单修改都走这里,所以只在这一处置脏标记。
|
|
564
|
+
const patch = (key) => (value) => {
|
|
565
|
+
if (!TRANSIENT_FIELDS.has(key)) setDirty(true);
|
|
566
|
+
setForm((prev) => ({ ...prev, [key]: value }));
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
const save = async () => {
|
|
570
|
+
setBusy(true); setErr(""); setMsg("");
|
|
571
|
+
try {
|
|
572
|
+
const body = {
|
|
573
|
+
patch: {
|
|
574
|
+
reply: {
|
|
575
|
+
private: form.replyPrivate,
|
|
576
|
+
group: form.replyGroup,
|
|
577
|
+
smartThreshold: Math.round(Math.min(10, Math.max(1, Number(form.smartThreshold) || 3))),
|
|
578
|
+
selfNames: String(form.selfNames || "").split(/[,,\s]+/).map((x) => x.trim()).filter(Boolean).slice(0, 10),
|
|
579
|
+
interests: String(form.interests || "").split(/[,,\n]+/).map((x) => x.trim()).filter(Boolean).slice(0, 100),
|
|
580
|
+
learnInterests: Boolean(form.learnInterests),
|
|
581
|
+
// 这里不能用 `|| 1.2`:Number('0') 是 0,属于 falsy,
|
|
582
|
+
// 填 0 会被悄悄存成 1.2 秒 —— 而 0 是一个有意义的合法值(每条立刻处理)。
|
|
583
|
+
// 只在「解析不出数字」时才回退默认。
|
|
584
|
+
// 是否按逗号分段。默认开(真人聊天就是一句一发),
|
|
585
|
+
// 关了只按换行切 —— 代码、JSON、长英文句子就不会被切碎。
|
|
586
|
+
commaSplit: Boolean(form.commaSplit),
|
|
587
|
+
debounceMs: (() => {
|
|
588
|
+
const raw = Number(form.debounceSec);
|
|
589
|
+
const sec = Number.isFinite(raw) ? raw : 1.2;
|
|
590
|
+
return Math.round(Math.min(600, Math.max(0, sec)) * 1000);
|
|
591
|
+
})(),
|
|
592
|
+
avoidRepeat: Boolean(form.avoidRepeat),
|
|
593
|
+
sharedAgent: Boolean(form.sharedAgent),
|
|
594
|
+
repeatThreshold: Math.min(1, Math.max(0.5, Number(form.repeatThreshold) || 0.7)),
|
|
595
|
+
linkParse: Boolean(form.linkParse),
|
|
596
|
+
linkMaxImages: Math.round(Math.min(20, Math.max(0, Number(form.linkMaxImages) || 0))),
|
|
597
|
+
// 0 是「永不回收」的哨兵值,必须原样发出去。
|
|
598
|
+
idleMs: (() => {
|
|
599
|
+
const raw = Number(form.idleMinutes);
|
|
600
|
+
if (!Number.isFinite(raw) || raw <= 0) return 0;
|
|
601
|
+
return Math.round(Math.min(1440, Math.max(1, raw)) * 60000);
|
|
602
|
+
})(),
|
|
603
|
+
contextMessages: Math.round(Math.min(100, Math.max(0, Number(form.contextMessages) || 0))),
|
|
604
|
+
maxLiveSessions: Math.round(Math.min(1000, Math.max(1, Number(form.maxLiveSessions) || 64))),
|
|
605
|
+
},
|
|
606
|
+
access: {
|
|
607
|
+
privateMode: form.privateMode,
|
|
608
|
+
privateIds: splitIds(form.privateIds),
|
|
609
|
+
groupMode: form.groupMode,
|
|
610
|
+
// 以前只提交上面三项:手写在文件里的黑名单不会被擦掉(服务端按键合并),
|
|
611
|
+
// 但用户也没法在面板里添加它们 —— 把群模式改成 allowlist 而 groupIds 为空时,
|
|
612
|
+
// 等于所有群都不收。
|
|
613
|
+
groupIds: splitIds(form.groupIds),
|
|
614
|
+
blockedUsers: splitIds(form.blockedUsers),
|
|
615
|
+
blockedGroups: splitIds(form.blockedGroups),
|
|
616
|
+
},
|
|
617
|
+
ownerIds: splitIds(form.ownerIds),
|
|
618
|
+
life: {
|
|
619
|
+
enabled: Boolean(form.lifeEnabled),
|
|
620
|
+
inject: Boolean(form.lifeInject),
|
|
621
|
+
autoRefresh: Boolean(form.lifeAutoRefresh),
|
|
622
|
+
proactive: Boolean(form.lifeProactive),
|
|
623
|
+
proactivePrivate: Boolean(form.lifeProactivePrivate),
|
|
624
|
+
proactiveGroup: Boolean(form.lifeProactiveGroup),
|
|
625
|
+
proactiveMaxPerDay: Math.round(Math.min(24, Math.max(0, Number(form.lifeMaxPerDay) || 0))),
|
|
626
|
+
proactiveSpread: Math.round(Math.min(2, Math.max(0.05, Number(form.lifeSpread) || 0.5)) * 100) / 100,
|
|
627
|
+
proactiveMinGapMinutes: Math.round(Math.min(720, Math.max(10, Number(form.lifeMinGap) || 90))),
|
|
628
|
+
proactiveJitterMinutes: Math.round(Math.min(240, Math.max(0, Number(form.lifeJitter) || 0))),
|
|
629
|
+
proactiveGraceMinutes: Math.round(Math.min(180, Math.max(5, Number(form.lifeGrace) || 30))),
|
|
630
|
+
proactiveHint: String(form.lifeHint ?? '').trim().slice(0, 500),
|
|
631
|
+
},
|
|
632
|
+
endocrine: {
|
|
633
|
+
enabled: Boolean(form.endoEnabled),
|
|
634
|
+
inject: Boolean(form.endoInject),
|
|
635
|
+
injectScope: String(form.endoScope || 'owner-private'),
|
|
636
|
+
autoEvents: Boolean(form.endoAutoEvents),
|
|
637
|
+
autoFlare: Boolean(form.endoAutoFlare),
|
|
638
|
+
moodFromEmotion: Boolean(form.endoMoodFromEmotion),
|
|
639
|
+
cycleLength: Math.round(Math.min(45, Math.max(21, Number(form.endoCycleLength) || 28))),
|
|
640
|
+
},
|
|
641
|
+
steam: (() => {
|
|
642
|
+
const raw = String(form.steamKey ?? '').trim();
|
|
643
|
+
const base = {
|
|
644
|
+
enabled: Boolean(form.steamEnabled),
|
|
645
|
+
|
|
646
|
+
// 缓存时间:0 表示每次都查。上限一天。
|
|
647
|
+
cacheTtlMs: Math.round(Math.min(86400, Math.max(0, Number(form.steamCacheSec) || 0)) * 1000),
|
|
648
|
+
withGames: Boolean(form.steamWithGames),
|
|
649
|
+
inject: Boolean(form.steamInject),
|
|
650
|
+
injectProactive: Boolean(form.steamInjectProactive),
|
|
651
|
+
privateOnly: Boolean(form.steamPrivateOnly),
|
|
652
|
+
};
|
|
653
|
+
if (!raw) return base;
|
|
654
|
+
// Steam Web API key 是 32 位十六进制。形状不对就不发,保留原值 ——
|
|
655
|
+
// 和 weather 那边同一个理由:粘错一整段文字比没填更难排查。
|
|
656
|
+
if (!/^[0-9A-Fa-f]{32}$/.test(raw)) {
|
|
657
|
+
throw new Error('Steam API Key 格式不对:应当是 32 位十六进制字符');
|
|
658
|
+
}
|
|
659
|
+
return { ...base, apiKey: raw };
|
|
660
|
+
})(),
|
|
661
|
+
image: {
|
|
662
|
+
enabled: Boolean(form.imgEnabled),
|
|
663
|
+
provider: String(form.imgProvider ?? '').trim() || 'doubao',
|
|
664
|
+
model: String(form.imgModel ?? '').trim() || 'image-gen',
|
|
665
|
+
timeoutMs: Math.round(Math.min(600, Math.max(10, Number(form.imgTimeoutSec) || 120)) * 1000),
|
|
666
|
+
maxPerTurn: Math.round(Math.min(6, Math.max(1, Number(form.imgMaxPerTurn) || 3))),
|
|
667
|
+
},
|
|
668
|
+
weather: (() => {
|
|
669
|
+
// 和风的 API Key 是 32 位十六进制或类似短串,绝不可能是一段文字。
|
|
670
|
+
// 之前这里直接把输入框内容塞进 apiKey,结果人格设定被当成 key 存进去,
|
|
671
|
+
// 存进去之后面板显示「已保存」,看起来完全正常,实际整个 weather 段是坏的。
|
|
672
|
+
// 所以这里做一次形状校验:不像 key 就不发,让它保留原来的值。
|
|
673
|
+
const raw = String(form.wxKey ?? '').trim();
|
|
674
|
+
const base = {
|
|
675
|
+
enabled: Boolean(form.wxEnabled),
|
|
676
|
+
apiHost: String(form.wxHost ?? '').trim(),
|
|
677
|
+
// 城市只用于提示词。以前这里写 `|| '华盛顿'`:输入框是空的(比如面板
|
|
678
|
+
// 没初始化这个字段)就会把用户填过的城市悄悄改回默认值。现在空就不发,
|
|
679
|
+
// 服务端的分段合并会保留原值。
|
|
680
|
+
...(String(form.wxCity ?? '').trim() ? { city: String(form.wxCity).trim() } : {}),
|
|
681
|
+
latitude: Number.isFinite(Number(form.wxLat)) ? Number(form.wxLat) : 38.90,
|
|
682
|
+
longitude: Number.isFinite(Number(form.wxLon)) ? Number(form.wxLon) : -77.04,
|
|
683
|
+
};
|
|
684
|
+
if (!raw) return base;
|
|
685
|
+
if (!/^[A-Za-z0-9._-]{8,128}$/.test(raw)) {
|
|
686
|
+
throw new Error('API Key 格式不对:应当是一串字母数字(不含空格和换行),长度 8–128');
|
|
687
|
+
}
|
|
688
|
+
return { ...base, apiKey: raw };
|
|
689
|
+
})(),
|
|
690
|
+
emotion: {
|
|
691
|
+
enabled: Boolean(form.emEnabled),
|
|
692
|
+
perSession: Boolean(form.emPerSession),
|
|
693
|
+
useModel: Boolean(form.emUseModel),
|
|
694
|
+
provider: String(form.emProvider || "").trim(),
|
|
695
|
+
model: String(form.emModel || "").trim(),
|
|
696
|
+
inject: Boolean(form.emInject),
|
|
697
|
+
privacyLevel: Math.round(Math.min(2, Math.max(0, Number(form.emPrivacy) || 0))),
|
|
698
|
+
significanceThreshold: Math.round(Math.min(30, Math.max(1, Number(form.emThreshold) || 5))),
|
|
699
|
+
},
|
|
700
|
+
memory: {
|
|
701
|
+
enabled: Boolean(form.memEnabled),
|
|
702
|
+
inject: Boolean(form.memInject),
|
|
703
|
+
useModel: Boolean(form.memUseModel),
|
|
704
|
+
halfLifeDays: Math.round(Math.min(3650, Math.max(1, Number(form.memHalfLife) || 30))),
|
|
705
|
+
recallLimit: Math.round(Math.min(20, Math.max(0, Number(form.memRecall) || 0))),
|
|
706
|
+
factLimit: Math.round(Math.min(20, Math.max(0, Number(form.memFacts) || 0))),
|
|
707
|
+
minScore: Math.min(1, Math.max(0, Number(form.memMinScore) || 0)),
|
|
708
|
+
dailyQuota: Math.round(Math.min(100, Math.max(0, Number(form.memQuota) || 0))),
|
|
709
|
+
},
|
|
710
|
+
memes: {
|
|
711
|
+
enabled: Boolean(form.memesEnabled),
|
|
712
|
+
autoCollect: Boolean(form.memesAutoCollect),
|
|
713
|
+
requireApproval: Boolean(form.memesRequireApproval),
|
|
714
|
+
visionClassify: Boolean(form.memesVision),
|
|
715
|
+
autoSend: Boolean(form.memesAutoSend),
|
|
716
|
+
autoSendChance: Math.min(1, Math.max(0, Number(form.memesAutoSendChance) || 0)),
|
|
717
|
+
},
|
|
718
|
+
// 保存前必须校验「服务商 + 模型」这对组合是否真的存在。
|
|
719
|
+
//
|
|
720
|
+
// 之前这里直接用 form.modelProvider / form.modelId,而那两个值
|
|
721
|
+
// 可能已经过时:宿主目录变了、模型下线了、或者换服务商时没重选模型。
|
|
722
|
+
// 面板上显示的是校验后的值,看起来一切正常,但保存下去的是那个
|
|
723
|
+
// 不存在的组合 —— 运行时就变成「agent 建得出来但模型不响应」,
|
|
724
|
+
// 主动消息静默失败,只在 debug.log 里留下一行空回合。
|
|
725
|
+
// 校验不过就退回「跟随默认」,宁可丢一次选择,也不要写坏配置。
|
|
726
|
+
model: (() => {
|
|
727
|
+
if (form.modelFollowDefault) return null;
|
|
728
|
+
const groups = catalog?.groups ?? [];
|
|
729
|
+
const provider = groups.find((g) => g.id === form.modelProvider);
|
|
730
|
+
if (!provider) return null;
|
|
731
|
+
if (!(provider.models ?? []).some((m) => m.id === form.modelId)) return null;
|
|
732
|
+
// 等级和 provider/model 是同一个选择对象的三件套,一起写或者都不写。
|
|
733
|
+
// 空值 = 服务商默认,干脆省掉这个键,别存一个空串。
|
|
734
|
+
const effort = String(form.modelReasoningEffort ?? '').trim();
|
|
735
|
+
// 只有在「已经拿到这个模型的档位表、表里确实没有这一档」时才丢掉它;
|
|
736
|
+
// 否则会把还在加载中的合法设置一起扔掉,等于保存时悄悄改设置。
|
|
737
|
+
const tableReady = reasoning.provider === provider.id && reasoning.model === form.modelId && reasoningEfforts.length > 0;
|
|
738
|
+
const unsupported = tableReady && !reasoningEfforts.some((r) => r.id === effort);
|
|
739
|
+
return { provider: provider.id, model: form.modelId, ...(effort && !unsupported ? { reasoningEffort: effort } : {}) };
|
|
740
|
+
})(),
|
|
741
|
+
persona: form.persona,
|
|
742
|
+
// Clamp and round here: the backend requires a strict integer in 1..3650 and
|
|
743
|
+
// an emptied field would otherwise fail the entire save.
|
|
744
|
+
// 0 是后端约定的「永久保存」哨兵值;勾选后忽略输入框里的天数。
|
|
745
|
+
retentionDays: form.retentionForever
|
|
746
|
+
? 0
|
|
747
|
+
: Math.round(Math.min(3650, Math.max(1, Number(form.retentionDays) || 30))),
|
|
748
|
+
rate: {
|
|
749
|
+
segmentMinMs: Math.round(Math.min(30, Math.max(0, Number(form.segmentMinSec) || 0)) * 1000),
|
|
750
|
+
segmentMaxMs: Math.round(Math.min(60, Math.max(0, Number(form.segmentMaxSec) || 0)) * 1000),
|
|
751
|
+
segmentPerCharMs: Math.round(Math.min(500, Math.max(0, Number(form.segmentPerCharMs) || 0))),
|
|
752
|
+
},
|
|
753
|
+
},
|
|
754
|
+
};
|
|
755
|
+
const res = await fetch(API + "/config", {
|
|
756
|
+
method: "POST", credentials: "same-origin",
|
|
757
|
+
headers: { "content-type": "application/json" },
|
|
758
|
+
body: JSON.stringify(body),
|
|
759
|
+
});
|
|
760
|
+
const data = await res.json();
|
|
761
|
+
if (!data.ok) throw new Error(data.error || "保存失败");
|
|
762
|
+
setMsg(data.hot ? "已保存并即时生效" : "已保存;微信接入相关改动需重载插件后生效");
|
|
763
|
+
// 保存后不能直接 load():那会把整个 form 重置,用户刚填的 API Key 立刻被清空。
|
|
764
|
+
// 服务端本来也不会回传明文 key,所以重载只会让输入框变空,看起来像没保存成功。
|
|
765
|
+
// 这里只把「已保存」标记更新一下,输入框内容保留到用户自己改。
|
|
766
|
+
if (form.wxKey && String(form.wxKey).trim()) setForm((f) => ({ ...f, wxHasKey: true, wxKey: "" }));
|
|
767
|
+
if (form.steamKey && String(form.steamKey).trim()) setForm((f) => ({ ...f, steamHasKey: true, steamKey: "" }));
|
|
768
|
+
await load({ keepSecrets: true });
|
|
769
|
+
await loadEndocrine();
|
|
770
|
+
// 保存成功后服务端已经是新值,标脏就该清掉。
|
|
771
|
+
setDirty(false);
|
|
772
|
+
} catch (error) { setErr(String(error.message || error)); }
|
|
773
|
+
finally { setBusy(false); }
|
|
774
|
+
};
|
|
775
|
+
|
|
776
|
+
const runBootstrap = async () => {
|
|
777
|
+
setBoot((prev) => ({ ...prev, busy: true }));
|
|
778
|
+
setErr(""); setMsg("");
|
|
779
|
+
try {
|
|
780
|
+
const res = await fetch(API + "/bootstrap", {
|
|
781
|
+
method: "POST", credentials: "same-origin",
|
|
782
|
+
headers: { "content-type": "application/json" },
|
|
783
|
+
body: JSON.stringify({ ownerIds: splitIds(boot.ownerId), baseUrl: boot.baseUrl, token: boot.token }),
|
|
784
|
+
});
|
|
785
|
+
const data = await res.json();
|
|
786
|
+
if (!data.ok) throw new Error(data.error || "生成配置失败");
|
|
787
|
+
setBoot((prev) => ({ ...prev, busy: false, done: true }));
|
|
788
|
+
setMsg(
|
|
789
|
+
"配置已生成:" + data.configPath + "。"
|
|
790
|
+
+ "现在请重载插件(或在面板上点重载),之后它会连上 agent-wechat 守护进程并开始收发微信消息。"
|
|
791
|
+
);
|
|
792
|
+
} catch (error) { setErr(String(error.message || error)); }
|
|
793
|
+
finally { setBoot((prev) => ({ ...prev, busy: false })); }
|
|
794
|
+
};
|
|
795
|
+
|
|
796
|
+
// 复制到剪贴板:面板要让用户把 WebUI 登录 token 抄走(127.0.0.1 是安全上下文,
|
|
797
|
+
// clipboard API 可用;失败时提示手动选中复制)。
|
|
798
|
+
const copyText = async (text) => {
|
|
799
|
+
if (!text) return;
|
|
800
|
+
try {
|
|
801
|
+
await navigator.clipboard.writeText(text);
|
|
802
|
+
setMsg("已复制到剪贴板");
|
|
803
|
+
} catch {
|
|
804
|
+
setErr("复制失败,请手动选中复制");
|
|
805
|
+
}
|
|
806
|
+
};
|
|
807
|
+
|
|
808
|
+
// 还没有配置文件:先让用户把账号填了。这一屏是唯一一处不依赖 runtime 的渲染,
|
|
809
|
+
// 也是新人装完插件后看到的第一屏 —— 之前这里根本没机会渲染,因为插件已经抛异常了。
|
|
810
|
+
// 还没有配置文件:只问管理员号(可留空)+ 守护进程地址和 token。
|
|
811
|
+
// 这一屏是新人装完插件后看到的第一屏,所以要把「接下来会发生什么」写清楚。
|
|
812
|
+
if (state && state.missingConfig) {
|
|
813
|
+
// 配置损坏时服务端已经把它备份并重建了模板。必须在这里说清楚,
|
|
814
|
+
// 否则用户只会看到「首次配置」屏,以为自己的设置被静默清空了。
|
|
815
|
+
const corrupt = state.corruptConfig;
|
|
816
|
+
return h("div", { className: "wxa" },
|
|
817
|
+
corrupt ? h(Card, { title: "配置文件已损坏" },
|
|
818
|
+
h("div", { className: "hint", style: { marginTop: 0 } },
|
|
819
|
+
"config.json 不是合法的 JSON,插件没法读它,所以按「首次配置」处理了。原来的文件没有删,已备份到:"),
|
|
820
|
+
h("div", { className: "hint", style: { wordBreak: "break-all", userSelect: "all" } }, String(corrupt.backup || "")),
|
|
821
|
+
h("div", { className: "hint" }, "报错位置:" + String(corrupt.message || "")),
|
|
822
|
+
h("div", { className: "hint" }, "想找回原来的设置,就把备份文件改回 config.json 再修掉语法错误;不想找就直接在下面重新生成一份。"),
|
|
823
|
+
) : null,
|
|
824
|
+
h("div", { className: "row" },
|
|
825
|
+
h("div", null,
|
|
826
|
+
h("h2", null, "微信接入 · 首次配置"),
|
|
827
|
+
h("p", { className: "sub" }, "先在电脑上把 agent-wechat 跑起来并扫码登录,然后到命令行执行 wx tokens create 拿一个 token。这一步只写配置文件,不启动任何东西。")),
|
|
828
|
+
),
|
|
829
|
+
h(Card, { title: "还没装 agent-wechat?先做这四步" },
|
|
830
|
+
h("div", { className: "hint", style: { marginTop: 0 } },
|
|
831
|
+
"这个插件不会自己下载或启动微信客户端。它需要电脑上已有一个 agent-wechat 守护进程在跑。"),
|
|
832
|
+
h("ol", { style: { margin: "8px 0 0", paddingLeft: "20px", lineHeight: 1.9 } },
|
|
833
|
+
h("li", null,
|
|
834
|
+
"下载安装:",
|
|
835
|
+
h("a", { href: WX_RELEASE_URL, target: "_blank", rel: "noreferrer" }, "github.com/thisnick/agent-wechat/releases"),
|
|
836
|
+
"(桌面端一键安装;或命令行 npm i -g @agent-wechat/cli)"),
|
|
837
|
+
h("li", null, "打开桌面端或执行 wx serve,让它保持运行"),
|
|
838
|
+
h("li", null, "用手机微信扫码登录,确认账号状态是「在线」"),
|
|
839
|
+
h("li", null,
|
|
840
|
+
"执行 ",
|
|
841
|
+
h("code", null, "wx tokens create dsh-wechat-access --accounts '*' --scopes read --scopes send --scopes media --scopes read-state"),
|
|
842
|
+
",把输出的 token 填到下面"),
|
|
843
|
+
),
|
|
844
|
+
h("div", { className: "hint", style: { marginTop: "8px" } },
|
|
845
|
+
"详细说明见 ",
|
|
846
|
+
h("a", { href: WX_REPO_URL, target: "_blank", rel: "noreferrer" }, "agent-wechat 文档"),
|
|
847
|
+
";本插件的 README 里也有逐步教程。"),
|
|
848
|
+
),
|
|
849
|
+
h(Card, { title: "agent-wechat 守护进程" },
|
|
850
|
+
h("div", { className: "row" },
|
|
851
|
+
h("div", null,
|
|
852
|
+
h("div", { className: "lbl" }, "服务地址"),
|
|
853
|
+
h("div", { className: "hint" }, "默认 http://127.0.0.1:6174/v1;只允许本机回环地址")),
|
|
854
|
+
h("input", {
|
|
855
|
+
type: "text", value: boot.baseUrl, placeholder: "http://127.0.0.1:6174/v1",
|
|
856
|
+
onChange: (e) => setBoot((prev) => ({ ...prev, baseUrl: e.target.value })),
|
|
857
|
+
}),
|
|
858
|
+
),
|
|
859
|
+
h("div", { className: "row", style: { marginTop: 10 } },
|
|
860
|
+
h("div", null,
|
|
861
|
+
h("div", { className: "lbl" }, "API token"),
|
|
862
|
+
h("div", { className: "hint" }, "格式是一串 64 位十六进制字符。只授予 read / send / media / read-state 即可,不需要 admin")),
|
|
863
|
+
h("input", {
|
|
864
|
+
type: "text", value: boot.token, placeholder: "wx tokens create 的输出",
|
|
865
|
+
onChange: (e) => setBoot((prev) => ({ ...prev, token: e.target.value })),
|
|
866
|
+
}),
|
|
867
|
+
),
|
|
868
|
+
),
|
|
869
|
+
h(Card, { title: "管理员(可留空)" },
|
|
870
|
+
h("div", { className: "row" },
|
|
871
|
+
h("div", null,
|
|
872
|
+
h("div", { className: "lbl" }, "管理员微信号"),
|
|
873
|
+
h("div", { className: "hint" }, "用另一个号私聊它来管理插件;留空就只能在本机 Harness 里管,之后随时能改")),
|
|
874
|
+
h("input", {
|
|
875
|
+
type: "text", value: boot.ownerId, placeholder: "可留空",
|
|
876
|
+
onChange: (e) => setBoot((prev) => ({ ...prev, ownerId: e.target.value })),
|
|
877
|
+
}),
|
|
878
|
+
),
|
|
879
|
+
),
|
|
880
|
+
h("div", { className: "row" },
|
|
881
|
+
h("button", { onClick: runBootstrap, disabled: boot.busy }, boot.busy ? "生成中…" : "生成配置"),
|
|
882
|
+
),
|
|
883
|
+
h("div", { className: "hint" }, "生成配置后需要重载插件才会连上守护进程。"),
|
|
884
|
+
msg ? h("div", { className: "msg" }, msg) : null,
|
|
885
|
+
err ? h("div", { className: "msg err" }, err) : null,
|
|
886
|
+
);
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
// 已经生成配置,但守护进程没连上(未登录 / 没启动 / token 不对)。
|
|
890
|
+
// 这种情况不该显示完整面板:所有按钮都会失败,用户只会更困惑。
|
|
891
|
+
if (state && (state.loginPending || (!state.runtimeReady && !state.bootError))) {
|
|
892
|
+
const wx = state.wechat ?? {};
|
|
893
|
+
return h("div", { className: "wxa" },
|
|
894
|
+
h("div", {
|
|
895
|
+
className: "msg",
|
|
896
|
+
style: { fontSize: "15px", fontWeight: 600, padding: "12px 14px", lineHeight: 1.7 },
|
|
897
|
+
},
|
|
898
|
+
"📱 还没连上微信。",
|
|
899
|
+
h("br"),
|
|
900
|
+
"插件连不到 agent-wechat 守护进程,或者那个账号还没登录。",
|
|
901
|
+
),
|
|
902
|
+
h(Card, { title: "接下来" },
|
|
903
|
+
h("ol", { style: { margin: 0, paddingLeft: "20px", lineHeight: 1.9 } },
|
|
904
|
+
h("li", null, "确认电脑上 agent-wechat 已经在跑(任务栏里应该有它的图标)"),
|
|
905
|
+
h("li", null, "确认手机上微信已扫码登录,并且账号状态是「在线」"),
|
|
906
|
+
h("li", null, "确认面板里填的 API token 是 wx tokens create 生成的那一个"),
|
|
907
|
+
h("li", null, "改完配置后重载插件"),
|
|
908
|
+
),
|
|
909
|
+
),
|
|
910
|
+
h(Card, { title: "没有安装 agent-wechat?" },
|
|
911
|
+
h("div", { className: "hint", style: { marginTop: 0 } },
|
|
912
|
+
"先到 ",
|
|
913
|
+
h("a", { href: WX_RELEASE_URL, target: "_blank", rel: "noreferrer" }, "agent-wechat Releases"),
|
|
914
|
+
" 下载桌面端并安装;也可以执行 npm i -g @agent-wechat/cli。装好后扫码登录,再回来重载这个插件。"),
|
|
915
|
+
),
|
|
916
|
+
h(Card, { title: "当前配置" },
|
|
917
|
+
h("div", { className: "row" },
|
|
918
|
+
h("div", null,
|
|
919
|
+
h("div", { className: "lbl" }, "服务地址"),
|
|
920
|
+
h("div", { className: "hint" }, String(wx.baseUrl ?? "(未配置)"))),
|
|
921
|
+
),
|
|
922
|
+
h("div", { className: "row", style: { marginTop: 8 } },
|
|
923
|
+
h("div", null,
|
|
924
|
+
h("div", { className: "lbl" }, "账号"),
|
|
925
|
+
h("div", { className: "hint" }, String(wx.accountId || "(由守护进程自动选择在线账号)"))),
|
|
926
|
+
),
|
|
927
|
+
),
|
|
928
|
+
state.bootError ? h("div", { className: "msg err" }, String(state.bootError.message ?? state.bootError)) : null,
|
|
929
|
+
err ? h("div", { className: "msg err" }, err) : null,
|
|
930
|
+
);
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
if (state && state.needsRestart) {
|
|
934
|
+
const who = String(state.needsRestart.selfId || "");
|
|
935
|
+
return h("div", { className: "wxa" },
|
|
936
|
+
h("div", {
|
|
937
|
+
className: "msg",
|
|
938
|
+
style: { fontSize: "16px", fontWeight: 600, padding: "14px 16px", lineHeight: 1.7 },
|
|
939
|
+
},
|
|
940
|
+
"✅ 已连接微信 " + who + ",配置已写回。",
|
|
941
|
+
h("br"),
|
|
942
|
+
"现在请完全退出 DeepSeek Harness,再重新启动 —— 微信接入才会真正开始工作。",
|
|
943
|
+
),
|
|
944
|
+
h(Card, { title: "接下来" },
|
|
945
|
+
h("ol", { style: { margin: 0, paddingLeft: "20px", lineHeight: 1.9 } },
|
|
946
|
+
h("li", null, "托盘图标右键 → 退出(不要只关窗口,要完全退出)"),
|
|
947
|
+
h("li", null, "重新打开 DeepSeek Harness"),
|
|
948
|
+
h("li", null, "这一屏会变成正常面板,微信接入自动启动"),
|
|
949
|
+
),
|
|
950
|
+
h("div", { className: "hint", style: { marginTop: "10px" } },
|
|
951
|
+
"如果不重启,插件会一直以为还没登录 —— 因为它启动时读到的 selfId 还是空的。"),
|
|
952
|
+
),
|
|
953
|
+
err ? h("div", { className: "msg err" }, err) : null,
|
|
954
|
+
);
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
if (!form) return h("div", { className: "wxa" }, h("h2", null, "微信接入"), err ? h("div", { className: "msg err" }, err) : h("p", { className: "sub" }, "读取中…"));
|
|
958
|
+
|
|
959
|
+
// Live preview of the resulting delay so the numbers stay meaningful.
|
|
960
|
+
const seconds = (value) => { const num = Number(value); return Number.isFinite(num) ? num : 0; };
|
|
961
|
+
const gapFor = (text) => {
|
|
962
|
+
const min = Math.min(seconds(form.segmentMinSec), seconds(form.segmentMaxSec)) * 1000;
|
|
963
|
+
const max = Math.max(seconds(form.segmentMinSec), seconds(form.segmentMaxSec)) * 1000;
|
|
964
|
+
const perChar = Math.max(0, seconds(form.segmentPerCharMs));
|
|
965
|
+
return (Math.min(max, Math.max(min, min + [...String(text)].length * perChar)) / 1000).toFixed(1);
|
|
966
|
+
};
|
|
967
|
+
|
|
968
|
+
// Everything the picker needs, derived once per render.
|
|
969
|
+
const providerGroups = catalog.groups ?? [];
|
|
970
|
+
const providerNames = providerGroups.map((g) => g.id);
|
|
971
|
+
// 下拉框显示的必须是 form 里真正存着的值。
|
|
972
|
+
// 以前这里是「找不到就退回列表第一项」:面板显示一个合法组合,
|
|
973
|
+
// form 里躺着另一个,保存时写下去的既不是看到的也不是想要的。
|
|
974
|
+
const storedProviderMissing = Boolean(form.modelProvider && !providerNames.includes(form.modelProvider));
|
|
975
|
+
const activeProvider = form.modelProvider || (providerGroups[0]?.id ?? "");
|
|
976
|
+
const modelsForProvider = providerGroups.find((g) => g.id === activeProvider)?.models ?? [];
|
|
977
|
+
const storedModelMissing = Boolean(form.modelId && !modelsForProvider.some((m) => m.id === form.modelId));
|
|
978
|
+
const activeModel = form.modelId || (modelsForProvider[0]?.id ?? "");
|
|
979
|
+
const defaultLabel = catalog.default && catalog.default.provider
|
|
980
|
+
? catalog.default.provider + " / " + catalog.default.model
|
|
981
|
+
+ (catalog.default.reasoningEffort ? " · 推理 " + catalog.default.reasoningEffort : "")
|
|
982
|
+
: "(未设置)";
|
|
983
|
+
const totalModels = providerGroups.reduce((sum, g) => sum + g.models.length, 0);
|
|
984
|
+
// 已存的组合是不是真的存在?不存在时下拉框会显示成「失效项」(见下面的 option),
|
|
985
|
+
// 让人一眼看出配置是坏的,而不是看到一个被悄悄替换掉的合法值。
|
|
986
|
+
const storedModelInvalid = Boolean(!form.modelFollowDefault && (storedProviderMissing || storedModelMissing));
|
|
987
|
+
// 只有当前这组 provider/model 的菜单才算数:请求还在路上时
|
|
988
|
+
// 不能拿上一组的档位凑数,那正是「显示一个、存下去另一个」的老毛病。
|
|
989
|
+
const reasoningEfforts = reasoning.provider === activeProvider && reasoning.model === activeModel
|
|
990
|
+
? (reasoning.efforts ?? [])
|
|
991
|
+
: [];
|
|
992
|
+
const activeReasoning = form.modelReasoningEffort || "";
|
|
993
|
+
const reasoningMissing = Boolean(activeReasoning && !reasoningEfforts.some((r) => r.id === activeReasoning));
|
|
994
|
+
// 城市名和经纬度明显对不上时给个提示。查天气只用经纬度,
|
|
995
|
+
// 所以真正错的是哪一边要靠人来判断。
|
|
996
|
+
const cityWarning = cityDistanceWarning(form.wxCity, form.wxLat, form.wxLon);
|
|
997
|
+
const memeStats = memes && memes.enabled ? memes.stats : null;
|
|
998
|
+
const lifeAction = async (action, extra = {}) => {
|
|
999
|
+
setBusy(true); setErr(""); setMsg("");
|
|
1000
|
+
try {
|
|
1001
|
+
const res = await fetch(API + "/life/action", {
|
|
1002
|
+
method: "POST", credentials: "same-origin",
|
|
1003
|
+
headers: { "content-type": "application/json" },
|
|
1004
|
+
body: JSON.stringify({ action, ...extra }),
|
|
1005
|
+
});
|
|
1006
|
+
const data = await res.json();
|
|
1007
|
+
if (!data.ok) throw new Error(data.error || data.reason || "操作失败");
|
|
1008
|
+
setMsg(action === "generate"
|
|
1009
|
+
? "生成完成:" + data.counts.days + " 天 · " + data.counts.outfits + " 套穿搭 · " + data.counts.meals + " 条餐食"
|
|
1010
|
+
: "已完成");
|
|
1011
|
+
await loadLife();
|
|
1012
|
+
} catch (error) { setErr(String(error.message || error)); }
|
|
1013
|
+
finally { setBusy(false); }
|
|
1014
|
+
};
|
|
1015
|
+
/**
|
|
1016
|
+
* 立刻触发一次主动消息。
|
|
1017
|
+
*
|
|
1018
|
+
* 平时它只在日程窗口到点后才发,而窗口基本都在晚上 —— 想验证一次要等半天。
|
|
1019
|
+
* 这个按钮走的是同一个 tickProactive,只是塞了一个「现在到期」的假窗口,
|
|
1020
|
+
* 所以配额、最小间隔、目标筛选照样生效,测出来的结果就是线上的真实行为。
|
|
1021
|
+
*/
|
|
1022
|
+
const testProactive = async () => {
|
|
1023
|
+
setBusy(true); setErr(""); setMsg(""); setProactiveTest(null);
|
|
1024
|
+
try {
|
|
1025
|
+
const res = await fetch(API + "/life/action", {
|
|
1026
|
+
method: "POST", credentials: "same-origin",
|
|
1027
|
+
headers: { "content-type": "application/json" },
|
|
1028
|
+
body: JSON.stringify({ action: "test-proactive" }),
|
|
1029
|
+
});
|
|
1030
|
+
const data = await res.json();
|
|
1031
|
+
if (!data.ok) {
|
|
1032
|
+
// 没发出去也有原因可看(没到窗口 / 额度用完 / 间隔不够),
|
|
1033
|
+
// 所以这里不抛错,把 reason 显示出来更有用。
|
|
1034
|
+
setProactiveTest({ ok: false, reason: data.reason, detail: data.detail, error: data.error });
|
|
1035
|
+
} else {
|
|
1036
|
+
setProactiveTest({ ok: true, segments: data.segments, text: data.text, after: data.after });
|
|
1037
|
+
await loadLife();
|
|
1038
|
+
}
|
|
1039
|
+
} catch (error) { setErr(String(error.message || error)); }
|
|
1040
|
+
finally { setBusy(false); }
|
|
1041
|
+
};
|
|
1042
|
+
|
|
1043
|
+
|
|
1044
|
+
/**
|
|
1045
|
+
* 重抽今天的主动消息安排。
|
|
1046
|
+
*
|
|
1047
|
+
* 只清 fired(已触发记录),不动 sent(真实发送记录)——
|
|
1048
|
+
* 清掉 sent 会让配额从零开始,一天能发出的次数就超过上限了。
|
|
1049
|
+
*/
|
|
1050
|
+
const reseedToday = async () => {
|
|
1051
|
+
setBusy(true); setErr(""); setMsg("");
|
|
1052
|
+
try {
|
|
1053
|
+
const res = await fetch(API + "/life/action", {
|
|
1054
|
+
method: "POST", credentials: "same-origin",
|
|
1055
|
+
headers: { "content-type": "application/json" },
|
|
1056
|
+
body: JSON.stringify({ action: "reset-today" }),
|
|
1057
|
+
});
|
|
1058
|
+
const data = await res.json();
|
|
1059
|
+
if (!data.ok) throw new Error(data.error || "重抽失败");
|
|
1060
|
+
const wins = data.proactive?.windowsToday ?? [];
|
|
1061
|
+
setMsg("已重抽:" + (wins.length ? "今天 " + wins.join("、") : "今天没有安排"));
|
|
1062
|
+
await load();
|
|
1063
|
+
} catch (error) { setErr(String(error.message || error)); }
|
|
1064
|
+
finally { setBusy(false); }
|
|
1065
|
+
};
|
|
1066
|
+
|
|
1067
|
+
const memoryAction = async (action, extra = {}) => {
|
|
1068
|
+
setBusy(true); setErr(""); setMsg("");
|
|
1069
|
+
try {
|
|
1070
|
+
const res = await fetch(API + "/memory/action", {
|
|
1071
|
+
method: "POST", credentials: "same-origin",
|
|
1072
|
+
headers: { "content-type": "application/json" },
|
|
1073
|
+
body: JSON.stringify({ action, ...extra }),
|
|
1074
|
+
});
|
|
1075
|
+
const data = await res.json();
|
|
1076
|
+
if (!data.ok) throw new Error(data.error || "操作失败");
|
|
1077
|
+
setMsg(action === "forget" ? "已忘掉这条" : "已记住");
|
|
1078
|
+
await loadMemory();
|
|
1079
|
+
} catch (error) { setErr(String(error.message || error)); }
|
|
1080
|
+
finally { setBusy(false); }
|
|
1081
|
+
};
|
|
1082
|
+
|
|
1083
|
+
const emotionAction = async (action, extra = {}) => {
|
|
1084
|
+
setBusy(true); setErr(""); setMsg("");
|
|
1085
|
+
try {
|
|
1086
|
+
const res = await fetch(API + "/emotion/action", {
|
|
1087
|
+
method: "POST", credentials: "same-origin",
|
|
1088
|
+
headers: { "content-type": "application/json" },
|
|
1089
|
+
body: JSON.stringify({ action, ...extra }),
|
|
1090
|
+
});
|
|
1091
|
+
const data = await res.json();
|
|
1092
|
+
if (!data.ok) throw new Error(data.error || "操作失败");
|
|
1093
|
+
setMsg(action === "reset" ? "已重置该档案" : "已更新:好感 " + data.favor + " / 亲密 " + data.intimacy + " / " + data.stage);
|
|
1094
|
+
await loadEmotion();
|
|
1095
|
+
} catch (error) { setErr(String(error.message || error)); }
|
|
1096
|
+
finally { setBusy(false); }
|
|
1097
|
+
};
|
|
1098
|
+
|
|
1099
|
+
const memeAction = async (action, extra = {}) => {
|
|
1100
|
+
setBusy(true); setErr(""); setMsg("");
|
|
1101
|
+
try {
|
|
1102
|
+
const res = await fetch(API + "/memes/action", {
|
|
1103
|
+
method: "POST", credentials: "same-origin",
|
|
1104
|
+
headers: { "content-type": "application/json" },
|
|
1105
|
+
body: JSON.stringify({ action, ...extra }),
|
|
1106
|
+
});
|
|
1107
|
+
const data = await res.json();
|
|
1108
|
+
if (!data.ok) throw new Error(data.error || data.reason || "操作失败");
|
|
1109
|
+
const summary = action === "import"
|
|
1110
|
+
? "导入完成:扫描 " + data.scanned + " 张,新增 " + data.added + " 张"
|
|
1111
|
+
: action === "classify"
|
|
1112
|
+
? "分类完成:" + data.classified + " 张" + (data.remaining ? ",还剩 " + data.remaining + " 张" : "")
|
|
1113
|
+
: "已完成";
|
|
1114
|
+
setMsg(summary);
|
|
1115
|
+
await loadMemes();
|
|
1116
|
+
} catch (error) { setErr(String(error.message || error)); }
|
|
1117
|
+
finally { setBusy(false); }
|
|
1118
|
+
};
|
|
1119
|
+
|
|
1120
|
+
|
|
1121
|
+
const online = Boolean(state && state.connected);
|
|
1122
|
+
|
|
1123
|
+
return h("div", { className: "wxa" },
|
|
1124
|
+
h("div", { className: "row" },
|
|
1125
|
+
h("div", null,
|
|
1126
|
+
h("h2", null, "微信接入"),
|
|
1127
|
+
h("p", { className: "sub" },
|
|
1128
|
+
(state.nickname ? state.nickname + "(" + (state.selfId || "-") + ")" : "账号 " + (state.selfId || "-"))
|
|
1129
|
+
+ " · agent-wechat " + (state.wechat ? (state.wechat.baseUrl || "") : "-")),
|
|
1130
|
+
),
|
|
1131
|
+
h("div", { className: "row" },
|
|
1132
|
+
h("span", { className: "badge " + (online ? "ok" : "bad") }, online ? "在线" : "未连接"),
|
|
1133
|
+
// 项目主页:只显示 GitHub 图标,不明文暴露链接。
|
|
1134
|
+
h("button", {
|
|
1135
|
+
className: "ghost icon",
|
|
1136
|
+
title: "在 GitHub 上查看项目",
|
|
1137
|
+
"aria-label": "在 GitHub 上查看项目",
|
|
1138
|
+
onClick: () => window.open(REPO_URL, "_blank", "noopener,noreferrer"),
|
|
1139
|
+
},
|
|
1140
|
+
h("svg", {
|
|
1141
|
+
width: "16", height: "16", viewBox: "0 0 16 16",
|
|
1142
|
+
fill: "currentColor", "aria-hidden": "true",
|
|
1143
|
+
},
|
|
1144
|
+
h("path", {
|
|
1145
|
+
fillRule: "evenodd",
|
|
1146
|
+
d: "M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27s1.36.09 2 .27c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 16 8c0-4.42-3.58-8-8-8z",
|
|
1147
|
+
}),
|
|
1148
|
+
),
|
|
1149
|
+
),
|
|
1150
|
+
h("button", { className: "ghost", onClick: () => setShowGuide((v) => !v) }, showGuide ? "收起教程" : "配置教程"),
|
|
1151
|
+
h("button", { className: "ghost", onClick: () => load(), disabled: busy }, "刷新"),
|
|
1152
|
+
),
|
|
1153
|
+
),
|
|
1154
|
+
|
|
1155
|
+
// UI 优化:17 个卡片平铺时改一个开关要滚很久。这里给出分组跳转条,
|
|
1156
|
+
// 用原生锚点(面板滚动容器里也能用,不需要 JS 滚动逻辑)。
|
|
1157
|
+
state.bootError ? h("div", { className: "msg err" },
|
|
1158
|
+
"启动失败(" + String(state.bootError.code || "STARTUP") + "):" + String(state.bootError.message || "")
|
|
1159
|
+
+ (state.bootError.lockOwner ? ";锁占用进程 " + String(state.bootError.lockOwner.pid ?? "-") : "")
|
|
1160
|
+
+ "",
|
|
1161
|
+
) : null,
|
|
1162
|
+
|
|
1163
|
+
h("div", { className: "quicknav sticky" },
|
|
1164
|
+
h("span", { className: "qnlbl" }, "快速跳转:"),
|
|
1165
|
+
// 四个语义组:先回消息本身怎么回,再是「像谁」,再是主动产出,最后是系统项。
|
|
1166
|
+
// 顺序也照应页面上卡片的排列,从组跳到相邻的卡不会来回折返。
|
|
1167
|
+
h("span", { className: "qngrp" },
|
|
1168
|
+
h("span", { className: "qng" }, "对话"),
|
|
1169
|
+
h("a", { href: "#card-model" }, "模型"),
|
|
1170
|
+
h("a", { href: "#card-reply" }, "自动回复"),
|
|
1171
|
+
h("a", { href: "#card-access" }, "回复范围"),
|
|
1172
|
+
h("a", { href: "#card-rate" }, "回复节奏"),
|
|
1173
|
+
),
|
|
1174
|
+
h("span", { className: "qngrp" },
|
|
1175
|
+
h("span", { className: "qng" }, "人设"),
|
|
1176
|
+
h("a", { href: "#card-persona" }, "人格"),
|
|
1177
|
+
h("a", { href: "#card-emotion" }, "情感"),
|
|
1178
|
+
h("a", { href: "#card-endocrine" }, "内分泌"),
|
|
1179
|
+
h("a", { href: "#card-memory" }, "记忆"),
|
|
1180
|
+
h("a", { href: "#card-memes" }, "表情包"),
|
|
1181
|
+
),
|
|
1182
|
+
h("span", { className: "qngrp" },
|
|
1183
|
+
h("span", { className: "qng" }, "主动"),
|
|
1184
|
+
h("a", { href: "#card-life" }, "虚拟人生"),
|
|
1185
|
+
|
|
1186
|
+
h("a", { href: "#card-image" }, "生图"),
|
|
1187
|
+
h("a", { href: "#card-steam" }, "Steam"),
|
|
1188
|
+
),
|
|
1189
|
+
h("span", { className: "qngrp" },
|
|
1190
|
+
h("span", { className: "qng" }, "系统"),
|
|
1191
|
+
h("a", { href: "#card-link" }, "链接解析"),
|
|
1192
|
+
h("a", { href: "#card-wechat" }, "微信"),
|
|
1193
|
+
h("a", { href: "#card-archive" }, "归档"),
|
|
1194
|
+
),
|
|
1195
|
+
),
|
|
1196
|
+
// UI 优化:保存按钮原来只在页尾,改完上面的设置要滚到底才能保存。
|
|
1197
|
+
// 顶部也放一个,dirty 状态和页尾完全同步。
|
|
1198
|
+
h("div", { className: "row", style: { marginTop: "-4px" } },
|
|
1199
|
+
h("div", null),
|
|
1200
|
+
h("button", { onClick: save, disabled: busy }, busy ? "保存中…" : (dirty ? "保存设置 *" : "保存设置")),
|
|
1201
|
+
),
|
|
1202
|
+
// 配置教程抽屉。内容要能独立看懂:首次配置两步、为什么重启两次、
|
|
1203
|
+
// 以及最容易被忽略的「守护进程要自己常驻」。
|
|
1204
|
+
showGuide
|
|
1205
|
+
? h(Card, { title: "配置教程" },
|
|
1206
|
+
h("div", { style: { lineHeight: 1.9, fontSize: "13px" } },
|
|
1207
|
+
h("div", {
|
|
1208
|
+
style: {
|
|
1209
|
+
border: "2px solid rgba(214,90,60,0.6)",
|
|
1210
|
+
background: "rgba(214,90,60,0.10)",
|
|
1211
|
+
borderRadius: "8px",
|
|
1212
|
+
padding: "12px 14px",
|
|
1213
|
+
margin: "0 0 18px",
|
|
1214
|
+
},
|
|
1215
|
+
},
|
|
1216
|
+
h("div", { style: { fontWeight: 700, fontSize: "14px", marginBottom: "8px" } }, "⚠ 改完配置一定要点最下方的「保存设置」"),
|
|
1217
|
+
h("div", { style: { marginBottom: "8px" } }, "面板上的输入框、开关、下拉框都只是本地草稿。不点保存,它们不会写进 config.json,刷新页面就全变回去了。"),
|
|
1218
|
+
h("div", { style: { marginBottom: "6px" } }, "正确顺序:改完 → 滚到页面最底部 → 点「保存设置」→ 看到「已保存」→ 需要重启的再重启 DSH。"),
|
|
1219
|
+
h("div", { className: "hint", style: { margin: "6px 0 0" } }, "按钮上带 * 号(显示成「保存设置 *」)说明还有未保存的修改。这个星号是最可靠的判断依据。"),
|
|
1220
|
+
),
|
|
1221
|
+
h("div", {
|
|
1222
|
+
style: {
|
|
1223
|
+
border: "1px solid rgba(214,148,50,0.55)",
|
|
1224
|
+
background: "rgba(214,148,50,0.10)",
|
|
1225
|
+
borderRadius: "8px",
|
|
1226
|
+
padding: "12px 14px",
|
|
1227
|
+
margin: "0 0 20px",
|
|
1228
|
+
},
|
|
1229
|
+
},
|
|
1230
|
+
h("div", { style: { fontWeight: 700, fontSize: "14px", marginBottom: "8px" } }, "★ 哪些改动要重启、哪些立刻生效"),
|
|
1231
|
+
h("div", { style: { marginBottom: "6px" } }, "立刻生效(保存按钮会提示「已即时生效」):回复节奏、批量窗口、生图开关与数量、Steam 开关、虚拟生活、表情包、情感、记忆、访问控制、人格。"),
|
|
1232
|
+
h("div", { style: { marginBottom: "6px" } }, "要重启 DSH:微信接入(地址、token、账号)、模型服务商与模型名、生图的服务商与模型名。"),
|
|
1233
|
+
h("div", { className: "hint", style: { margin: "6px 0 0" } }, "拿不准就重启一次,不会有副作用。"),
|
|
1234
|
+
),
|
|
1235
|
+
// 快速跳转:8 个章节锚点。教程很长,没有这个用户只能一路滚。
|
|
1236
|
+
// <a href="#id"> 在面板的滚动容器里也能用,不需要 JS。
|
|
1237
|
+
h("div", { style: {
|
|
1238
|
+
display: "flex", flexWrap: "wrap", gap: "8px",
|
|
1239
|
+
padding: "12px 14px", margin: "20px 0 20px",
|
|
1240
|
+
border: "1px solid rgba(127,127,127,0.28)",
|
|
1241
|
+
borderRadius: "8px", background: "rgba(127,127,127,0.06)",
|
|
1242
|
+
} },
|
|
1243
|
+
h("div", { style: { width: "100%", fontWeight: 600, fontSize: "12.5px", marginBottom: "2px" } }, "快速跳转"),
|
|
1244
|
+
h("a", { href: "#guide-save", style: { fontSize: "12.5px", padding: "3px 10px", borderRadius: "999px", border: "1px solid rgba(127,127,127,0.35)", textDecoration: "none", color: "inherit", background: "rgba(127,127,127,0.10)" } }, "1. 保存机制"),
|
|
1245
|
+
h("a", { href: "#guide-login", style: { fontSize: "12.5px", padding: "3px 10px", borderRadius: "999px", border: "1px solid rgba(127,127,127,0.35)", textDecoration: "none", color: "inherit", background: "rgba(127,127,127,0.10)" } }, "2. 首次登录"),
|
|
1246
|
+
h("a", { href: "#guide-key", style: { fontSize: "12.5px", padding: "3px 10px", borderRadius: "999px", border: "1px solid rgba(127,127,127,0.35)", textDecoration: "none", color: "inherit", background: "rgba(127,127,127,0.10)" } }, "3. 获取 Key"),
|
|
1247
|
+
h("a", { href: "#guide-ext", style: { fontSize: "12.5px", padding: "3px 10px", borderRadius: "999px", border: "1px solid rgba(127,127,127,0.35)", textDecoration: "none", color: "inherit", background: "rgba(127,127,127,0.10)" } }, "4. 扩展功能"),
|
|
1248
|
+
h("a", { href: "#guide-reply", style: { fontSize: "12.5px", padding: "3px 10px", borderRadius: "999px", border: "1px solid rgba(127,127,127,0.35)", textDecoration: "none", color: "inherit", background: "rgba(127,127,127,0.10)" } }, "5. 回复与人格"),
|
|
1249
|
+
h("a", { href: "#guide-panel", style: { fontSize: "12.5px", padding: "3px 10px", borderRadius: "999px", border: "1px solid rgba(127,127,127,0.35)", textDecoration: "none", color: "inherit", background: "rgba(127,127,127,0.10)" } }, "6. 面板说明"),
|
|
1250
|
+
h("a", { href: "#guide-restore", style: { fontSize: "12.5px", padding: "3px 10px", borderRadius: "999px", border: "1px solid rgba(127,127,127,0.35)", textDecoration: "none", color: "inherit", background: "rgba(127,127,127,0.10)" } }, "7. 配置恢复"),
|
|
1251
|
+
h("a", { href: "#guide-tips", style: { fontSize: "12.5px", padding: "3px 10px", borderRadius: "999px", border: "1px solid rgba(127,127,127,0.35)", textDecoration: "none", color: "inherit", background: "rgba(127,127,127,0.10)" } }, "8. 使用建议"),
|
|
1252
|
+
),
|
|
1253
|
+
h("div", { style: { marginBottom: "8px" } }, "本文介绍 DSH 微信插件的安装初始化、功能配置及常见问题处理。建议第一次使用时按照章节顺序操作,熟悉插件后再根据自己的需求调整各项设置。"),
|
|
1254
|
+
h("div", { id: "guide-save", style: { fontWeight: 600, fontSize: "15px", margin: "24px 0 10px" } }, "1. 修改配置前,先了解保存机制"),
|
|
1255
|
+
h("div", { style: { marginBottom: "8px" } }, "⚠️ 修改配置后,一定要点击页面最下方的「保存设置」。"),
|
|
1256
|
+
h("div", { style: { marginBottom: "8px" } }, "面板上的输入框、开关和下拉选项在修改时都只是临时草稿,并不会立即写入 `config.json`。只有点击「保存设置」后,修改才会真正生效并保存到本地。"),
|
|
1257
|
+
h("div", { style: { marginBottom: "8px" } }, "每次修改配置后,按照以下步骤操作:"),
|
|
1258
|
+
h("ol", { style: { margin: "0 0 10px", paddingLeft: "22px" } },
|
|
1259
|
+
h("li", null, "完成需要的修改。"),
|
|
1260
|
+
h("li", null, "滚动到页面最底部,点击「保存设置」。"),
|
|
1261
|
+
h("li", null, "看到「已保存」提示后,说明配置已经写入。"),
|
|
1262
|
+
h("li", null, "根据配置项的要求决定是否重启 DSH。"),
|
|
1263
|
+
),
|
|
1264
|
+
h("div", { style: { marginBottom: "8px" } }, "保存按钮显示为「保存设置 *」时,说明还有修改没有保存。看到这个星号,就意味着当前配置尚未提交。"),
|
|
1265
|
+
h("div", { style: { fontWeight: 600, fontSize: "13.5px", margin: "18px 0 10px" } }, "哪些配置需要重启?"),
|
|
1266
|
+
h("div", { style: { marginBottom: "8px" } }, "插件中的配置分为两种生效方式:"),
|
|
1267
|
+
h("table", { style: { borderCollapse: "collapse", width: "100%", margin: "0 0 10px", fontSize: "12.5px" } },
|
|
1268
|
+
h("tr", null,
|
|
1269
|
+
h("th", { style: { border: "1px solid rgba(127,127,127,0.3)", padding: "6px 8px", textAlign: "left", fontWeight: 600 } }, "保存后立即生效"),
|
|
1270
|
+
h("th", { style: { border: "1px solid rgba(127,127,127,0.3)", padding: "6px 8px", textAlign: "left", fontWeight: 600 } }, "保存后需要重启 DSH"),
|
|
1271
|
+
),
|
|
1272
|
+
h("tr", null,
|
|
1273
|
+
h("td", { style: { border: "1px solid rgba(127,127,127,0.3)", padding: "6px 8px", textAlign: "left", fontWeight: 400 } }, "回复节奏、批量窗口"),
|
|
1274
|
+
h("td", { style: { border: "1px solid rgba(127,127,127,0.3)", padding: "6px 8px", textAlign: "left", fontWeight: 400 } }, "微信接入相关配置"),
|
|
1275
|
+
),
|
|
1276
|
+
h("tr", null,
|
|
1277
|
+
h("td", { style: { border: "1px solid rgba(127,127,127,0.3)", padding: "6px 8px", textAlign: "left", fontWeight: 400 } }, "生图开关、生成数量"),
|
|
1278
|
+
h("td", { style: { border: "1px solid rgba(127,127,127,0.3)", padding: "6px 8px", textAlign: "left", fontWeight: 400 } }, "模型服务商、模型名称"),
|
|
1279
|
+
),
|
|
1280
|
+
h("tr", null,
|
|
1281
|
+
h("td", { style: { border: "1px solid rgba(127,127,127,0.3)", padding: "6px 8px", textAlign: "left", fontWeight: 400 } }, "Steam 开关"),
|
|
1282
|
+
h("td", { style: { border: "1px solid rgba(127,127,127,0.3)", padding: "6px 8px", textAlign: "left", fontWeight: 400 } }, "生图服务商、生图模型"),
|
|
1283
|
+
),
|
|
1284
|
+
h("tr", null,
|
|
1285
|
+
h("td", { style: { border: "1px solid rgba(127,127,127,0.3)", padding: "6px 8px", textAlign: "left", fontWeight: 400 } }, "虚拟生活"),
|
|
1286
|
+
h("td", { style: { border: "1px solid rgba(127,127,127,0.3)", padding: "6px 8px", textAlign: "left", fontWeight: 400 } }, ""),
|
|
1287
|
+
),
|
|
1288
|
+
h("tr", null,
|
|
1289
|
+
h("td", { style: { border: "1px solid rgba(127,127,127,0.3)", padding: "6px 8px", textAlign: "left", fontWeight: 400 } }, "表情包"),
|
|
1290
|
+
h("td", { style: { border: "1px solid rgba(127,127,127,0.3)", padding: "6px 8px", textAlign: "left", fontWeight: 400 } }, ""),
|
|
1291
|
+
),
|
|
1292
|
+
h("tr", null,
|
|
1293
|
+
h("td", { style: { border: "1px solid rgba(127,127,127,0.3)", padding: "6px 8px", textAlign: "left", fontWeight: 400 } }, "情感与关系"),
|
|
1294
|
+
h("td", { style: { border: "1px solid rgba(127,127,127,0.3)", padding: "6px 8px", textAlign: "left", fontWeight: 400 } }, ""),
|
|
1295
|
+
),
|
|
1296
|
+
h("tr", null,
|
|
1297
|
+
h("td", { style: { border: "1px solid rgba(127,127,127,0.3)", padding: "6px 8px", textAlign: "left", fontWeight: 400 } }, "长期记忆"),
|
|
1298
|
+
h("td", { style: { border: "1px solid rgba(127,127,127,0.3)", padding: "6px 8px", textAlign: "left", fontWeight: 400 } }, ""),
|
|
1299
|
+
),
|
|
1300
|
+
h("tr", null,
|
|
1301
|
+
h("td", { style: { border: "1px solid rgba(127,127,127,0.3)", padding: "6px 8px", textAlign: "left", fontWeight: 400 } }, "访问控制"),
|
|
1302
|
+
h("td", { style: { border: "1px solid rgba(127,127,127,0.3)", padding: "6px 8px", textAlign: "left", fontWeight: 400 } }, ""),
|
|
1303
|
+
),
|
|
1304
|
+
h("tr", null,
|
|
1305
|
+
h("td", { style: { border: "1px solid rgba(127,127,127,0.3)", padding: "6px 8px", textAlign: "left", fontWeight: 400 } }, "人格设定"),
|
|
1306
|
+
h("td", { style: { border: "1px solid rgba(127,127,127,0.3)", padding: "6px 8px", textAlign: "left", fontWeight: 400 } }, ""),
|
|
1307
|
+
),
|
|
1308
|
+
),
|
|
1309
|
+
h("div", { style: { marginBottom: "8px" } }, "保存时,面板也会提示配置是否已经即时生效。"),
|
|
1310
|
+
h("div", { style: { marginBottom: "8px" } }, "不确定某项配置是否需要重启时,保存后重新启动一次 DSH 即可。"),
|
|
1311
|
+
h("div", { id: "guide-login", style: { fontWeight: 600, fontSize: "15px", margin: "24px 0 10px" } }, "2. 首次启动与微信登录"),
|
|
1312
|
+
h("div", { style: { fontWeight: 600, fontSize: "13.5px", margin: "18px 0 10px" } }, "2.1 先把 agent-wechat 跑起来"),
|
|
1313
|
+
h("div", { style: { marginBottom: "8px" } }, "这个插件不会自己启动微信客户端。它连的是电脑上已经跑着的 agent-wechat 守护进程,所以第一步是把那个进程跑起来。"),
|
|
1314
|
+
h("ol", { style: { margin: "0 0 10px", paddingLeft: "22px" } },
|
|
1315
|
+
h("li", null, "打开 agent-wechat 桌面端(或者命令行执行 wx serve),让它常驻。"),
|
|
1316
|
+
h("li", null, "用手机微信扫码登录,确认账号状态是「在线」。"),
|
|
1317
|
+
h("li", null, "执行 wx tokens create dsh-wechat-access --accounts '*' --scopes read --scopes send --scopes media --scopes read-state 拿一个 token。"),
|
|
1318
|
+
h("li", null, "把 token 填进面板,保存后重载插件。"),
|
|
1319
|
+
),
|
|
1320
|
+
h("div", { style: { marginBottom: "8px" } }, "token 只需要 read / send / media / read-state 四个权限,不需要 admin。插件自己也不会去建账号或改安全设置。"),
|
|
1321
|
+
h("div", { style: { fontWeight: 600, fontSize: "13.5px", margin: "18px 0 10px" } }, "2.2 连不上怎么办"),
|
|
1322
|
+
h("div", { style: { marginBottom: "8px" } }, "面板上一直显示「还没连上微信」,通常只有四种原因,按这个顺序查:"),
|
|
1323
|
+
h("ol", { style: { margin: "0 0 10px", paddingLeft: "22px" } },
|
|
1324
|
+
h("li", null, "agent-wechat 没在跑 —— 任务栏里应该能看到它。"),
|
|
1325
|
+
h("li", null, "守护进程在跑,但账号没登录,或者掉线了。"),
|
|
1326
|
+
h("li", null, "地址填错。默认是 http://127.0.0.1:6174/v1,端口要和守护进程实际监听的一致。"),
|
|
1327
|
+
h("li", null, "token 不对或被吊销。重新用 wx tokens create 生成一个。"),
|
|
1328
|
+
),
|
|
1329
|
+
h("div", { style: { marginBottom: "8px" } }, "地址只允许填本机回环地址(127.0.0.1 / localhost / ::1)。如果守护进程在另一台机器上,正确做法是在本机做 SSH 端口转发,而不是把端口暴露到网络上 —— 拿到 token 就等于能以你的微信身份发消息、读全部聊天记录。"),
|
|
1330
|
+
h("div", { style: { marginBottom: "8px" } }, "配置文件中保存着 token,所以让 Agent 改配置时一定要明确要求它不要动其它字段。"),
|
|
1331
|
+
// ── 2.3 更新插件 ─────────────────────────────────────
|
|
1332
|
+
h("div", { style: { fontWeight: 600, fontSize: "13.5px", margin: "18px 0 10px" } }, "2.3 更新插件时要注意什么"),
|
|
1333
|
+
h("div", { style: { marginBottom: "8px" } }, "更新插件必须先关掉 DSH,再换包,最后重新启动。"),
|
|
1334
|
+
h("ol", { style: { margin: "0 0 10px", paddingLeft: "22px" } },
|
|
1335
|
+
h("li", null, "关掉 DSH。"),
|
|
1336
|
+
h("li", null, "执行 dsh plugin remove / add,或替换 tgz 安装包。"),
|
|
1337
|
+
h("li", null, "重新启动 DSH。"),
|
|
1338
|
+
),
|
|
1339
|
+
// 这条是真实事故:一边跑一边换包,旧实例变成僵尸,占着端口,
|
|
1340
|
+
// 新实例起不来,表现是「插件面板正常、微信也登着,但她一条都不回」。
|
|
1341
|
+
h("div", { className: "hint", style: { margin: "6px 0 10px" } },
|
|
1342
|
+
"不要一边运行一边换包。那样会留下一个已经失效、却仍在占着端口的旧实例:",
|
|
1343
|
+
"面板看着一切正常,她也收得到消息,但就是一条都不回。"),
|
|
1344
|
+
h("div", { style: { marginBottom: "8px" } }, "怎么判断是不是这种情况?看 debug.log,如果每分钟出现一条:"),
|
|
1345
|
+
h("div", { style: { fontFamily: "ui-monospace, Consolas, monospace", fontSize: "12px", background: "rgba(127,127,127,0.12)", padding: "8px 10px", borderRadius: "6px", margin: "0 0 10px", wordBreak: "break-all" } },
|
|
1346
|
+
"微信自动回复失败 (Error) Error: cannot get required service \"agents\" in inactive context"),
|
|
1347
|
+
h("div", { style: { marginBottom: "8px" } }, "那就重启一次 DSH,问题会消失。1.4.1 起插件会自己识别并退出,但那只是兜底。"),
|
|
1348
|
+
|
|
1349
|
+
h("div", { id: "guide-key", style: { fontWeight: 600, fontSize: "15px", margin: "24px 0 10px" } }, "3. 获取 API Key"),
|
|
1350
|
+
h("div", { style: { marginBottom: "8px" } }, "插件支持接入和风天气与 Steam。两项服务都有免费的使用额度,不配置也不会影响基本聊天,只是无法使用对应功能。"),
|
|
1351
|
+
h("div", { style: { fontWeight: 600, fontSize: "13.5px", margin: "18px 0 10px" } }, "3.1 和风天气"),
|
|
1352
|
+
h("div", { style: { marginBottom: "8px" } }, "和风天气用于获取虚拟人物所在地的天气信息。"),
|
|
1353
|
+
h("div", { style: { marginBottom: "8px" } }, "获取 Key:"),
|
|
1354
|
+
h("ol", { style: { margin: "0 0 10px", paddingLeft: "22px" } },
|
|
1355
|
+
h("li", null, "打开和风天气开发平台(dev.qweather.com),使用邮箱注册。"),
|
|
1356
|
+
h("li", null, "登录控制台,进入「项目管理」并创建项目。"),
|
|
1357
|
+
h("li", null, "在项目中点击「添加数据」,选择天气预报相关服务。"),
|
|
1358
|
+
h("li", null, "返回项目页面,复制 API Key。"),
|
|
1359
|
+
),
|
|
1360
|
+
h("div", { style: { marginBottom: "8px" } }, "填写配置:"),
|
|
1361
|
+
h("ol", { style: { margin: "0 0 10px", paddingLeft: "22px" } },
|
|
1362
|
+
h("li", null, "打开插件面板中的【虚拟人生】卡片。"),
|
|
1363
|
+
h("li", null, "将 API Key 填入天气配置栏。"),
|
|
1364
|
+
h("li", null, "填写城市名称和对应的经纬度。"),
|
|
1365
|
+
h("li", null, "点击「保存设置」。"),
|
|
1366
|
+
),
|
|
1367
|
+
h("div", { style: { marginBottom: "8px" } }, "几个容易出错的地方:"),
|
|
1368
|
+
h("ul", { style: { margin: "0 0 10px", paddingLeft: "22px" } },
|
|
1369
|
+
h("li", null, "API Key 长度为 8–128 位,只能包含字母、数字以及 . _ -,不要把其他说明文字一起复制进去。"),
|
|
1370
|
+
h("li", null, "天气查询实际使用的是经纬度,城市名称主要用于提示词。经纬度填错会导致查询地点不正确。"),
|
|
1371
|
+
h("li", null, "和风天气公共域名 api.qweather.com 正在停用。如果需要填写 API Host,请使用控制台提供的地址。"),
|
|
1372
|
+
h("li", null, "免费版有每日调用额度限制。超过额度后,天气功能可能会退化为根据季节推测天气,而不是直接报错。"),
|
|
1373
|
+
),
|
|
1374
|
+
h("div", { style: { fontWeight: 600, fontSize: "13.5px", margin: "18px 0 10px" } }, "3.2 Steam"),
|
|
1375
|
+
h("div", { style: { marginBottom: "8px" } }, "Steam 接入后,插件可以获取绑定账号的游戏状态,例如当前正在玩的游戏。"),
|
|
1376
|
+
h("div", { style: { marginBottom: "8px" } }, "获取 Key:"),
|
|
1377
|
+
h("ol", { style: { margin: "0 0 10px", paddingLeft: "22px" } },
|
|
1378
|
+
h("li", null, "打开 Steam API Key 申请页面(steamcommunity.com/dev/apikey)。"),
|
|
1379
|
+
h("li", null, "使用 Steam 账号登录。"),
|
|
1380
|
+
h("li", null, "在「Domain Name」中填写 localhost 即可。"),
|
|
1381
|
+
h("li", null, "同意相关条款,点击 Register。"),
|
|
1382
|
+
h("li", null, "页面会显示一串 32 位十六进制 Key,复制备用。"),
|
|
1383
|
+
),
|
|
1384
|
+
h("div", { style: { marginBottom: "8px" } }, "填写配置:"),
|
|
1385
|
+
h("ol", { style: { margin: "0 0 10px", paddingLeft: "22px" } },
|
|
1386
|
+
h("li", null, "打开面板中的【Steam】卡片。"),
|
|
1387
|
+
h("li", null, "将 Key 粘贴到 API Key 输入框。"),
|
|
1388
|
+
h("li", null, "开启「接入 Steam 状态」。"),
|
|
1389
|
+
h("li", null, "点击「保存设置」。"),
|
|
1390
|
+
h("li", null, "在下方的「绑定表」中填写联系人和对应的 17 位 SteamID64。"),
|
|
1391
|
+
h("li", null, "点击「绑定」完成关联。"),
|
|
1392
|
+
),
|
|
1393
|
+
h("div", { style: { marginBottom: "8px" } }, "注意事项:"),
|
|
1394
|
+
h("ul", { style: { margin: "0 0 10px", paddingLeft: "22px" } },
|
|
1395
|
+
h("li", null, "Steam 隐私设置中的「游戏详情」必须设为公开,否则插件可能无法获取游戏时长等信息。"),
|
|
1396
|
+
h("li", null, "如果游戏详情设置为私密,API 可能返回空对象而不报错,容易误以为账号没有游戏记录。"),
|
|
1397
|
+
h("li", null, "API Key 绑定在 Steam 账号上,长期有效。需要更换时,先到 Steam 端注销原来的 Key。"),
|
|
1398
|
+
h("li", null, "Key 只保存在本地,面板只会返回是否保存成功的状态,不会回传明文。"),
|
|
1399
|
+
h("li", null, "更换绑定账号时,先在「绑定表」中点击「解绑」,再重新绑定即可。"),
|
|
1400
|
+
),
|
|
1401
|
+
h("div", { style: { marginBottom: "8px" } }, "如何查找 SteamID64?"),
|
|
1402
|
+
h("div", { style: { marginBottom: "8px" } }, "打开 Steam 个人资料页面,查看浏览器地址栏。"),
|
|
1403
|
+
h("div", { style: { marginBottom: "8px" } }, "如果地址是 steamcommunity.com/profiles/7656119xxxxxxxxxx,其中的 17 位数字就是 SteamID64。"),
|
|
1404
|
+
h("div", { style: { marginBottom: "8px" } }, "如果使用的是自定义地址,例如 /id/xxx,可以在 Steam 客户端的「编辑个人资料」中查找,也可以使用第三方查询工具。不要向不可信的网站提供账号凭据。"),
|
|
1405
|
+
h("div", { id: "guide-ext", style: { fontWeight: 600, fontSize: "15px", margin: "24px 0 10px" } }, "4. 扩展功能"),
|
|
1406
|
+
h("div", { style: { marginBottom: "8px" } }, "以下功能可以按需启用,不使用时保持默认设置即可。"),
|
|
1407
|
+
h("div", { style: { fontWeight: 600, fontSize: "13.5px", margin: "18px 0 10px" } }, "4.1 生图"),
|
|
1408
|
+
h("div", { style: { marginBottom: "8px" } }, "生图功能允许她根据聊天内容主动生成图片,并通过微信发送。"),
|
|
1409
|
+
h("div", { style: { marginBottom: "8px" } }, "使用前必须安装 dsh-connect-doubao。"),
|
|
1410
|
+
h("div", { style: { marginBottom: "8px" } }, "本插件本身不提供生图模型,而是调用 dsh-connect-doubao 注册的「豆包 生图」能力。因此,需要先安装该插件,并完成豆包扫码登录。"),
|
|
1411
|
+
h("div", { style: { marginBottom: "8px" } }, "在 DSH 终端中执行:"),
|
|
1412
|
+
h("div", { style: { fontFamily: "ui-monospace, Consolas, monospace", fontSize: "12px", background: "rgba(127,127,127,0.12)", padding: "8px 10px", borderRadius: "6px", margin: "0 0 10px", wordBreak: "break-all" } }, "dsh plugin --profile desktop add dsh-connect-doubao"),
|
|
1413
|
+
h("div", { style: { marginBottom: "8px" } }, "安装完成后,打开 dsh-connect-doubao 的面板,扫码登录豆包。"),
|
|
1414
|
+
h("div", { style: { marginBottom: "8px" } }, "完成以上步骤后,再回到本插件的【生图】卡片进行配置。"),
|
|
1415
|
+
h("div", { style: { marginBottom: "8px" } }, "配置步骤:"),
|
|
1416
|
+
h("ol", { style: { margin: "0 0 10px", paddingLeft: "22px" } },
|
|
1417
|
+
h("li", null, "开启「允许她自己发图」。"),
|
|
1418
|
+
h("li", null, "「服务商」保持为 doubao。"),
|
|
1419
|
+
h("li", null, "「生图模型」保持为 image-gen。"),
|
|
1420
|
+
h("li", null, "设置「每次最多发几张」,范围为 1–6。"),
|
|
1421
|
+
h("li", null, "设置「超时(秒)」,默认值为 120。"),
|
|
1422
|
+
h("li", null, "点击「保存设置」。"),
|
|
1423
|
+
),
|
|
1424
|
+
h("div", { style: { marginBottom: "8px" } }, "服务商和模型使用默认值即可,一般不需要修改。"),
|
|
1425
|
+
h("div", { style: { marginBottom: "8px" } }, "参数说明:"),
|
|
1426
|
+
h("ul", { style: { margin: "0 0 10px", paddingLeft: "22px" } },
|
|
1427
|
+
h("li", null, "每次最多发几张:限制一次最多发送多少张图片。豆包通常一次返回 1–3 张,超过设置数量的图片只发送前几张。"),
|
|
1428
|
+
h("li", null, "超时(秒):限制单次生图请求的等待时间。一般生图需要 10–30 秒,默认 120 秒。如果超过设定时间仍未完成,插件会放弃本次生成,避免一直占用当前回复流程。"),
|
|
1429
|
+
),
|
|
1430
|
+
h("div", { style: { marginBottom: "8px" } }, "其他说明:"),
|
|
1431
|
+
h("ul", { style: { margin: "0 0 10px", paddingLeft: "22px" } },
|
|
1432
|
+
h("li", null, "生图会消耗豆包额度,与聊天分开计费。"),
|
|
1433
|
+
h("li", null, "修改生图开关、生成数量和超时时间后,保存即可生效。"),
|
|
1434
|
+
h("li", null, "修改服务商或生图模型后,需要重启 DSH。"),
|
|
1435
|
+
h("li", null, "豆包生成的图片会先下载为字节数据,再通过微信发送。不能直接转发本机上的图片路径,微信不接受外链。"),
|
|
1436
|
+
h("li", null, "不需要主动生图时,关闭「允许她自己发图」即可,其他配置会保留。"),
|
|
1437
|
+
),
|
|
1438
|
+
h("div", { style: { marginBottom: "8px" } }, "如果出现「没有找到生图路由」或「生图模型没有开始回应」等提示,先检查 dsh-connect-doubao 是否安装,以及豆包是否已经完成登录。"),
|
|
1439
|
+
h("div", { style: { fontWeight: 600, fontSize: "13.5px", margin: "18px 0 10px" } }, "4.2 表情包"),
|
|
1440
|
+
h("div", { style: { marginBottom: "8px" } }, "表情包功能默认开启。"),
|
|
1441
|
+
h("div", { style: { marginBottom: "8px" } }, "如果不希望她直接使用未经筛选的新图片,可以开启「需要审核」。新图片会先进入待审核池,通过审核后才会被使用。"),
|
|
1442
|
+
h("div", { style: { marginBottom: "8px" } }, "「视觉分类」用于对图片进行分类。如果希望减少模型调用,可以关闭该选项。"),
|
|
1443
|
+
h("div", { style: { fontWeight: 600, fontSize: "13.5px", margin: "18px 0 10px" } }, "4.4 联网与天气"),
|
|
1444
|
+
h("div", { style: { marginBottom: "8px" } }, "需要查询最新资讯或天气时,再配置对应的 API Key。"),
|
|
1445
|
+
h("div", { style: { marginBottom: "8px" } }, "没有配置 Key 也不影响基本聊天,只是无法使用依赖这些服务的功能。"),
|
|
1446
|
+
h("div", { id: "guide-reply", style: { fontWeight: 600, fontSize: "15px", margin: "24px 0 10px" } }, "5. 回复方式与人格设置"),
|
|
1447
|
+
h("div", { style: { fontWeight: 600, fontSize: "13.5px", margin: "18px 0 10px" } }, "5.1 群聊回复"),
|
|
1448
|
+
h("div", { style: { marginBottom: "8px" } }, "插件默认会回复私聊消息,群聊消息则只归档、不主动回复。"),
|
|
1449
|
+
h("div", { style: { marginBottom: "8px" } }, "如果希望她参与群聊,需要调整群聊回复模式。"),
|
|
1450
|
+
h("div", { style: { marginBottom: "8px" } }, "选择「智能判断」后,还需要填写「她的名字」和「感兴趣的话题」。"),
|
|
1451
|
+
h("div", { style: { marginBottom: "8px" } }, "智能判断的处理方式如下:"),
|
|
1452
|
+
h("ul", { style: { margin: "0 0 10px", paddingLeft: "22px" } },
|
|
1453
|
+
h("li", null, "在群聊中被直接叫到时,会触发回复。"),
|
|
1454
|
+
h("li", null, "没有被叫到时,会根据消息内容进行评分。"),
|
|
1455
|
+
h("li", null, "评分达到设定的阈值后,才会主动参与讨论。"),
|
|
1456
|
+
),
|
|
1457
|
+
h("div", { style: { marginBottom: "8px" } }, "如果觉得她在群里太活跃,可以适当调高回复阈值。"),
|
|
1458
|
+
h("div", { style: { fontWeight: 600, fontSize: "13.5px", margin: "18px 0 10px" } }, "5.2 人格设定"),
|
|
1459
|
+
h("div", { style: { marginBottom: "8px" } }, "如果觉得她的语气、性格或聊天习惯不符合预期,可以在人格配置中进行调整。"),
|
|
1460
|
+
h("div", { style: { marginBottom: "8px" } }, "人格主要影响说话方式和交流风格,不会替代系统提示词。留空时使用插件默认人设。"),
|
|
1461
|
+
h("div", { style: { marginBottom: "8px" } }, "另外,人格设定不会改变插件本身的功能。例如,修改人格不会移除生图、天气查询或 Steam 状态获取能力,这些能力由插件代码实现。"),
|
|
1462
|
+
h("div", { id: "guide-panel", style: { fontWeight: 600, fontSize: "15px", margin: "24px 0 10px" } }, "6. 面板配置说明"),
|
|
1463
|
+
h("div", { style: { marginBottom: "8px" } }, "以下按照面板从上到下的顺序介绍各个模块。已经在前面详细介绍过的功能,这里只说明配置用途,避免重复操作步骤。"),
|
|
1464
|
+
h("div", { style: { marginBottom: "8px" } }, "模型:默认选择「跟随宿主默认」。需要单独指定模型时,再选择对应的服务商和模型。更换服务商后记得重新选择模型。"),
|
|
1465
|
+
h("div", { style: { marginBottom: "8px" } }, "自动回复:控制私聊和群聊的自动回复开关,以及群聊判断所需的名字、感兴趣的话题等配置。"),
|
|
1466
|
+
h("div", { style: { marginBottom: "8px", padding: "10px 12px", background: "rgba(127,127,127,0.08)", borderRadius: "8px" } },
|
|
1467
|
+
h("div", { style: { fontWeight: 600, marginBottom: "6px" } }, "共享会话模式(两种模式的区别)"),
|
|
1468
|
+
h("div", { style: { marginBottom: "4px" } }, "无论开关如何,她都会注入最近对话、长期记忆、情感状态和念头。也就是说「她记得你」这件事不依赖这个开关。"),
|
|
1469
|
+
h("div", { style: { marginBottom: "4px" } }, "关闭(默认):每轮生成时只用注入的上下文,不保留内部推理过程。token 消耗低(约 4,700/轮),适合日常轻聊。"),
|
|
1470
|
+
h("div", { style: { marginBottom: "4px" } }, "开启:同一个对话始终使用同一个 AI 会话,她保留完整的推理链和工具调用历史。主动消息也知道你们聊过什么(比如「上次那个面试怎么样了?」)。token 消耗较高(约 35,000/轮),适合深度陪伴。"),
|
|
1471
|
+
h("div", null, "两种模式可以随时切换,不需要重启。切换后旧会话会自动清理并重建。"),
|
|
1472
|
+
),
|
|
1473
|
+
h("div", { style: { marginBottom: "8px" } }, "链接解析:控制是否提取消息中链接的标题、封面,以及最多附带多少张图片。"),
|
|
1474
|
+
h("div", { style: { marginBottom: "8px" } }, "虚拟人生:设置她自己的作息、穿搭、三餐等日常信息,天气 Key 也在这里填写。"),
|
|
1475
|
+
h("div", { style: { marginBottom: "8px" } }, "情感与关系:管理好感度、亲密度和八维情绪等状态。"),
|
|
1476
|
+
h("div", { style: { marginBottom: "8px" } }, "长期记忆:保存和整理重要聊天内容。关闭「用模型提炼」可以减少模型调用,但可能影响记忆准确性。"),
|
|
1477
|
+
h("div", { style: { marginBottom: "8px" } }, "表情包:管理表情包的使用、审核和视觉分类。"),
|
|
1478
|
+
h("div", { style: { marginBottom: "8px" } }, "回复节奏:调整批量窗口、分段间隔和每分钟回复上限。"),
|
|
1479
|
+
h("div", { style: { marginBottom: "8px" } }, "Steam:接入 Steam 游戏状态,并管理联系人与 SteamID64 的绑定关系。"),
|
|
1480
|
+
h("div", { style: { marginBottom: "8px" } }, "生图:管理生图开关、服务商、模型、生成数量和超时时间。"),
|
|
1481
|
+
h("div", { style: { marginBottom: "8px" } }, "回复范围:设置哪些私聊和群聊可以触发回复。可以使用白名单,也可以屏蔽指定群聊。"),
|
|
1482
|
+
h("div", { style: { marginBottom: "8px" } }, "归档:管理聊天记录的保留时间,默认保留 30 天。需要长期保存时,可以开启「永久保存」。"),
|
|
1483
|
+
h("div", { style: { marginBottom: "8px" } }, "会话与上下文:控制历史消息数量和会话保留时间。增加历史消息数量有助于保持对话连贯性,但会增加 Token 消耗和请求耗时。"),
|
|
1484
|
+
h("div", { style: { marginBottom: "8px" } }, "虚拟生活与主动消息:管理她的日常作息和主动联系行为。消息过于频繁时,可以调低每日上限或调大最小间隔。"),
|
|
1485
|
+
h("div", { style: { marginBottom: "8px" } }, "长期记忆与情感:管理记忆整理、关系状态和情绪变化。"),
|
|
1486
|
+
h("div", { style: { marginBottom: "8px" } }, "其他配置"),
|
|
1487
|
+
h("div", { style: { marginBottom: "8px" } }, "管理员:填写自己的微信号,用于通过私聊远程管理插件。"),
|
|
1488
|
+
h("div", { id: "guide-restore", style: { fontWeight: 600, fontSize: "15px", margin: "24px 0 10px" } }, "7. 配置恢复"),
|
|
1489
|
+
h("div", { style: { fontWeight: 600, fontSize: "13.5px", margin: "18px 0 10px" } }, "7.1 重置配置"),
|
|
1490
|
+
h("div", { style: { marginBottom: "8px" } }, "如果配置文件损坏,或者需要重新进行首次配置,可以通过重命名配置文件来重置。"),
|
|
1491
|
+
h("div", { style: { marginBottom: "8px" } }, "⚠️ 不要直接删除 config.json。"),
|
|
1492
|
+
h("div", { style: { marginBottom: "8px" } }, "操作步骤:"),
|
|
1493
|
+
h("ol", { style: { margin: "0 0 10px", paddingLeft: "22px" } },
|
|
1494
|
+
h("li", null, "找到 config.json。"),
|
|
1495
|
+
h("li", null, "将它重命名为 config.json.bak。"),
|
|
1496
|
+
h("li", null, "重新启动 DSH。"),
|
|
1497
|
+
),
|
|
1498
|
+
h("div", { style: { marginBottom: "8px" } }, "如果插件支持在配置文件缺失时自动创建默认配置,就会重新进入首次配置流程。"),
|
|
1499
|
+
h("div", { style: { fontWeight: 600, fontSize: "13.5px", margin: "18px 0 10px" } }, "7.2 只修改了部分配置,其他设置会丢失吗?"),
|
|
1500
|
+
h("div", { style: { marginBottom: "8px" } }, "正常情况下不会。"),
|
|
1501
|
+
h("div", { style: { marginBottom: "8px" } }, "面板每次保存只会提交实际修改过的配置项,不会主动覆盖其他未修改的设置。因此,遇到单项功能异常时,优先检查对应配置,不必直接重置整个配置文件。"),
|
|
1502
|
+
h("div", { style: { marginBottom: "8px" } }, "如果通过 Agent 或文本编辑器直接修改 config.json,建议先备份文件,并确认只修改了目标字段。"),
|
|
1503
|
+
h("div", { id: "guide-tips", style: { fontWeight: 600, fontSize: "15px", margin: "24px 0 10px" } }, "8. 使用建议"),
|
|
1504
|
+
h("ul", { style: { margin: "0 0 10px", paddingLeft: "22px" } },
|
|
1505
|
+
h("li", null, "修改配置后,先确认保存成功,再刷新页面或重启 DSH。"),
|
|
1506
|
+
h("li", null, "模型、生图服务商和微信接入配置变更后,记得重载插件。"),
|
|
1507
|
+
h("li", null, "使用扩展功能前,确认所需的前置插件和 API Key 已经配置好。"),
|
|
1508
|
+
h("li", null, "不熟悉的配置项建议先保留默认值,确认功能正常后再逐步调整。"),
|
|
1509
|
+
h("li", null, "定期备份 config.json,不要随意删除或覆盖。"),
|
|
1510
|
+
h("li", null, "不要公开 API Key、agent-wechat Token 等敏感信息。"),
|
|
1511
|
+
),
|
|
1512
|
+
h("div", { style: { marginBottom: "8px" } }, "以上就是插件的主要配置方法。大部分功能都可以直接通过面板完成,不需要手动修改配置文件。"),
|
|
1513
|
+
),
|
|
1514
|
+
)
|
|
1515
|
+
: null,
|
|
1516
|
+
|
|
1517
|
+
h(Card, { title: "模型" },
|
|
1518
|
+
h("div", { className: "row" },
|
|
1519
|
+
h("div", null,
|
|
1520
|
+
h("div", { className: "lbl" }, "跟随宿主默认"),
|
|
1521
|
+
h("div", { className: "hint" }, "开启时使用 DSH 全局默认模型(当前:" + defaultLabel + ");关闭后可任选下面列出的任意模型")),
|
|
1522
|
+
h(Switch, {
|
|
1523
|
+
checked: form.modelFollowDefault,
|
|
1524
|
+
onChange: (v) => {
|
|
1525
|
+
// 关掉「跟随默认」时,下拉框必须立刻有合法值。否则 form 里还是空的,
|
|
1526
|
+
// 用户看到的是列表第一项,保存下去却是 null(又变回跟随默认)。
|
|
1527
|
+
setDirty(true);
|
|
1528
|
+
setForm((prev) => {
|
|
1529
|
+
if (v) return { ...prev, modelFollowDefault: true };
|
|
1530
|
+
const provider = providerNames.includes(prev.modelProvider) ? prev.modelProvider : (providerGroups[0]?.id ?? "");
|
|
1531
|
+
const models = providerGroups.find((g) => g.id === provider)?.models ?? [];
|
|
1532
|
+
const model = models.some((m) => m.id === prev.modelId) ? prev.modelId : (models[0]?.id ?? "");
|
|
1533
|
+
return { ...prev, modelFollowDefault: false, modelProvider: provider, modelId: model, modelReasoningEffort: "" };
|
|
1534
|
+
});
|
|
1535
|
+
},
|
|
1536
|
+
}),
|
|
1537
|
+
),
|
|
1538
|
+
form.modelFollowDefault ? null : h("div", { className: "row" },
|
|
1539
|
+
h("div", null,
|
|
1540
|
+
h("div", { className: "lbl" }, "服务商"),
|
|
1541
|
+
h("div", { className: "hint" }, "共 " + providerGroups.length + " 个可用服务商,合计 " + totalModels + " 个模型")),
|
|
1542
|
+
h("select", {
|
|
1543
|
+
value: activeProvider,
|
|
1544
|
+
onChange: (e) => {
|
|
1545
|
+
// 换服务商时必须把模型重置为新服务商的第一个。
|
|
1546
|
+
// 否则旧服务商的模型 ID 会留在 form 里 —— 那正是「面板看着正常、
|
|
1547
|
+
// 存下去是坏组合」的来源。
|
|
1548
|
+
const next = e.target.value;
|
|
1549
|
+
const models = providerGroups.find((g) => g.id === next)?.models ?? [];
|
|
1550
|
+
setDirty(true);
|
|
1551
|
+
setForm((prev) => ({ ...prev, modelProvider: next, modelId: models[0]?.id ?? "", modelReasoningEffort: "" }));
|
|
1552
|
+
},
|
|
1553
|
+
},
|
|
1554
|
+
// 存着的服务商在宿主目录里已经没有了:把它作为一项显示出来,
|
|
1555
|
+
// 别让下拉框默默跳到第一个服务商 —— 那看起来像「已选中」。
|
|
1556
|
+
storedProviderMissing
|
|
1557
|
+
? h("option", { key: "__missing_provider__", value: form.modelProvider }, form.modelProvider + "(宿主已无此服务商)")
|
|
1558
|
+
: null,
|
|
1559
|
+
providerGroups.map((g) => h("option", { key: g.id, value: g.id }, g.name + "(" + g.models.length + ")")),
|
|
1560
|
+
),
|
|
1561
|
+
),
|
|
1562
|
+
form.modelFollowDefault ? null : h("div", { className: "row" },
|
|
1563
|
+
h("div", null,
|
|
1564
|
+
h("div", { className: "lbl" }, "模型"),
|
|
1565
|
+
h("div", { className: "hint" }, "列表来自宿主实时目录,服务商增删模型无需更新插件")),
|
|
1566
|
+
h("select", {
|
|
1567
|
+
value: activeModel,
|
|
1568
|
+
onChange: (e) => {
|
|
1569
|
+
// 换模型就换了一套档位,旧等级留着等于往不支持它的模型上写。
|
|
1570
|
+
const next = e.target.value;
|
|
1571
|
+
setDirty(true);
|
|
1572
|
+
setForm((prev) => ({ ...prev, modelId: next, modelReasoningEffort: "" }));
|
|
1573
|
+
},
|
|
1574
|
+
},
|
|
1575
|
+
// 同理:模型 ID 不属于当前服务商时也显示出来,而不是替换成第一个。
|
|
1576
|
+
storedModelMissing
|
|
1577
|
+
? h("option", { key: "__missing_model__", value: form.modelId }, form.modelId + "(该服务商下没有这个模型)")
|
|
1578
|
+
: null,
|
|
1579
|
+
modelsForProvider.map((m) => h("option", { key: m.id, value: m.id }, m.name === m.id ? m.id : m.name + "(" + m.id + ")")),
|
|
1580
|
+
),
|
|
1581
|
+
),
|
|
1582
|
+
form.modelFollowDefault ? null : h("div", { className: "row" },
|
|
1583
|
+
h("div", null,
|
|
1584
|
+
h("div", { className: "lbl" }, "推理等级"),
|
|
1585
|
+
h("div", { className: "hint" },
|
|
1586
|
+
reasoning.error
|
|
1587
|
+
? "读取宿主模型详情失败:" + reasoning.error
|
|
1588
|
+
: reasoningEfforts.length
|
|
1589
|
+
? "越高越慢、越费 token;这里只列这个模型真正支持的档位"
|
|
1590
|
+
: reasoning.provider === activeProvider && reasoning.model === activeModel
|
|
1591
|
+
? "这个模型没有可调档位,会用服务商自己的默认"
|
|
1592
|
+
: "正在读取宿主支持的档位…")),
|
|
1593
|
+
h("select", {
|
|
1594
|
+
value: activeReasoning,
|
|
1595
|
+
onChange: (e) => patch("modelReasoningEffort")(e.target.value),
|
|
1596
|
+
},
|
|
1597
|
+
// 存着的档位在这个模型上不存在时也要显示出来,
|
|
1598
|
+
// 否则下拉框会默默跳到「服务商默认」,看起来像没设过。
|
|
1599
|
+
reasoningMissing
|
|
1600
|
+
? h("option", { key: "__missing_effort__", value: activeReasoning }, activeReasoning + "(该模型没有这一档)")
|
|
1601
|
+
: null,
|
|
1602
|
+
h("option", { value: "" }, reasoning.defaultEffort ? "服务商默认(" + reasoning.defaultEffort + ")" : "服务商默认"),
|
|
1603
|
+
reasoningEfforts.map((r) => h("option", { key: r.id, value: r.id }, r.name === r.id ? r.id : r.name + "(" + r.id + ")")),
|
|
1604
|
+
),
|
|
1605
|
+
),
|
|
1606
|
+
(catalog.failures ?? []).length
|
|
1607
|
+
? h("div", { className: "hint" }, "部分服务商读取失败:" + catalog.failures.map((f) => f.name + "(" + f.message + ")").join(";"))
|
|
1608
|
+
: null,
|
|
1609
|
+
providerGroups.length === 0
|
|
1610
|
+
? h("div", { className: "hint" }, "宿主未返回任何可用模型;此时只能跟随默认。")
|
|
1611
|
+
: null,
|
|
1612
|
+
// 已存的模型在宿主目录里找不到:明确提示,并说明保存会退回默认。
|
|
1613
|
+
// 不说的话,用户看到的是「列表里明明有个合法选项」,根本不知道配置是坏的。
|
|
1614
|
+
storedModelInvalid
|
|
1615
|
+
? h("div", { className: "hint", style: { color: "#c33" } },
|
|
1616
|
+
"已保存的模型 " + form.modelProvider + " / " + form.modelId + " 在宿主当前目录里不存在(这个服务商下没有该模型)。",
|
|
1617
|
+
h("br"),
|
|
1618
|
+
"带着它保存会让主动消息和回复静默失败。重新选一个再保存;直接保存会退回「跟随默认」。",
|
|
1619
|
+
)
|
|
1620
|
+
: null,
|
|
1621
|
+
h("div", { className: "hint" }, "切换模型后保存即生效:插件会丢弃已缓存的会话,下一条消息用新模型重开。"),
|
|
1622
|
+
),
|
|
1623
|
+
|
|
1624
|
+
h(Card, { title: "自动回复" },
|
|
1625
|
+
h("div", { className: "row" },
|
|
1626
|
+
h("div", null,
|
|
1627
|
+
h("div", { className: "lbl" }, "避免重复说过的话"),
|
|
1628
|
+
h("div", { className: "hint" }, "她连续几轮说同一句(开场白、口头禅、同一个梗)时,先带着「你刚才已经说过」重问一次;重问后仍重复就照发,不会把回复吞掉")),
|
|
1629
|
+
h(Switch, { checked: form.avoidRepeat, onChange: (v) => patch("avoidRepeat")(v) }),
|
|
1630
|
+
),
|
|
1631
|
+
form.avoidRepeat
|
|
1632
|
+
? h("div", { className: "row" },
|
|
1633
|
+
h("div", null,
|
|
1634
|
+
h("div", { className: "lbl" }, "复读相似度阈值"),
|
|
1635
|
+
h("div", { className: "hint" }, "越高越严格。0.7 能抓住「加语气词、换标点、多一句尾巴」这类改写;0.9 只拦几乎逐字相同的。范围 0.5–1")),
|
|
1636
|
+
h("input", { type: "number", min: 0.5, max: 1, step: 0.05, value: form.repeatThreshold, onChange: (e) => patch("repeatThreshold")(e.target.value) }),
|
|
1637
|
+
)
|
|
1638
|
+
: null,
|
|
1639
|
+
h("div", { className: "row" },
|
|
1640
|
+
h("div", null,
|
|
1641
|
+
h("div", { className: "lbl" }, "共享会话模式"),
|
|
1642
|
+
h("div", { className: "hint" }, "无论开关如何,她都会注入最近对话、长期记忆、情感状态和念头。开启后额外记住完整推理过程和工具调用历史,主动消息也知道你们聊过什么;关闭则每次全新推理(省 token)。会话回收后下次自动恢复。"),
|
|
1643
|
+
),
|
|
1644
|
+
h(Switch, { checked: form.sharedAgent, onChange: (v) => patch("sharedAgent")(v) }),
|
|
1645
|
+
),
|
|
1646
|
+
h("div", { className: "row" },
|
|
1647
|
+
h("div", null, h("div", { className: "lbl" }, "私聊自动回复"), h("div", { className: "hint" }, "关闭后仍会归档消息,只是不再自动生成回复")),
|
|
1648
|
+
h(Switch, { checked: form.replyPrivate, onChange: patch("replyPrivate") }),
|
|
1649
|
+
),
|
|
1650
|
+
h("div", { className: "row" },
|
|
1651
|
+
h("div", null, h("div", { className: "lbl" }, "群聊回复"), h("div", { className: "hint" }, "默认关闭:群消息只归档不回。打开后「智能」= 被 @ / 被引用 / 被叫名字,或内容她感兴趣时才回")),
|
|
1652
|
+
h("select", { value: form.replyGroup, onChange: (e) => patch("replyGroup")(e.target.value) },
|
|
1653
|
+
h("option", { value: "off" }, "不回复(只归档)"),
|
|
1654
|
+
h("option", { value: "mention" }, "仅被 @ 时回复"),
|
|
1655
|
+
h("option", { value: "smart" }, "智能判断"),
|
|
1656
|
+
h("option", { value: "all" }, "每条都回复"),
|
|
1657
|
+
),
|
|
1658
|
+
),
|
|
1659
|
+
form.replyGroup === "smart"
|
|
1660
|
+
? h("div", null,
|
|
1661
|
+
h("div", { className: "row" },
|
|
1662
|
+
h("div", null, h("div", { className: "lbl" }, "回复阈值"), h("div", { className: "hint" }, "分数达到才回;调高更安静,调低更爱说话(1–10)")),
|
|
1663
|
+
h("input", { type: "number", min: 1, max: 10, value: form.smartThreshold, onChange: (e) => patch("smartThreshold")(e.target.value) }),
|
|
1664
|
+
),
|
|
1665
|
+
h("div", { className: "row" },
|
|
1666
|
+
h("div", null, h("div", { className: "lbl" }, "她的名字"), h("div", { className: "hint" }, "被叫到这些名字就回,逗号分隔;微信号总是算在内")),
|
|
1667
|
+
h("input", { type: "text", placeholder: "小鱼, 小助手", value: form.selfNames, onChange: (e) => patch("selfNames")(e.target.value) }),
|
|
1668
|
+
),
|
|
1669
|
+
h("div", { className: "hint" }, "感兴趣的话题词(逗号或换行分隔;留空用内置默认表)"),
|
|
1670
|
+
h("textarea", {
|
|
1671
|
+
value: form.interests,
|
|
1672
|
+
onChange: (e) => patch("interests")(e.target.value),
|
|
1673
|
+
placeholder: "游戏, 动漫, 电影, 编程, 考试, 吃饭, 猫, 天气",
|
|
1674
|
+
}),
|
|
1675
|
+
h("div", { className: "row" },
|
|
1676
|
+
h("div", null, h("div", { className: "lbl" }, "从对话里学习兴趣"), h("div", { className: "hint" }, "她回过的群消息里出现的话题会加权,随时间衰减")),
|
|
1677
|
+
h(Switch, { checked: form.learnInterests, onChange: (v) => patch("learnInterests")(v) }),
|
|
1678
|
+
),
|
|
1679
|
+
state && state.groupGate
|
|
1680
|
+
? h("div", { className: "hint" },
|
|
1681
|
+
"已判定 " + state.groupGate.counts.considered + " 条 · 回复 " + state.groupGate.counts.replied +
|
|
1682
|
+
" · 跳过 " + state.groupGate.counts.skipped +
|
|
1683
|
+
" · 学到 " + state.groupGate.learnedTopics + " 个话题" +
|
|
1684
|
+
(state.groupGate.last
|
|
1685
|
+
? "|最近一条:" + (state.groupGate.last.reply ? "回复" : "跳过") +
|
|
1686
|
+
"(score=" + state.groupGate.last.score + "," + state.groupGate.last.detail + ")"
|
|
1687
|
+
: ""))
|
|
1688
|
+
: null,
|
|
1689
|
+
)
|
|
1690
|
+
: null,
|
|
1691
|
+
),
|
|
1692
|
+
|
|
1693
|
+
h(Card, { title: "链接解析" },
|
|
1694
|
+
h("div", { className: "row" },
|
|
1695
|
+
h("div", null,
|
|
1696
|
+
h("div", { className: "lbl" }, "解析聊天里的链接"),
|
|
1697
|
+
h("div", { className: "hint" }, "识别 B站 / 小黑盒 / X / 小红书 / YouTube / Instagram,把标题、封面和图集发出来;视频只发链接,不下载文件")),
|
|
1698
|
+
h(Switch, { checked: form.linkParse, onChange: (v) => patch("linkParse")(v) }),
|
|
1699
|
+
),
|
|
1700
|
+
form.linkParse ? h("div", { className: "row" },
|
|
1701
|
+
h("div", null,
|
|
1702
|
+
h("div", { className: "lbl" }, "最多图片数"),
|
|
1703
|
+
h("div", { className: "hint" }, "图集最多发几张,0 = 只发文字和链接")),
|
|
1704
|
+
h("input", {
|
|
1705
|
+
type: "number", min: 0, max: 20, value: form.linkMaxImages,
|
|
1706
|
+
onChange: (e) => patch("linkMaxImages")(e.target.value),
|
|
1707
|
+
}),
|
|
1708
|
+
) : null,
|
|
1709
|
+
h("div", { className: "hint" }, "解析结果会同时作为上下文交给模型,她知道链接里是什么。读取失败时只发原链接。"),
|
|
1710
|
+
),
|
|
1711
|
+
|
|
1712
|
+
h(Card, { title: "虚拟人生" },
|
|
1713
|
+
h("div", { className: "row" },
|
|
1714
|
+
h("div", null,
|
|
1715
|
+
h("div", { className: "lbl" }, "启用虚拟人生"),
|
|
1716
|
+
h("div", { className: "hint" }, "给她一份连续的日程、穿搭和三餐;生成一次按周循环,不每天调用模型")),
|
|
1717
|
+
h(Switch, { checked: form.lifeEnabled, onChange: (v) => patch("lifeEnabled")(v) }),
|
|
1718
|
+
),
|
|
1719
|
+
!form.lifeEnabled ? null : h("div", { className: "row" },
|
|
1720
|
+
h("div", null,
|
|
1721
|
+
h("div", { className: "lbl" }, "把当前状态注入对话"),
|
|
1722
|
+
h("div", { className: "hint" }, "聊天时她知道「现在在干嘛、穿什么、吃什么」,不额外调用模型")),
|
|
1723
|
+
h(Switch, { checked: form.lifeInject, onChange: (v) => patch("lifeInject")(v) }),
|
|
1724
|
+
),
|
|
1725
|
+
!form.lifeEnabled ? null : h("div", { className: "row" },
|
|
1726
|
+
h("div", null,
|
|
1727
|
+
h("div", { className: "lbl" }, "每周自动更新"),
|
|
1728
|
+
h("div", { className: "hint" }, "每周一自动生成新一周,并参考上周避免重复主题、活动、餐食和穿搭;关闭后只能手动生成")),
|
|
1729
|
+
h(Switch, { checked: form.lifeAutoRefresh, onChange: (v) => patch("lifeAutoRefresh")(v) }),
|
|
1730
|
+
),
|
|
1731
|
+
!form.lifeEnabled ? null : h("div", { className: "hint" },
|
|
1732
|
+
life && life.snapshot && life.snapshot.ready
|
|
1733
|
+
? "已生成:" + life.snapshot.counts.days + " 天日程 · " + life.snapshot.counts.outfits + " 套穿搭 · " + life.snapshot.counts.meals + " 条餐食" +
|
|
1734
|
+
(life.snapshot.weekStart ? " · 本周从 " + life.snapshot.weekStart : "") +
|
|
1735
|
+
(life.snapshot.needsRefresh ? (form.lifeAutoRefresh ? " · 待自动更新" : " · 待更新(自动更新已关闭)") : "")
|
|
1736
|
+
: "还没有生成日程"),
|
|
1737
|
+
!form.lifeEnabled ? null : h("div", { className: "row" },
|
|
1738
|
+
h("button", { className: "ghost", onClick: () => lifeAction("generate", { force: true }), disabled: busy }, busy ? "生成中…" : "生成 / 重新生成"),
|
|
1739
|
+
h("button", { className: "ghost", onClick: loadLife, disabled: busy }, "刷新"),
|
|
1740
|
+
h("button", { className: "ghost", onClick: () => lifeAction("clear"), disabled: busy }, "清空"),
|
|
1741
|
+
),
|
|
1742
|
+
// 本周安排:默认整块折叠,标题下面什么都不显示。
|
|
1743
|
+
// 主题摘要是 7 个短语连成一行,也很长,所以一起收进去。
|
|
1744
|
+
!form.lifeEnabled || !life || !life.snapshot || !life.snapshot.ready ? null : h("div", null,
|
|
1745
|
+
h("div", { className: "row" },
|
|
1746
|
+
h("div", { className: "lbl" }, "本周安排"),
|
|
1747
|
+
h("button", { className: "ghost", onClick: () => setWeekOpen((v) => !v) }, weekOpen ? "收起" : "展开"),
|
|
1748
|
+
),
|
|
1749
|
+
!weekOpen ? null : h("div", { style: { marginTop: "8px" } },
|
|
1750
|
+
h("div", { className: "hint", style: { marginBottom: "10px" } },
|
|
1751
|
+
Object.values(life.snapshot.week ?? {}).map((d) => d.theme).join(" · ")),
|
|
1752
|
+
["0","1","2","3","4","5","6"].map((idx) => {
|
|
1753
|
+
const day = life.snapshot.week?.[idx];
|
|
1754
|
+
if (!day) return null;
|
|
1755
|
+
const name = ["周一","周二","周三","周四","周五","周六","周日"][Number(idx)];
|
|
1756
|
+
return h("div", { key: idx, style: { marginBottom: "12px" } },
|
|
1757
|
+
h("div", { className: "lbl" }, name + " · " + (day.theme || "") + " · " + (day.mood || "")),
|
|
1758
|
+
h("div", { className: "hint" }, (day.timeline ?? []).map((item) => {
|
|
1759
|
+
const start = String(Math.floor(item.start / 60)).padStart(2, "0") + ":" + String(item.start % 60).padStart(2, "0");
|
|
1760
|
+
const endRaw = item.end >= 1440 ? "24:00" : String(Math.floor(item.end / 60)).padStart(2, "0") + ":" + String(item.end % 60).padStart(2, "0");
|
|
1761
|
+
return start + "-" + endRaw + " " + item.activity + (item.location ? "(" + item.location + ")" : "");
|
|
1762
|
+
}).join(" ")),
|
|
1763
|
+
(day.proactiveWindows ?? []).length
|
|
1764
|
+
? h("div", { className: "hint" }, "想说话:" + day.proactiveWindows.map((w) => w.at + " " + (w.intent || "")).join(";"))
|
|
1765
|
+
: null,
|
|
1766
|
+
);
|
|
1767
|
+
}),
|
|
1768
|
+
),
|
|
1769
|
+
),
|
|
1770
|
+
!form.lifeEnabled ? null : h("div", { className: "row" },
|
|
1771
|
+
h("div", null,
|
|
1772
|
+
h("div", { className: "lbl" }, "按真实天气生成"),
|
|
1773
|
+
h("div", { className: "hint" }, "接和风天气,把未来一周的实际温度和阴晴写进生成提示词。不开就只能按月份猜,容易出现大晴天穿羽绒服")),
|
|
1774
|
+
h(Switch, { checked: form.wxEnabled, onChange: (v) => patch("wxEnabled")(v) }),
|
|
1775
|
+
),
|
|
1776
|
+
!form.lifeEnabled || !form.wxEnabled ? null : h("div", { className: "row" },
|
|
1777
|
+
h("div", null, h("div", { className: "lbl" }, "API Host"), h("div", { className: "hint" }, "控制台-设置里那个 xxx.qweatherapi.com,公共域名正在停用")),
|
|
1778
|
+
h("input", { type: "text", placeholder: "abcxyz.qweatherapi.com", value: form.wxHost, onChange: (e) => patch("wxHost")(e.target.value) }),
|
|
1779
|
+
),
|
|
1780
|
+
!form.lifeEnabled || !form.wxEnabled ? null : h("div", { className: "row" },
|
|
1781
|
+
h("div", null,
|
|
1782
|
+
h("div", { className: "lbl" }, "API Key"),
|
|
1783
|
+
h("div", { className: "hint" }, form.wxHasKey ? "已保存。留空保存表示不改;要换就填新的" : "控制台-项目管理里创建,用 X-QW-Api-Key 认证,不用 JWT")),
|
|
1784
|
+
h("input", { type: "password", placeholder: form.wxHasKey ? "已保存(留空不改)" : "粘贴你的 API Key", value: form.wxKey, onChange: (e) => patch("wxKey")(e.target.value) }),
|
|
1785
|
+
),
|
|
1786
|
+
!form.lifeEnabled || !form.wxEnabled ? null : h("div", { className: "row" },
|
|
1787
|
+
h("div", null, h("div", { className: "lbl" }, "城市"), h("div", { className: "hint" }, "只用于提示词里点名,实际查询用下面的经纬度")),
|
|
1788
|
+
h("input", { type: "text", value: form.wxCity, onChange: (e) => patch("wxCity")(e.target.value) }),
|
|
1789
|
+
),
|
|
1790
|
+
|
|
1791
|
+
|
|
1792
|
+
!form.lifeEnabled || !form.wxEnabled || !cityWarning ? null : h("div", { className: "hint", style: { color: "#c80" } },
|
|
1793
|
+
"城市写的是「" + String(form.wxCity ?? "").trim() + "」,但经纬度离它大约 " + cityWarning.km + " 公里。实际查天气用的是经纬度,确认一下哪边才是对的。"),
|
|
1794
|
+
!form.lifeEnabled || !form.wxEnabled ? null : h("div", { className: "row" },
|
|
1795
|
+
h("div", null, h("div", { className: "lbl" }, "纬度 / 经度"), h("div", { className: "hint" }, "默认是华盛顿白宫,一个公开地标,不代表任何真实住址。和风 v1 接口按坐标查,最多两位小数;换成你自己的位置")),
|
|
1796
|
+
h("div", { style: { display: "flex", gap: "8px" } },
|
|
1797
|
+
h("input", { type: "number", step: "0.01", value: form.wxLat, onChange: (e) => patch("wxLat")(e.target.value) }),
|
|
1798
|
+
h("input", { type: "number", step: "0.01", value: form.wxLon, onChange: (e) => patch("wxLon")(e.target.value) }),
|
|
1799
|
+
),
|
|
1800
|
+
),
|
|
1801
|
+
!form.lifeEnabled ? null : h("div", { className: "row" },
|
|
1802
|
+
h("div", null,
|
|
1803
|
+
h("div", { className: "lbl" }, "主动消息"),
|
|
1804
|
+
h("div", { className: "hint" }, "按日程里的「想说点什么」窗口主动发消息,走现有的轮询,不新增定时器")),
|
|
1805
|
+
h(Switch, { checked: form.lifeProactive, onChange: (v) => patch("lifeProactive")(v) }),
|
|
1806
|
+
),
|
|
1807
|
+
!form.lifeEnabled || !form.lifeProactive ? null : h("div", { className: "row" },
|
|
1808
|
+
h("div", null, h("div", { className: "lbl" }, "允许私聊主动")),
|
|
1809
|
+
h(Switch, { checked: form.lifeProactivePrivate, onChange: (v) => patch("lifeProactivePrivate")(v) }),
|
|
1810
|
+
),
|
|
1811
|
+
!form.lifeEnabled || !form.lifeProactive ? null : h("div", { className: "row" },
|
|
1812
|
+
h("div", null, h("div", { className: "lbl" }, "允许群聊主动"), h("div", { className: "hint" }, "默认关闭:群聊里没人叫你就不该说话")),
|
|
1813
|
+
h(Switch, { checked: form.lifeProactiveGroup, onChange: (v) => patch("lifeProactiveGroup")(v) }),
|
|
1814
|
+
),
|
|
1815
|
+
!form.lifeEnabled || !form.lifeProactive ? null : h("div", { className: "row" },
|
|
1816
|
+
h("div", null, h("div", { className: "lbl" }, "每天最多几次"), h("div", { className: "hint" }, "上限,不是固定值。实际次数每天按正态分布在 0 到这个数之间抽,均值是一半 —— 设 5 就平均 2-3 次。一次算一条完整消息,拆成几段发也只算一次")),
|
|
1817
|
+
h("input", { type: "number", min: 0, max: 24, value: form.lifeMaxPerDay, onChange: (e) => patch("lifeMaxPerDay")(e.target.value) }),
|
|
1818
|
+
),
|
|
1819
|
+
!form.lifeEnabled || !form.lifeProactive ? null : h("div", { className: "row" },
|
|
1820
|
+
h("div", null,
|
|
1821
|
+
h("div", { className: "lbl" }, "次数离散程度"),
|
|
1822
|
+
h("div", { className: "hint" }, "标准差 ÷ 均值。0.1 很集中,几乎每天发差不多那么多次;0.5 是标准钟形,中间多两头少;1.0 很散,接近均匀分布,0 次和上限都常见。范围 0.05–2,默认 0.5")),
|
|
1823
|
+
h("input", { type: "number", min: 0.05, max: 2, step: 0.05, value: form.lifeSpread, onChange: (e) => patch("lifeSpread")(e.target.value) }),
|
|
1824
|
+
),
|
|
1825
|
+
!form.lifeEnabled || !form.lifeProactive ? null : h("div", { className: "row" },
|
|
1826
|
+
h("div", null, h("div", { className: "lbl" }, "最小间隔(分钟)"), h("div", { className: "hint" }, "两次主动消息之间至少隔这么久,用来保证时间点不挤在一起")),
|
|
1827
|
+
h("input", { type: "number", min: 10, max: 720, value: form.lifeMinGap, onChange: (e) => patch("lifeMinGap")(e.target.value) }),
|
|
1828
|
+
),
|
|
1829
|
+
!form.lifeEnabled || !form.lifeProactive ? null : h("div", { className: "row" },
|
|
1830
|
+
h("div", null, h("div", { className: "lbl" }, "时间随机幅度(分钟)"), h("div", { className: "hint" }, "日程里写的「大概这个点」前后浮动多少。0 = 精确按日程;同一天固定,不会因为轮询而越来越早")),
|
|
1831
|
+
h("input", { type: "number", min: 0, max: 240, value: form.lifeJitter, onChange: (e) => patch("lifeJitter")(e.target.value) }),
|
|
1832
|
+
),
|
|
1833
|
+
!form.lifeEnabled || !form.lifeProactive ? null : h("div", { className: "row" },
|
|
1834
|
+
h("div", null, h("div", { className: "lbl" }, "到点后多久内补发(分钟)"), h("div", { className: "hint" }, "随机化之后窗口是一个区间。过了这个宽度还没轮询到,这条就跳过,不补发")),
|
|
1835
|
+
h("input", { type: "number", min: 5, max: 180, value: form.lifeGrace, onChange: (e) => patch("lifeGrace")(e.target.value) }),
|
|
1836
|
+
),
|
|
1837
|
+
// 立即测试:日程窗口基本都在晚上,想验证一次要等半天。
|
|
1838
|
+
// 这个按钮走同一个 tickProactive,只是把窗口当成「现在到期」,
|
|
1839
|
+
// 配额和最小间隔照样生效,所以测出来就是线上的真实行为。
|
|
1840
|
+
!form.lifeEnabled || !form.lifeProactive ? null : h("div", null,
|
|
1841
|
+
h("div", { className: "row" },
|
|
1842
|
+
h("div", null,
|
|
1843
|
+
h("div", { className: "lbl" }, "立即测试"),
|
|
1844
|
+
h("div", { className: "hint" }, "马上发一条,不用等日程窗口。会占用当天的次数和最小间隔")),
|
|
1845
|
+
h("button", { className: "ghost", onClick: testProactive, disabled: busy }, busy ? "发送中…" : "发一条试试"),
|
|
1846
|
+
),
|
|
1847
|
+
!proactiveTest ? null : h("div", { className: "hint", style: { marginTop: "6px" } },
|
|
1848
|
+
proactiveTest.ok
|
|
1849
|
+
? "已发出 " + (proactiveTest.segments?.length ?? 1) + " 条:" + (proactiveTest.segments ?? [proactiveTest.text]).join(" / ")
|
|
1850
|
+
: "没发出去(" + (proactiveTest.reason || proactiveTest.error) + ")" + (proactiveTest.detail ? ":" + proactiveTest.detail : ""),
|
|
1851
|
+
),
|
|
1852
|
+
),
|
|
1853
|
+
// 内容方向:长期约束她主动说话的主题和方式。
|
|
1854
|
+
// 和日程里的 intent 是两层 —— intent 决定今天为什么想说话,
|
|
1855
|
+
// 这里决定她平时怎么说话。留空就完全按日程走。
|
|
1856
|
+
!form.lifeEnabled || !form.lifeProactive ? null : h("div", null,
|
|
1857
|
+
h("div", { className: "lbl" }, "内容方向"),
|
|
1858
|
+
h("div", { className: "hint" }, "她主动说话时长期遵循的偏好,比如「多聊生活小事,别总问我在干嘛」。留空就只按日程里的念头写"),
|
|
1859
|
+
h("textarea", {
|
|
1860
|
+
value: form.lifeHint,
|
|
1861
|
+
maxLength: 500,
|
|
1862
|
+
placeholder: "例:多分享自己遇到的小事,不要每次都用问句结尾",
|
|
1863
|
+
onChange: (e) => patch("lifeHint")(e.target.value),
|
|
1864
|
+
style: { minHeight: "60px" },
|
|
1865
|
+
}),
|
|
1866
|
+
),
|
|
1867
|
+
// 运行状态:今天发了几次、还剩几次、下次窗口几点。
|
|
1868
|
+
// 这几个数字是「她为什么不主动说话」的第一现场,
|
|
1869
|
+
// 之前只能翻 debug.log,现在直接显示在面板上。
|
|
1870
|
+
!form.lifeEnabled || !form.lifeProactive ? null : (() => {
|
|
1871
|
+
const st = state?.proactive;
|
|
1872
|
+
if (!st) return null;
|
|
1873
|
+
if (!st.enabled) return h("div", { className: "hint" }, "主动消息未启用");
|
|
1874
|
+
const last = st.lastSentAt ? new Date(st.lastSentAt).toLocaleString("zh-CN") : "还没发过";
|
|
1875
|
+
const wins = (st.windowsToday ?? []).length ? st.windowsToday.join("、") : "今天没有安排";
|
|
1876
|
+
return h("div", { className: "hint", style: { marginTop: "8px", lineHeight: "20px" } },
|
|
1877
|
+
"今天已发 " + st.sentToday + " / " + st.maxPerDay + " 次,还剩 " + st.remaining + " 次",
|
|
1878
|
+
h("br"),
|
|
1879
|
+
"今天的窗口:" + wins + "(到点后 " + st.graceMinutes + " 分钟内有效)",
|
|
1880
|
+
h("br"),
|
|
1881
|
+
"上次发送:" + last,
|
|
1882
|
+
h("br"),
|
|
1883
|
+
"目标:" + ((st.targets ?? []).length ? st.targets.join("、") : "没有勾选任何会话"),
|
|
1884
|
+
);
|
|
1885
|
+
})(),
|
|
1886
|
+
// 手动重抽今天的安排:改了上限/离散度之后,窗口还是按旧参数算的,
|
|
1887
|
+
// 重抽一下就能立刻看到新结果,不用等到明天。
|
|
1888
|
+
// 只清「已触发」记录,不动真实发送记录,所以配额不会被重置。
|
|
1889
|
+
!form.lifeEnabled || !form.lifeProactive ? null : h("div", { className: "row" },
|
|
1890
|
+
h("div", null,
|
|
1891
|
+
h("div", { className: "lbl" }, "重新抽取今天的安排"),
|
|
1892
|
+
h("div", { className: "hint" }, "按当前的上限、离散度、最小间隔重新算今天的次数和时间点。已发出的次数照常保留")),
|
|
1893
|
+
h("button", {
|
|
1894
|
+
className: "ghost",
|
|
1895
|
+
disabled: busy,
|
|
1896
|
+
onClick: reseedToday,
|
|
1897
|
+
}, busy ? "处理中…" : "重抽"),
|
|
1898
|
+
),
|
|
1899
|
+
!form.lifeEnabled || !form.lifeProactive ? null : h("div", null,
|
|
1900
|
+
h("div", { className: "lbl" }, "主动消息会话"),
|
|
1901
|
+
h("div", { className: "hint" }, "只有勾选的会话才会收到主动消息;不勾就是完全不会打扰。列表来自本地归档。"),
|
|
1902
|
+
!targets.length
|
|
1903
|
+
? h("div", { className: "hint" }, "还没有可选的会话——先和她聊几句,再回来刷新。")
|
|
1904
|
+
: h("div", null, targets.slice(0, 30).map((t, idx) => h("div", { key: t.kind + ":" + t.peerId, className: "row" },
|
|
1905
|
+
h("div", null,
|
|
1906
|
+
h("div", { className: "lbl" }, (t.kind === "group" ? "群 " : "私聊 ") + t.peerId),
|
|
1907
|
+
h("div", { className: "hint" }, t.lastAt ? "最近活跃 " + new Date(t.lastAt).toLocaleString() : "无活跃记录")),
|
|
1908
|
+
h("div", { className: "row" },
|
|
1909
|
+
h(Switch, {
|
|
1910
|
+
checked: t.selected === true,
|
|
1911
|
+
onChange: (v) => setTargets((prev) => prev.map((x, i) => i === idx ? { ...x, selected: v, enabled: v } : x)),
|
|
1912
|
+
}),
|
|
1913
|
+
),
|
|
1914
|
+
))),
|
|
1915
|
+
h("button", { className: "ghost", onClick: loadTargets, disabled: busy }, "刷新会话列表"),
|
|
1916
|
+
h("button", { className: "ghost", onClick: saveTargets, disabled: busy }, "保存勾选"),
|
|
1917
|
+
),
|
|
1918
|
+
),
|
|
1919
|
+
|
|
1920
|
+
h(Card, { title: "情感与关系" },
|
|
1921
|
+
h("div", { className: "row" },
|
|
1922
|
+
h("div", null,
|
|
1923
|
+
h("div", { className: "lbl" }, "启用情感系统"),
|
|
1924
|
+
h("div", { className: "hint" }, "记录每个人对你的好感与亲密度,分四阶段演进;她的语气会随之变化。")),
|
|
1925
|
+
h(Switch, { checked: form.emEnabled, onChange: (v) => patch("emEnabled")(v) }),
|
|
1926
|
+
),
|
|
1927
|
+
form.emEnabled
|
|
1928
|
+
? h("div", null,
|
|
1929
|
+
h("div", { className: "row" },
|
|
1930
|
+
h("div", null, h("div", { className: "lbl" }, "注入到对话里"), h("div", { className: "hint" }, "关闭后仍然记录,但聊天时她不会考虑当前关系")),
|
|
1931
|
+
h(Switch, { checked: form.emInject, onChange: (v) => patch("emInject")(v) }),
|
|
1932
|
+
),
|
|
1933
|
+
h("div", { className: "row" },
|
|
1934
|
+
h("div", null, h("div", { className: "lbl" }, "用模型判断变化"), h("div", { className: "hint" }, "关闭则用关键词启发式,省一次模型调用但更粗糙")),
|
|
1935
|
+
h(Switch, { checked: form.emUseModel, onChange: (v) => patch("emUseModel")(v) }),
|
|
1936
|
+
),
|
|
1937
|
+
form.emUseModel
|
|
1938
|
+
? h("div", { className: "row" },
|
|
1939
|
+
h("div", null, h("div", { className: "lbl" }, "分析模型"), h("div", { className: "hint" }, "留空沿用主模型")),
|
|
1940
|
+
h("div", { style: { display: "flex", gap: "6px" } },
|
|
1941
|
+
h("input", { type: "text", placeholder: "provider", value: form.emProvider, onChange: (e) => patch("emProvider")(e.target.value) }),
|
|
1942
|
+
h("input", { type: "text", placeholder: "model", value: form.emModel, onChange: (e) => patch("emModel")(e.target.value) }),
|
|
1943
|
+
),
|
|
1944
|
+
)
|
|
1945
|
+
: null,
|
|
1946
|
+
h("div", { className: "row" },
|
|
1947
|
+
h("div", null, h("div", { className: "lbl" }, "隐私级别"), h("div", { className: "hint" }, "0=完全不注入 1=只给阶段 2=连数值一起")),
|
|
1948
|
+
h("select", { value: form.emPrivacy, onChange: (e) => patch("emPrivacy")(e.target.value) },
|
|
1949
|
+
h("option", { value: 0 }, "0 · 保密"),
|
|
1950
|
+
h("option", { value: 1 }, "1 · 基础"),
|
|
1951
|
+
h("option", { value: 2 }, "2 · 详细"),
|
|
1952
|
+
),
|
|
1953
|
+
),
|
|
1954
|
+
h("div", { className: "row" },
|
|
1955
|
+
h("div", null, h("div", { className: "lbl" }, "按会话隔离"), h("div", { className: "hint" }, "关闭时同一个人在不同群里共用一份关系")),
|
|
1956
|
+
h(Switch, { checked: form.emPerSession, onChange: (v) => patch("emPerSession")(v) }),
|
|
1957
|
+
),
|
|
1958
|
+
h("div", { className: "row" },
|
|
1959
|
+
h("div", null, h("div", { className: "lbl" }, "重要记忆阈值"), h("div", { className: "hint" }, "单轮变化合计达到这个值才记进长期记忆")),
|
|
1960
|
+
h("input", { type: "number", min: 1, max: 30, value: form.emThreshold, onChange: (e) => patch("emThreshold")(e.target.value) }),
|
|
1961
|
+
),
|
|
1962
|
+
)
|
|
1963
|
+
: null,
|
|
1964
|
+
emotion && emotion.enabled
|
|
1965
|
+
? h("div", null,
|
|
1966
|
+
h("div", { className: "hint" },
|
|
1967
|
+
"共 " + emotion.stats.users + " 份档案 · 累计 " + emotion.stats.totalTurns + " 轮对话" +
|
|
1968
|
+
(emotion.stats.positiveTurns || emotion.stats.negativeTurns
|
|
1969
|
+
? "(正面 " + emotion.stats.positiveTurns + " / 负面 " + emotion.stats.negativeTurns + ")"
|
|
1970
|
+
: "")),
|
|
1971
|
+
emotion.profiles.length
|
|
1972
|
+
? h("div", null, emotion.profiles.slice(0, 8).map((p) =>
|
|
1973
|
+
h("div", { className: "row", key: p.userKey },
|
|
1974
|
+
h("div", null,
|
|
1975
|
+
h("div", { className: "lbl" }, p.userKey + " · " + p.stage),
|
|
1976
|
+
h("div", { className: "hint" }, "好感 " + p.favor + " / 亲密 " + p.intimacy + " · " + p.totalTurns + " 轮 · " + p.attitude)),
|
|
1977
|
+
h("button", {
|
|
1978
|
+
className: "ghost",
|
|
1979
|
+
onClick: () => emotionAction("reset", { peerId: p.userKey }),
|
|
1980
|
+
disabled: busy,
|
|
1981
|
+
style: { height: "24px", padding: "0 8px", fontSize: "11.5px" },
|
|
1982
|
+
}, "重置"),
|
|
1983
|
+
)))
|
|
1984
|
+
: h("div", { className: "hint" }, "还没有档案。聊天几轮后会自动出现。"),
|
|
1985
|
+
)
|
|
1986
|
+
: null,
|
|
1987
|
+
h("div", { className: "row" },
|
|
1988
|
+
h("button", { className: "ghost", onClick: loadEmotion, disabled: busy }, "刷新"),
|
|
1989
|
+
),
|
|
1990
|
+
),
|
|
1991
|
+
|
|
1992
|
+
h(Card, { title: "内分泌" },
|
|
1993
|
+
h("div", { className: "row" },
|
|
1994
|
+
h("div", null,
|
|
1995
|
+
h("div", { className: "lbl" }, "启用内分泌"),
|
|
1996
|
+
h("div", { className: "hint" }, "14 个腺体激素的昼夜节律、28 天周期和可选疾病状态。只影响语气和精力,不参与权限、拒绝或安全判定。")),
|
|
1997
|
+
h(Switch, { checked: form.endoEnabled, onChange: (v) => patch("endoEnabled")(v) }),
|
|
1998
|
+
),
|
|
1999
|
+
!form.endoEnabled ? null : h("div", null,
|
|
2000
|
+
h("div", { className: "row" },
|
|
2001
|
+
h("div", null,
|
|
2002
|
+
h("div", { className: "lbl" }, "注入到对话里"),
|
|
2003
|
+
h("div", { className: "hint" }, "只给主观感受,不给激素数值和临床标签;人格、关系和规则始终优先")),
|
|
2004
|
+
h(Switch, { checked: form.endoInject, onChange: (v) => patch("endoInject")(v) }),
|
|
2005
|
+
),
|
|
2006
|
+
h("div", { className: "row" },
|
|
2007
|
+
h("div", null,
|
|
2008
|
+
h("div", { className: "lbl" }, "注入范围"),
|
|
2009
|
+
h("div", { className: "hint" }, "群聊和非主人私聊永远只给很粗的精力描述,不暴露周期和疾病")),
|
|
2010
|
+
h("select", { value: form.endoScope, onChange: (e) => patch("endoScope")(e.target.value) },
|
|
2011
|
+
h("option", { value: "owner-private" }, "仅主人私聊"),
|
|
2012
|
+
h("option", { value: "private" }, "所有私聊(群聊仍脱敏)"),
|
|
2013
|
+
h("option", { value: "all" }, "私聊 + 群聊(群聊仍脱敏)"),
|
|
2014
|
+
),
|
|
2015
|
+
),
|
|
2016
|
+
h("div", { className: "row" },
|
|
2017
|
+
h("div", null, h("div", { className: "lbl" }, "用聊天事件推动激素"), h("div", { className: "hint" }, "主人私聊里熬夜 / 被吓 / 吃饱时加一个短期脉冲,20 分钟最多一次")),
|
|
2018
|
+
h(Switch, { checked: form.endoAutoEvents, onChange: (v) => patch("endoAutoEvents")(v) }),
|
|
2019
|
+
),
|
|
2020
|
+
h("div", { className: "row" },
|
|
2021
|
+
h("div", null, h("div", { className: "lbl" }, "允许随机疾病加重"), h("div", { className: "hint" }, "默认关闭,避免每轮读状态都随机发病")),
|
|
2022
|
+
h(Switch, { checked: form.endoAutoFlare, onChange: (v) => patch("endoAutoFlare")(v) }),
|
|
2023
|
+
),
|
|
2024
|
+
h("div", { className: "row" },
|
|
2025
|
+
h("div", null, h("div", { className: "lbl" }, "用情感状态驱动心情"), h("div", { className: "hint" }, "只在主人私聊里,从八维情绪取主导项;群友聊天不改身体状态")),
|
|
2026
|
+
h(Switch, { checked: form.endoMoodFromEmotion, onChange: (v) => patch("endoMoodFromEmotion")(v) }),
|
|
2027
|
+
),
|
|
2028
|
+
h("div", { className: "row" },
|
|
2029
|
+
h("div", null, h("div", { className: "lbl" }, "周期长度"), h("div", { className: "hint" }, "范围 21–45 天,默认 28 天")),
|
|
2030
|
+
h("input", { type: "number", min: 21, max: 45, value: form.endoCycleLength, onChange: (e) => patch("endoCycleLength")(e.target.value) }),
|
|
2031
|
+
),
|
|
2032
|
+
endocrine && endocrine.snapshot
|
|
2033
|
+
? h("div", null,
|
|
2034
|
+
h("div", { className: "hint" },
|
|
2035
|
+
"周期:" + (endocrine.snapshot.cycle ? endocrine.snapshot.cycle.phaseLabel + " 第 " + endocrine.snapshot.cycle.day + "/" + endocrine.snapshot.cycle.length + " 天" : "—")
|
|
2036
|
+
+ " · 活跃疾病:" + ((endocrine.snapshot.diseases ?? []).filter((d) => d.severity > 0).map((d) => d.name).join("、") || "无")),
|
|
2037
|
+
h("div", { className: "hint" },
|
|
2038
|
+
"偏高:" + (endocrine.snapshot.hormones.filter((hormone) => hormone.level === "high").slice(0, 4).map((hormone) => hormone.name).join("、") || "无")
|
|
2039
|
+
+ ";偏低:" + (endocrine.snapshot.hormones.filter((hormone) => hormone.level === "low").slice(0, 4).map((hormone) => hormone.name).join("、") || "无")),
|
|
2040
|
+
h("div", { style: { marginTop: "8px" } },
|
|
2041
|
+
(endocrine.snapshot.hormones ?? []).slice(0, 10).map((hormone) => h("div", { className: "row", key: hormone.id, style: { alignItems: "center", gap: "8px" } },
|
|
2042
|
+
h("div", { className: "lbl", style: { width: "74px", margin: 0 } }, hormone.name),
|
|
2043
|
+
h("div", { style: { flex: 1, height: "6px", borderRadius: "999px", background: "rgba(127,127,127,.18)", overflow: "hidden" } },
|
|
2044
|
+
h("div", { style: { width: Math.max(0, Math.min(100, Number(hormone.value) || 0)) + "%", height: "100%", borderRadius: "999px", background: "var(--dsw-alias-state-business-primary)" } })),
|
|
2045
|
+
h("div", { className: "hint", style: { width: "34px", textAlign: "right", margin: 0 } }, String(Math.round(Number(hormone.value) || 0))),
|
|
2046
|
+
)),
|
|
2047
|
+
),
|
|
2048
|
+
)
|
|
2049
|
+
: h("div", { className: "hint" }, "状态加载中…"),
|
|
2050
|
+
h("div", { className: "row" },
|
|
2051
|
+
(endocrine?.scenarios ?? []).map((s) => h("button", { key: s.id, className: "ghost", onClick: () => endocrineAction("scenario", { name: s.id }), disabled: busy }, s.label)),
|
|
2052
|
+
h("button", { className: "ghost", onClick: loadEndocrine, disabled: busy }, "刷新"),
|
|
2053
|
+
),
|
|
2054
|
+
h("div", { className: "row" },
|
|
2055
|
+
h("button", { className: "ghost", onClick: () => endocrineAction("cycleAdvance", { n: 1 }), disabled: busy }, "周期 +1 天"),
|
|
2056
|
+
h("button", { className: "ghost", onClick: () => endocrineAction("cycleReset"), disabled: busy }, "回到经期"),
|
|
2057
|
+
),
|
|
2058
|
+
),
|
|
2059
|
+
),
|
|
2060
|
+
h(Card, { title: "长期记忆" },
|
|
2061
|
+
h("div", { className: "row" },
|
|
2062
|
+
h("div", null,
|
|
2063
|
+
h("div", { className: "lbl" }, "启用长期记忆"),
|
|
2064
|
+
h("div", { className: "hint" }, "按人记住她聊过的事。同一个人在群里和私聊共用一份记忆——群里说过的事,私聊里也记得。")),
|
|
2065
|
+
h(Switch, { checked: form.memEnabled, onChange: (v) => patch("memEnabled")(v) }),
|
|
2066
|
+
),
|
|
2067
|
+
form.memEnabled
|
|
2068
|
+
? h("div", null,
|
|
2069
|
+
h("div", { className: "row" },
|
|
2070
|
+
h("div", null, h("div", { className: "lbl" }, "注入到对话里"), h("div", { className: "hint" }, "关闭后仍然记录,但聊天时她想不起来")),
|
|
2071
|
+
h(Switch, { checked: form.memInject, onChange: (v) => patch("memInject")(v) }),
|
|
2072
|
+
),
|
|
2073
|
+
h("div", { className: "row" },
|
|
2074
|
+
h("div", null, h("div", { className: "lbl" }, "用模型挑选记忆"), h("div", { className: "hint" }, "关闭则用启发式,省一次模型调用但更粗糙")),
|
|
2075
|
+
h(Switch, { checked: form.memUseModel, onChange: (v) => patch("memUseModel")(v) }),
|
|
2076
|
+
),
|
|
2077
|
+
h("div", { className: "row" },
|
|
2078
|
+
h("div", null, h("div", { className: "lbl" }, "记忆半衰期(天)"), h("div", { className: "hint" }, "越久越难想起来,但不会被删除")),
|
|
2079
|
+
h("input", { type: "number", min: 1, max: 3650, value: form.memHalfLife, onChange: (e) => patch("memHalfLife")(e.target.value) }),
|
|
2080
|
+
),
|
|
2081
|
+
h("div", { className: "row" },
|
|
2082
|
+
h("div", null, h("div", { className: "lbl" }, "召回条数 / 常驻事实"), h("div", { className: "hint" }, "每轮最多想起几条相关的事;事实不占这个额度")),
|
|
2083
|
+
h("div", { style: { display: "flex", gap: "6px", alignItems: "center" } },
|
|
2084
|
+
h("input", { type: "number", min: 0, max: 20, value: form.memRecall, onChange: (e) => patch("memRecall")(e.target.value) }),
|
|
2085
|
+
h("span", { className: "hint" }, "/"),
|
|
2086
|
+
h("input", { type: "number", min: 0, max: 20, value: form.memFacts, onChange: (e) => patch("memFacts")(e.target.value) }),
|
|
2087
|
+
),
|
|
2088
|
+
),
|
|
2089
|
+
h("div", { className: "row" },
|
|
2090
|
+
h("div", null, h("div", { className: "lbl" }, "每日记忆配额"), h("div", { className: "hint" }, "每人每天最多记几条,防止塞满上下文")),
|
|
2091
|
+
h("input", { type: "number", min: 0, max: 100, value: form.memQuota, onChange: (e) => patch("memQuota")(e.target.value) }),
|
|
2092
|
+
),
|
|
2093
|
+
)
|
|
2094
|
+
: null,
|
|
2095
|
+
memory && memory.enabled
|
|
2096
|
+
? h("div", null,
|
|
2097
|
+
h("div", { className: "hint" }, "共记住 " + memory.totalPeople + " 个人"),
|
|
2098
|
+
memory.people.length
|
|
2099
|
+
? h("div", null, memory.people.slice(0, 6).map((p) =>
|
|
2100
|
+
h("div", { key: p.personId, style: { marginTop: "6px" } },
|
|
2101
|
+
h("div", { className: "lbl" }, p.personId + " · " + p.facts + " 条事实 / " + p.events + " 条事件"),
|
|
2102
|
+
p.memories.slice(0, 4).map((m) =>
|
|
2103
|
+
h("div", { className: "hint", key: m.id, style: { display: "flex", justifyContent: "space-between", gap: "8px" } },
|
|
2104
|
+
h("span", null, "· " + m.time + " " + m.text),
|
|
2105
|
+
h("button", {
|
|
2106
|
+
className: "ghost",
|
|
2107
|
+
onClick: () => memoryAction("forget", { personId: p.personId, memoryId: m.id }),
|
|
2108
|
+
disabled: busy,
|
|
2109
|
+
style: { height: "20px", padding: "0 6px", fontSize: "11px" },
|
|
2110
|
+
}, "忘掉"),
|
|
2111
|
+
)),
|
|
2112
|
+
)))
|
|
2113
|
+
: h("div", { className: "hint" }, "还没有记忆。聊几轮后会自动出现。"),
|
|
2114
|
+
)
|
|
2115
|
+
: null,
|
|
2116
|
+
h("div", { className: "row" },
|
|
2117
|
+
h("button", { className: "ghost", onClick: loadMemory, disabled: busy }, "刷新"),
|
|
2118
|
+
),
|
|
2119
|
+
),
|
|
2120
|
+
|
|
2121
|
+
h(Card, { title: "表情包" },
|
|
2122
|
+
h("div", { className: "row" },
|
|
2123
|
+
h("div", null,
|
|
2124
|
+
h("div", { className: "lbl" }, "启用表情包图库"),
|
|
2125
|
+
h("div", { className: "hint" }, "开启后她可以用 wx_meme_search / wx_meme_send 找图发图;关闭只是隐藏工具,图库文件不动")),
|
|
2126
|
+
h(Switch, { checked: form.memesEnabled, onChange: (v) => patch("memesEnabled")(v) }),
|
|
2127
|
+
),
|
|
2128
|
+
!form.memesEnabled ? null : h("div", { className: "row" },
|
|
2129
|
+
h("div", null,
|
|
2130
|
+
h("div", { className: "lbl" }, "自动收集群里的图"),
|
|
2131
|
+
h("div", { className: "hint" }, "收到图片时按概率收进图库")),
|
|
2132
|
+
h(Switch, { checked: form.memesAutoCollect, onChange: (v) => patch("memesAutoCollect")(v) }),
|
|
2133
|
+
),
|
|
2134
|
+
!form.memesEnabled || !form.memesAutoCollect ? null : h("div", { className: "row" },
|
|
2135
|
+
h("div", null,
|
|
2136
|
+
h("div", { className: "lbl" }, "收集后需人工审核"),
|
|
2137
|
+
h("div", { className: "hint" }, "先进待审核池,你在下面点「入库」才真正可用")),
|
|
2138
|
+
h(Switch, { checked: form.memesRequireApproval, onChange: (v) => patch("memesRequireApproval")(v) }),
|
|
2139
|
+
),
|
|
2140
|
+
!form.memesEnabled ? null : h("div", { className: "row" },
|
|
2141
|
+
h("div", null,
|
|
2142
|
+
h("div", { className: "lbl" }, "用视觉模型自动分类"),
|
|
2143
|
+
h("div", { className: "hint" }, "每批图片调一次模型,生成描述/标签/情绪用于检索;关闭则按文件名和手动标签")),
|
|
2144
|
+
h(Switch, { checked: form.memesVision, onChange: (v) => patch("memesVision")(v) }),
|
|
2145
|
+
),
|
|
2146
|
+
!form.memesEnabled ? null : h("div", { className: "row" },
|
|
2147
|
+
h("div", null,
|
|
2148
|
+
h("div", { className: "lbl" }, "回复后自动配表情的概率"),
|
|
2149
|
+
h("div", { className: "hint" }, "0 = 从不,0.15 = 约七分之一")),
|
|
2150
|
+
h("input", {
|
|
2151
|
+
type: "number", min: 0, max: 1, step: 0.05, value: form.memesAutoSendChance,
|
|
2152
|
+
onChange: (e) => patch("memesAutoSendChance")(e.target.value),
|
|
2153
|
+
}),
|
|
2154
|
+
),
|
|
2155
|
+
!form.memesEnabled ? null : h("div", { className: "hint" },
|
|
2156
|
+
memeStats
|
|
2157
|
+
? "图库 " + memeStats.total + " 张 · 已分类 " + memeStats.classified + " · 待审核 " + memeStats.pending
|
|
2158
|
+
: "图库读取中…"),
|
|
2159
|
+
!form.memesEnabled ? null : h("div", { className: "row" },
|
|
2160
|
+
h("button", { className: "ghost", onClick: () => memeAction("classify"), disabled: busy }, "立即分类"),
|
|
2161
|
+
h("button", { className: "ghost", onClick: loadMemes, disabled: busy }, "刷新图库"),
|
|
2162
|
+
),
|
|
2163
|
+
!form.memesEnabled ? null : h("div", { className: "row" },
|
|
2164
|
+
h("input", {
|
|
2165
|
+
type: "text", value: form.memeFolder ?? "", placeholder: "本地表情包文件夹,例如 D:\\stickers",
|
|
2166
|
+
onChange: (e) => patch("memeFolder")(e.target.value),
|
|
2167
|
+
}),
|
|
2168
|
+
h("button", { className: "ghost", onClick: () => memeAction("import", { folder: form.memeFolder ?? "" }), disabled: busy }, "导入文件夹"),
|
|
2169
|
+
),
|
|
2170
|
+
!form.memesEnabled || !memeStats ? null : h("div", { className: "hint" },
|
|
2171
|
+
"手动放图:把图片放进 " + (memeStats.root || "数据目录/memes") + " 的 images 文件夹后点「刷新图库」;或用上面的「导入文件夹」(子目录名会自动成为标签)。"),
|
|
2172
|
+
!form.memesEnabled || !memes || !(memes.pending ?? []).length ? null : h("div", null,
|
|
2173
|
+
h("div", { className: "lbl" }, "待审核(" + memes.pending.length + ")"),
|
|
2174
|
+
h("div", { className: "hint" }, "这些图还没进图库。点「入库」通过,「丢弃」删除。"),
|
|
2175
|
+
h("div", { className: "row" }, memes.pending.slice(0, 6).map((item) =>
|
|
2176
|
+
h("div", { key: item.id, className: "row" },
|
|
2177
|
+
h("span", { className: "hint" }, item.width + "×" + item.height + " " + (item.description || item.id)),
|
|
2178
|
+
h("button", { className: "ghost", onClick: () => memeAction("approve", { id: item.id }), disabled: busy }, "入库"),
|
|
2179
|
+
h("button", { className: "ghost", onClick: () => memeAction("reject", { id: item.id }), disabled: busy }, "丢弃"),
|
|
2180
|
+
),
|
|
2181
|
+
)),
|
|
2182
|
+
),
|
|
2183
|
+
!form.memesEnabled || !memes || !(memes.entries ?? []).length ? null : h("div", null,
|
|
2184
|
+
h("div", { className: "lbl" }, "最近入库(" + memes.entries.length + ")"),
|
|
2185
|
+
h("div", { className: "hint" }, memes.entries.slice(0, 8).map((item) =>
|
|
2186
|
+
(item.description || item.note || item.id) + ((item.emotions ?? []).length ? "[" + item.emotions.join("/") + "]" : "")
|
|
2187
|
+
).join(" · ")),
|
|
2188
|
+
),
|
|
2189
|
+
),
|
|
2190
|
+
|
|
2191
|
+
h(Card, { title: "回复节奏" },
|
|
2192
|
+
// 分段规则。放在卡片最前面:这是最容易「看起来坏了」的一项 ——
|
|
2193
|
+
// 切太碎像刷屏,切不开又像不分段。
|
|
2194
|
+
h("div", { className: "row" },
|
|
2195
|
+
h("div", null,
|
|
2196
|
+
h("div", { className: "lbl" }, "按逗号分段"),
|
|
2197
|
+
h("div", { className: "hint" },
|
|
2198
|
+
"开着时「在呢,刚忙完,怎么了」会拆成三条发出去,像真人打字。",
|
|
2199
|
+
"关掉后只按换行分段,适合她经常发代码、JSON、英文长句的场景。"),
|
|
2200
|
+
),
|
|
2201
|
+
h(Switch, { checked: form.commaSplit !== false, onChange: (v) => patch("commaSplit")(v) }),
|
|
2202
|
+
),
|
|
2203
|
+
h("div", { className: "hint", style: { margin: "0 0 10px" } },
|
|
2204
|
+
"代码块和行内代码永远整块保留,不受这一项影响。"),
|
|
2205
|
+
// 会话回收:空闲多久之后销毁内存里的 agent。
|
|
2206
|
+
// 这个值直接决定「隔一会儿再聊,她还记不记得刚才说到哪」。
|
|
2207
|
+
h("div", { className: "row" },
|
|
2208
|
+
h("div", null,
|
|
2209
|
+
h("div", { className: "lbl" }, "会话保留时间(分钟)"),
|
|
2210
|
+
h("div", { className: "hint" }, form.sharedAgent ? "共享会话模式下回收只是释放内存:下次聊天自动恢复完整历史,连续感不受影响。填 0 表示永不回收。范围 0–1440" : "隔这么久没说话,就把这个对话的上下文从内存里清掉。下次再聊会重新补最近 20 条历史,但「上次说到哪」的连续感会弱一些。填 0 表示永不清理。范围 0–1440")),
|
|
2211
|
+
h("input", {
|
|
2212
|
+
type: "number", min: 0, max: 1440, value: form.idleMinutes,
|
|
2213
|
+
disabled: form.neverEvict === true,
|
|
2214
|
+
onChange: (e) => patch("idleMinutes")(e.target.value),
|
|
2215
|
+
}),
|
|
2216
|
+
),
|
|
2217
|
+
h("div", { className: "row" },
|
|
2218
|
+
h("div", null,
|
|
2219
|
+
h("div", { className: "lbl" }, "永不回收"),
|
|
2220
|
+
h("div", { className: "hint" }, form.sharedAgent ? "共享会话模式下此项作用减弱:即使回收,历史也通过恢复机制保留。此选项只控制内存占用。" : "打开后所有对话的上下文一直留着,只能靠重启 DSH 释放。聊过的人多时会占内存,但她的连续感最好")),
|
|
2221
|
+
h(Switch, {
|
|
2222
|
+
checked: form.neverEvict === true,
|
|
2223
|
+
onChange: (v) => { patch("neverEvict")(v); if (v) patch("idleMinutes")(0); else if (Number(form.idleMinutes) <= 0) patch("idleMinutes")(30); },
|
|
2224
|
+
}),
|
|
2225
|
+
),
|
|
2226
|
+
// 每次新建会话时补多少条历史。
|
|
2227
|
+
// 重启 DSH、或空闲超过「会话保留时间」之后,agent 会重建 ——
|
|
2228
|
+
// 重建后她能看到多少「之前聊过什么」,完全由这个数决定。
|
|
2229
|
+
h("div", { className: "row" },
|
|
2230
|
+
h("div", null,
|
|
2231
|
+
h("div", { className: "lbl" }, "重建后补多少条历史"),
|
|
2232
|
+
h("div", { className: "hint" }, form.sharedAgent ? "共享会话模式下此项作用减弱:完整历史由会话自动保持,此选项只影响额外注入的上下文。范围 0–100,默认 20" : "重启或空闲回收后,新会话会把最近这么多条聊天记录重新读一遍。调大她更容易接上「上次说到哪」,代价是每次请求变长。范围 0–100,默认 20")),
|
|
2233
|
+
h("input", {
|
|
2234
|
+
type: "number", min: 0, max: 100, value: form.contextMessages,
|
|
2235
|
+
onChange: (e) => patch("contextMessages")(e.target.value),
|
|
2236
|
+
}),
|
|
2237
|
+
),
|
|
2238
|
+
h("div", { className: "row" },
|
|
2239
|
+
h("div", null,
|
|
2240
|
+
h("div", { className: "lbl" }, "批量窗口(秒)"),
|
|
2241
|
+
h("div", { className: "hint" }, "她话还没说完就回了?把这个调大。收到消息后等这么久、确认没有新消息才回复,窗口内的几句合并成一轮。默认 1.2 秒;5–10 秒多数人觉得最自然,60 秒等于每分钟统一处理一次。范围 0–600 秒,改完即时生效")),
|
|
2242
|
+
h("input", {
|
|
2243
|
+
type: "number", min: 0, max: 600, step: 0.1, value: form.debounceSec,
|
|
2244
|
+
onChange: (e) => patch("debounceSec")(e.target.value),
|
|
2245
|
+
}),
|
|
2246
|
+
),
|
|
2247
|
+
h("div", { className: "row" },
|
|
2248
|
+
h("div", null,
|
|
2249
|
+
h("div", { className: "lbl" }, "轮询间隔(秒)"),
|
|
2250
|
+
h("div", { className: "hint" }, "多久向微信查一次最近消息,补上事件流丢失的部分。范围 15–3600 秒")),
|
|
2251
|
+
h("input", {
|
|
2252
|
+
type: "number", min: 15, max: 3600, value: form.pollSeconds,
|
|
2253
|
+
onChange: (e) => patch("pollSeconds")(e.target.value),
|
|
2254
|
+
}),
|
|
2255
|
+
),
|
|
2256
|
+
h("div", { className: "row" },
|
|
2257
|
+
h("div", null,
|
|
2258
|
+
h("div", { className: "lbl" }, "轮询补漏"),
|
|
2259
|
+
h("div", { className: "hint" }, "每个周期向微信查一次最近消息,防止事件丢失(5 分钟前的只归档不回复)")),
|
|
2260
|
+
h(Switch, { checked: form.pollEnabled, onChange: patch("pollEnabled") }),
|
|
2261
|
+
),
|
|
2262
|
+
h("div", { className: "row" },
|
|
2263
|
+
h("div", null,
|
|
2264
|
+
h("div", { className: "lbl" }, "分段最小间隔(秒)"),
|
|
2265
|
+
h("div", { className: "hint" }, "拆成多条发送时,相邻两条之间至少等这么久")),
|
|
2266
|
+
h("input", {
|
|
2267
|
+
type: "number", min: 0, max: 30, step: 0.1, value: form.segmentMinSec,
|
|
2268
|
+
onChange: (e) => patch("segmentMinSec")(e.target.value),
|
|
2269
|
+
}),
|
|
2270
|
+
),
|
|
2271
|
+
h("div", { className: "row" },
|
|
2272
|
+
h("div", null,
|
|
2273
|
+
h("div", { className: "lbl" }, "分段最大间隔(秒)"),
|
|
2274
|
+
h("div", { className: "hint" }, "再长也不会超过这个上限,避免长句卡太久")),
|
|
2275
|
+
h("input", {
|
|
2276
|
+
type: "number", min: 0, max: 60, step: 0.1, value: form.segmentMaxSec,
|
|
2277
|
+
onChange: (e) => patch("segmentMaxSec")(e.target.value),
|
|
2278
|
+
}),
|
|
2279
|
+
),
|
|
2280
|
+
h("div", { className: "row" },
|
|
2281
|
+
h("div", null,
|
|
2282
|
+
h("div", { className: "lbl" }, "每字追加(毫秒)"),
|
|
2283
|
+
h("div", { className: "hint" }, "越长的句子等得越久,更像真人打字;0 = 固定用最小间隔")),
|
|
2284
|
+
h("input", {
|
|
2285
|
+
type: "number", min: 0, max: 500, step: 10, value: form.segmentPerCharMs,
|
|
2286
|
+
onChange: (e) => patch("segmentPerCharMs")(e.target.value),
|
|
2287
|
+
}),
|
|
2288
|
+
),
|
|
2289
|
+
h("div", { className: "hint" },
|
|
2290
|
+
"当前效果:「好的」等 " + gapFor("好的") + " 秒,「今天过得怎么样呀,要不要一起打游戏」等 "
|
|
2291
|
+
+ gapFor("今天过得怎么样呀,要不要一起打游戏") + " 秒。改完保存即时生效。"),
|
|
2292
|
+
),
|
|
2293
|
+
|
|
2294
|
+
h(Card, { title: "Steam" },
|
|
2295
|
+
h("div", { className: "row" },
|
|
2296
|
+
h("div", null,
|
|
2297
|
+
h("div", { className: "lbl" }, "接入 Steam 状态"),
|
|
2298
|
+
h("div", { className: "hint" }, "打开后她知道你此刻在玩什么、在线还是离线,可以在聊天里自然提起。需要先填 Steam Web API Key。")),
|
|
2299
|
+
h(Switch, { checked: form.steamEnabled, onChange: (v) => patch("steamEnabled")(v) }),
|
|
2300
|
+
),
|
|
2301
|
+
!form.steamEnabled ? null : h("div", { className: "row" },
|
|
2302
|
+
h("div", null,
|
|
2303
|
+
h("div", { className: "lbl" }, "API Key"),
|
|
2304
|
+
h("div", { className: "hint" }, "在 steamcommunity.com/dev/apikey 申请,32 位十六进制。" + (form.steamHasKey ? "当前已保存,留空表示不修改。" : ""))),
|
|
2305
|
+
h("input", { type: "password", placeholder: form.steamHasKey ? "已保存(留空不改)" : "粘贴 32 位 Key", value: form.steamKey, onChange: (e) => patch("steamKey")(e.target.value) }),
|
|
2306
|
+
),
|
|
2307
|
+
!form.steamEnabled ? null : h("div", { className: "row" },
|
|
2308
|
+
h("div", null,
|
|
2309
|
+
h("div", { className: "lbl" }, "缓存时间(秒)"),
|
|
2310
|
+
h("div", { className: "hint" }, "多久才真正问一次 Steam。调大省请求,调小更实时;填 0 表示每次都查。范围 0–86400")),
|
|
2311
|
+
h("input", { type: "number", min: 0, max: 86400, value: form.steamCacheSec, onChange: (e) => patch("steamCacheSec")(e.target.value) }),
|
|
2312
|
+
),
|
|
2313
|
+
!form.steamEnabled ? null : h("div", { className: "row" },
|
|
2314
|
+
h("div", null,
|
|
2315
|
+
h("div", { className: "lbl" }, "一起拉游戏时长"),
|
|
2316
|
+
h("div", { className: "hint" }, "关掉可少一个请求。开启需要 Steam 的「游戏详情」设为公开,否则拿不到时长。")),
|
|
2317
|
+
h(Switch, { checked: form.steamWithGames, onChange: (v) => patch("steamWithGames")(v) }),
|
|
2318
|
+
),
|
|
2319
|
+
!form.steamEnabled ? null : h("div", { className: "row" },
|
|
2320
|
+
h("div", null,
|
|
2321
|
+
h("div", { className: "lbl" }, "聊天时注入状态"),
|
|
2322
|
+
h("div", { className: "hint" }, "打开后她本来就知道你在玩什么,不用你问。关掉后她不知道,但在面板里仍然能看到状态。")),
|
|
2323
|
+
h(Switch, { checked: form.steamInject, onChange: (v) => patch("steamInject")(v) }),
|
|
2324
|
+
),
|
|
2325
|
+
!form.steamEnabled ? null : h("div", { className: "row" },
|
|
2326
|
+
h("div", null,
|
|
2327
|
+
h("div", { className: "lbl" }, "主动消息也注入"),
|
|
2328
|
+
h("div", { className: "hint" }, "打开后她主动找你时会知道你在玩什么,但提示词里明确要求不要每次都提这件事。")),
|
|
2329
|
+
h(Switch, { checked: form.steamInjectProactive, onChange: (v) => patch("steamInjectProactive")(v) }),
|
|
2330
|
+
),
|
|
2331
|
+
!form.steamEnabled ? null : h("div", { className: "row" },
|
|
2332
|
+
h("div", null,
|
|
2333
|
+
h("div", { className: "lbl" }, "只在私聊注入"),
|
|
2334
|
+
h("div", { className: "hint" }, "建议保持开启。群里还有别人,把你正在玩什么说出去不太合适。")),
|
|
2335
|
+
h(Switch, { checked: form.steamPrivateOnly, onChange: (v) => patch("steamPrivateOnly")(v) }),
|
|
2336
|
+
),
|
|
2337
|
+
// 绑定表放在同一张卡片里:它属于 Steam 功能的一部分,
|
|
2338
|
+
// 分成两张卡会让人以为要分别开两个开关。
|
|
2339
|
+
h("div", { style: { marginTop: "16px", paddingTop: "12px", borderTop: "1px solid rgba(127,127,127,0.2)" } },
|
|
2340
|
+
h("div", { style: { fontWeight: 600, marginBottom: "6px" } }, "绑定表(微信 → Steam)"),
|
|
2341
|
+
h("div", { className: "hint", style: { marginBottom: "8px" } },
|
|
2342
|
+
"把联系人和 Steam 账号关联起来。只有这里能绑,聊天里不能 —— SteamID 是公开信息,允许在群里绑的话,任何人都能把别人的 ID 绑到自己身上。"),
|
|
2343
|
+
(steamBindings || []).length === 0
|
|
2344
|
+
? h("div", { className: "hint" }, "还没有任何绑定。")
|
|
2345
|
+
: (steamBindings || []).map((row) => h("div", { key: row.peer, className: "row", style: { alignItems: "flex-start" } },
|
|
2346
|
+
h("div", null,
|
|
2347
|
+
h("div", { className: "lbl" }, "微信 " + row.peer),
|
|
2348
|
+
(row.bindings || []).map((b) => h("div", { key: b.steamId, className: "hint" },
|
|
2349
|
+
b.steamId + (b.nickname ? "(" + b.nickname + ")" : "") + " "
|
|
2350
|
+
+ h("button", { className: "ghost", style: { marginLeft: "6px", padding: "1px 8px" },
|
|
2351
|
+
onClick: () => steamUnbind(row.peer, b.steamId) }, "解绑"))),
|
|
2352
|
+
),
|
|
2353
|
+
)),
|
|
2354
|
+
h("div", { className: "row", style: { marginTop: "10px" } },
|
|
2355
|
+
h("div", null,
|
|
2356
|
+
h("div", { className: "lbl" }, "新增绑定"),
|
|
2357
|
+
h("div", { className: "hint" }, "填微信号和 17 位 SteamID64。绑完会立刻探一次,把 Steam 昵称带回来。")),
|
|
2358
|
+
h("div", { style: { display: "flex", flexDirection: "column", gap: "6px" } },
|
|
2359
|
+
...(steamDrafts || []).map((draft, index) => h("div", { key: draft.id, style: { display: "flex", gap: "6px", alignItems: "center" } },
|
|
2360
|
+
h("input", { type: "text", placeholder: "微信号", style: { width: "120px" }, value: draft.peer,
|
|
2361
|
+
onChange: (e) => setSteamDraft(draft.id, { peer: e.target.value }) }),
|
|
2362
|
+
h("input", { type: "text", placeholder: "7656119xxxxxxxxxx", style: { width: "180px" }, value: draft.steamId,
|
|
2363
|
+
onChange: (e) => setSteamDraft(draft.id, { steamId: e.target.value }) }),
|
|
2364
|
+
draft.done
|
|
2365
|
+
? h("span", { className: "hint", style: { color: "rgba(80,180,110,1)" } }, "✓ 已绑定")
|
|
2366
|
+
: h("button", { className: "ghost", disabled: steamBindBusy, onClick: () => steamBindSubmit(draft.id) },
|
|
2367
|
+
steamBindBusy ? "绑定中…" : "绑定"),
|
|
2368
|
+
(steamDrafts || []).length > 1
|
|
2369
|
+
? h("button", { className: "ghost", style: { padding: "1px 8px" },
|
|
2370
|
+
onClick: () => removeSteamDraft(draft.id) }, "×")
|
|
2371
|
+
: null,
|
|
2372
|
+
)),
|
|
2373
|
+
),
|
|
2374
|
+
),
|
|
2375
|
+
),
|
|
2376
|
+
),
|
|
2377
|
+
h(Card, { title: "生图" },
|
|
2378
|
+
h("div", { className: "row" },
|
|
2379
|
+
h("div", null,
|
|
2380
|
+
h("div", { className: "lbl" }, "允许她自己发图"),
|
|
2381
|
+
h("div", { className: "hint" }, "打开后,想发图时会调用豆包生图,画完直接发出去。需要一个能生图的服务商(默认用已安装的豆包插件)。")),
|
|
2382
|
+
h(Switch, { checked: form.imgEnabled, onChange: (v) => patch("imgEnabled")(v) }),
|
|
2383
|
+
),
|
|
2384
|
+
!form.imgEnabled ? null : h("div", { className: "row" },
|
|
2385
|
+
h("div", null,
|
|
2386
|
+
h("div", { className: "lbl" }, "服务商"),
|
|
2387
|
+
h("div", { className: "hint" }, "生图走 Harness 的模型路由。默认 doubao(dsh-connect-doubao 注册的「豆包 生图」)。")),
|
|
2388
|
+
h("input", { type: "text", placeholder: "doubao", value: form.imgProvider, onChange: (e) => patch("imgProvider")(e.target.value) }),
|
|
2389
|
+
),
|
|
2390
|
+
!form.imgEnabled ? null : h("div", { className: "row" },
|
|
2391
|
+
h("div", null,
|
|
2392
|
+
h("div", { className: "lbl" }, "生图模型"),
|
|
2393
|
+
h("div", { className: "hint" }, "默认 image-gen。改了要重启 DSH 才生效。")),
|
|
2394
|
+
h("input", { type: "text", placeholder: "image-gen", value: form.imgModel, onChange: (e) => patch("imgModel")(e.target.value) }),
|
|
2395
|
+
),
|
|
2396
|
+
!form.imgEnabled ? null : h("div", { className: "row" },
|
|
2397
|
+
h("div", null,
|
|
2398
|
+
h("div", { className: "lbl" }, "超时(秒)"),
|
|
2399
|
+
h("div", { className: "hint" }, "生图一般 10–30 秒。等太久没出来就放弃,免得卡住整个回复。范围 10–600")),
|
|
2400
|
+
h("input", { type: "number", min: 10, max: 600, value: form.imgTimeoutSec, onChange: (e) => patch("imgTimeoutSec")(e.target.value) }),
|
|
2401
|
+
),
|
|
2402
|
+
h("div", { className: "row" },
|
|
2403
|
+
h("div", null,
|
|
2404
|
+
h("div", { className: "lbl" }, "每次最多发几张"),
|
|
2405
|
+
h("div", { className: "hint" }, "范围 1–6。豆包一次通常回 1–3 张,超过这个数的只发前几张。开太多会明显变慢,也更容易触发风控。")),
|
|
2406
|
+
h("input", { type: "number", min: 1, max: 6, value: form.imgMaxPerTurn, onChange: (e) => patch("imgMaxPerTurn")(e.target.value) }),
|
|
2407
|
+
),
|
|
2408
|
+
!form.imgEnabled ? null : h("div", { className: "hint", style: { marginTop: 8 } },
|
|
2409
|
+
"生图会消耗豆包额度,且每次都要十几秒。不要让她每句话都发图。"),
|
|
2410
|
+
),
|
|
2411
|
+
h(Card, { title: "回复范围" },
|
|
2412
|
+
h("div", { className: "row" },
|
|
2413
|
+
h("div", null, h("div", { className: "lbl" }, "私聊范围")),
|
|
2414
|
+
h("select", { value: form.privateMode, onChange: (e) => patch("privateMode")(e.target.value) },
|
|
2415
|
+
h("option", { value: "all" }, "所有人"),
|
|
2416
|
+
h("option", { value: "allowlist" }, "仅白名单"),
|
|
2417
|
+
h("option", { value: "disabled" }, "全部忽略"),
|
|
2418
|
+
),
|
|
2419
|
+
),
|
|
2420
|
+
h("div", { className: "row" },
|
|
2421
|
+
h("div", null, h("div", { className: "lbl" }, "私聊白名单"), h("div", { className: "hint" }, "微信号,逗号分隔;仅白名单模式生效")),
|
|
2422
|
+
h("input", { type: "text", value: form.privateIds, onChange: (e) => patch("privateIds")(e.target.value), placeholder: "123456789" }),
|
|
2423
|
+
),
|
|
2424
|
+
h("div", { className: "row" },
|
|
2425
|
+
h("div", null, h("div", { className: "lbl" }, "群消息")),
|
|
2426
|
+
h("select", { value: form.groupMode, onChange: (e) => patch("groupMode")(e.target.value) },
|
|
2427
|
+
h("option", { value: "all" }, "全部接收"),
|
|
2428
|
+
h("option", { value: "allowlist" }, "仅白名单群"),
|
|
2429
|
+
h("option", { value: "disabled" }, "全部忽略"),
|
|
2430
|
+
),
|
|
2431
|
+
),
|
|
2432
|
+
h("div", { className: "row" },
|
|
2433
|
+
h("div", null, h("div", { className: "lbl" }, "群白名单"), h("div", { className: "hint" }, "群号,逗号分隔;仅白名单群模式生效")),
|
|
2434
|
+
h("input", { type: "text", value: form.groupIds, onChange: (e) => patch("groupIds")(e.target.value), placeholder: "123456789" }),
|
|
2435
|
+
),
|
|
2436
|
+
h("div", { className: "row" },
|
|
2437
|
+
h("div", null, h("div", { className: "lbl" }, "屏蔽的联系人"), h("div", { className: "hint" }, "这些人的消息一律忽略,优先于其它设置")),
|
|
2438
|
+
h("input", { type: "text", value: form.blockedUsers, onChange: (e) => patch("blockedUsers")(e.target.value) }),
|
|
2439
|
+
),
|
|
2440
|
+
h("div", { className: "row" },
|
|
2441
|
+
h("div", null, h("div", { className: "lbl" }, "屏蔽的群"), h("div", { className: "hint" }, "这些群一条都不收")),
|
|
2442
|
+
h("input", { type: "text", value: form.blockedGroups, onChange: (e) => patch("blockedGroups")(e.target.value) }),
|
|
2443
|
+
),
|
|
2444
|
+
h("div", { className: "row" },
|
|
2445
|
+
h("div", null, h("div", { className: "lbl" }, "管理员微信"), h("div", { className: "hint" }, "可用插件工具操作微信;群内仍按普通成员处理")),
|
|
2446
|
+
h("input", { type: "text", value: form.ownerIds, onChange: (e) => patch("ownerIds")(e.target.value) }),
|
|
2447
|
+
),
|
|
2448
|
+
),
|
|
2449
|
+
|
|
2450
|
+
h(Card, { title: "人格设定" },
|
|
2451
|
+
h("div", { className: "hint" }, "只影响自动回复时的语气与习惯;不会覆盖系统提示。"),
|
|
2452
|
+
h("textarea", { value: form.persona, onChange: (e) => patch("persona")(e.target.value), placeholder: "你是一名友好自然的 AI 微信助手…" }),
|
|
2453
|
+
),
|
|
2454
|
+
|
|
2455
|
+
h(Card, { title: "归档" },
|
|
2456
|
+
h("div", { className: "row" },
|
|
2457
|
+
h("div", null,
|
|
2458
|
+
h("div", { className: "lbl" }, "永久保存"),
|
|
2459
|
+
h("div", { className: "hint" }, "打开后不再按天删除,所有归档一直留着;关掉则按下面的天数自动清理。")),
|
|
2460
|
+
h(Switch, { checked: form.retentionForever, onChange: (v) => patch("retentionForever")(v) }),
|
|
2461
|
+
),
|
|
2462
|
+
form.retentionForever
|
|
2463
|
+
? h("div", { className: "hint" }, "当前策略:永久保存。归档只会随你手动删除或卸载插件而消失。")
|
|
2464
|
+
: h("div", { className: "row" },
|
|
2465
|
+
h("div", null,
|
|
2466
|
+
h("div", { className: "lbl" }, "本地归档保留天数"),
|
|
2467
|
+
h("div", { className: "hint" }, "收到和发出的每条消息按天存成一个文件,超期自动删除。默认 30 天,范围 1–3650。")),
|
|
2468
|
+
h("input", {
|
|
2469
|
+
type: "number", min: 1, max: 3650, value: form.retentionDays,
|
|
2470
|
+
onChange: (e) => patch("retentionDays")(e.target.value),
|
|
2471
|
+
}),
|
|
2472
|
+
),
|
|
2473
|
+
h("div", { className: "hint" }, "这个值影响三件事:wx_read_history 能读到多久以前、wx_search_messages 能搜到多久以前、以及主动消息会话列表里还能看到哪些聊天。永久保存会让这三处都不设时间下限。"),
|
|
2474
|
+
),
|
|
2475
|
+
|
|
2476
|
+
// msg / err 放在保存条之前:保存条是吸底的,提示落在它下面会被压在屏幕外。
|
|
2477
|
+
msg ? h("div", { className: "msg" }, msg) : null,
|
|
2478
|
+
err ? h("div", { className: "msg err" }, err) : null,
|
|
2479
|
+
// UI 优化:保存条吸底。原来保存按钮只在最上和最下,改中间的设置时
|
|
2480
|
+
// 两个都不在视野里;用户只能记着「等会儿滚到底再存」,然后就忘了。
|
|
2481
|
+
// 常驻显示而不只在 dirty 时出现,是因为它同时充当「这里有未保存内容」的锚点。
|
|
2482
|
+
h("div", { className: "savebar" },
|
|
2483
|
+
h("div", { className: "grow" },
|
|
2484
|
+
dirty
|
|
2485
|
+
? h("div", { style: { color: "var(--dsw-alias-warning, #d97706)", fontSize: "12.5px" } }, "有未保存的修改")
|
|
2486
|
+
: h("div", { className: "hint", style: { marginTop: 0 } }, "改完记得点「保存设置」,否则刷新后会变回去"),
|
|
2487
|
+
),
|
|
2488
|
+
h("button", { className: "ghost", onClick: () => { setDirty(false); load(); }, disabled: busy }, "放弃修改"),
|
|
2489
|
+
h("button", { onClick: save, disabled: busy }, busy ? "保存中…" : (dirty ? "保存设置 *" : "保存设置")),
|
|
2490
|
+
),
|
|
2491
|
+
);
|
|
2492
|
+
}
|
|
2493
|
+
|
|
2494
|
+
function WechatIcon() {
|
|
2495
|
+
return h("svg", { width: 18, height: 18, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1.7, strokeLinecap: "round", strokeLinejoin: "round" },
|
|
2496
|
+
h("path", { d: "M21 11.5a8.4 8.4 0 0 1-8.5 8.5 8.7 8.7 0 0 1-3.8-.9L3 21l1.9-5.7A8.4 8.4 0 0 1 12.5 3 8.4 8.4 0 0 1 21 11.5z" }));
|
|
2497
|
+
}
|
|
2498
|
+
|
|
2499
|
+
const PANEL_ID = "wechat-access";
|
|
2500
|
+
const inject = ["slots"];
|
|
2501
|
+
|
|
2502
|
+
function apply(ctx) {
|
|
2503
|
+
try { if (typeof window !== "undefined") window.__wechatAccessClient = { applied: true, at: Date.now() }; } catch (e) {}
|
|
2504
|
+
ctx.effect(
|
|
2505
|
+
() => ctx.slots.inject("sidebar.panellist", () => ctx.slots.register(
|
|
2506
|
+
{ name: "sidebar.panellist", id: PANEL_ID, order: 8, label: () => "微信接入" },
|
|
2507
|
+
WechatIcon,
|
|
2508
|
+
), "wechat-access: sidebar entry"),
|
|
2509
|
+
"wechat-access: sidebar entry",
|
|
2510
|
+
);
|
|
2511
|
+
ctx.effect(
|
|
2512
|
+
() => ctx.slots.inject("settings.section", () => ctx.slots.register(
|
|
2513
|
+
{ name: "settings.section", id: "wechat-access", order: 7, label: () => "微信接入" },
|
|
2514
|
+
WechatPanel,
|
|
2515
|
+
), "wechat-access: settings fallback"),
|
|
2516
|
+
"wechat-access: settings fallback",
|
|
2517
|
+
);
|
|
2518
|
+
ctx.effect(
|
|
2519
|
+
() => ctx.slots.inject("main", () => ctx.slots.register(
|
|
2520
|
+
{ name: "main", key: PANEL_ID, inject: () => ({}) },
|
|
2521
|
+
WechatPanel,
|
|
2522
|
+
), "wechat-access: main panel"),
|
|
2523
|
+
"wechat-access: main panel",
|
|
2524
|
+
);
|
|
2525
|
+
}
|
|
2526
|
+
|
|
2527
|
+
exports.apply = apply;
|
|
2528
|
+
exports.inject = inject;
|
|
2529
|
+
exports.WechatPanel = WechatPanel;
|
|
2530
|
+
return module.exports;
|
|
2531
|
+
},
|
|
2532
|
+
});
|