dsh-folia 4.25.5 → 4.26.0-pre.10
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/lib/client.js +637 -0
- package/lib/features.js +8 -0
- package/lib/index.js +9 -0
- package/lib/pet-chat-memory.js +147 -0
- package/lib/pet-chat-proactive.js +229 -0
- package/lib/route-registry.js +11 -0
- package/lib/routes/pet-chat.js +998 -0
- package/lib/routes/pets.js +30 -2
- package/lib/settings/ownership.js +5 -3
- package/lib/settings-schema.js +2161 -2053
- package/lib/tts/tts-worker.cjs +129 -0
- package/lib/voice/record.js +154 -0
- package/package.json +6 -1
package/lib/client.js
CHANGED
|
@@ -8069,6 +8069,35 @@ window.__ModuleLoader__.load({
|
|
|
8069
8069
|
// 之后退皮肤永远放不回来(审查 P3)。空串 / false = 没有待恢复的选择。
|
|
8070
8070
|
skinYieldRestoreId: '', // 让路前的壁纸 id(str 档,与壁纸 id 同一口径)
|
|
8071
8071
|
skinYieldRestoreRotation: false, // 让路前的轮播开关
|
|
8072
|
+
|
|
8073
|
+
// ── 桌宠对话(门 2):点宠物 -> 气泡 -> 用户自己的模型 ──────────────────────
|
|
8074
|
+
// 整包一个对象(`kind: 'petChat'`,见 readPetChat),因为它是一个功能的一组参数,
|
|
8075
|
+
// 拆成十个顶层键只会让归属表更难读。
|
|
8076
|
+
// ⚠️ `apiKey` **只存本机 profile**:不打印、不进日志、不上传站点(门 2 自检 S5 用 grep 守)。
|
|
8077
|
+
// `enabled` 默认 **false**:不点不连、不给没配置的人弹错误;关掉即回到预设台词库。
|
|
8078
|
+
petChat: {
|
|
8079
|
+
enabled: false,
|
|
8080
|
+
// 默认走用户自己的 DeepSeek(工单 A1):key 由用户在设置里填,不预置任何凭据。
|
|
8081
|
+
provider: 'openai', // 'ollama' | 'openai'(openai = 任何 OpenAI 兼容端点)
|
|
8082
|
+
baseUrl: 'https://api.deepseek.com',
|
|
8083
|
+
apiKey: '', // 用户自己填;本机 Ollama 不需要
|
|
8084
|
+
model: 'deepseek-chat',
|
|
8085
|
+
/**
|
|
8086
|
+
* v0.1 设置收敛:**只有一个对象、一套键**(工单 §5「配置单一真源」)。
|
|
8087
|
+
*
|
|
8088
|
+
* 旧键(persona / maxTurns / maxChars / voiceOut / voiceEngine / voiceEnabled)
|
|
8089
|
+
* 读入时由 readPetChat() 映射成这里的结构,写回只写新结构 —— 不再有第二套。
|
|
8090
|
+
* 上下文轮数 / 字数上限这两个"实现细节"降级为代码常量(见 DEFAULT_MAX_TURNS/CHARS),
|
|
8091
|
+
* 用户不再需要知道它们。
|
|
8092
|
+
*/
|
|
8093
|
+
petName: '', // 桌宠名字(空 ⇒ 用宠物包 displayName);同时是唤醒词
|
|
8094
|
+
ownerName: '', // 用户希望被怎么称呼
|
|
8095
|
+
// 朗读:只有一个音色 + 一个静音开关(不再有 rate/pitch/volume/voiceURI 五件套)
|
|
8096
|
+
voice: { name: 'zh-CN-XiaoxiaoNeural', muted: false },
|
|
8097
|
+
// 唤醒:点一下默认开;叫名字默认关(S6 才实现,先在设置里留位)
|
|
8098
|
+
wake: { click: true, name: false, keyword: '' },
|
|
8099
|
+
// 对话记忆默认开启且**不暴露开关**(追加决定 1):能力常开,用户只能在右键里查看/清空
|
|
8100
|
+
},
|
|
8072
8101
|
};
|
|
8073
8102
|
|
|
8074
8103
|
// 只做默认值、既不 sanitize 也不持久化的键(纯展示态字段)。
|
|
@@ -8304,6 +8333,8 @@ window.__ModuleLoader__.load({
|
|
|
8304
8333
|
// 皮肤互操作的落盘记忆:id 走与壁纸 id 同一个 str 档,轮播开关走 boolFalse。
|
|
8305
8334
|
skinYieldRestoreId: { kind: 'str' },
|
|
8306
8335
|
skinYieldRestoreRotation: { kind: 'boolFalse' },
|
|
8336
|
+
// 桌宠对话(门 2):整包一个键,子字段的校验在 readPetChat 里(见该函数)。
|
|
8337
|
+
petChat: { kind: 'petChat' },
|
|
8307
8338
|
};
|
|
8308
8339
|
|
|
8309
8340
|
// ── 整机配置快照 · 派生段(`PROFILE_PRESET_KEYS` 必须由 `KINDS` 派生,见上方四段注释)──
|
|
@@ -8771,6 +8802,77 @@ window.__ModuleLoader__.load({
|
|
|
8771
8802
|
return base;
|
|
8772
8803
|
}
|
|
8773
8804
|
|
|
8805
|
+
// ── 桌宠对话(门 2)──────────────────────────────────────────────────────────
|
|
8806
|
+
// 整包一个设置键;子字段在这里消毒(客户端与宿主共用同一条路径)。
|
|
8807
|
+
const PET_CHAT_PROVIDER_VALUES = ['ollama', 'openai'];
|
|
8808
|
+
const PET_CHAT_MAX_TURNS = 12; // 工单:默认 8、上限 12
|
|
8809
|
+
const PET_CHAT_MAX_CHARS = 160; // 工单:默认 80、上限 160
|
|
8810
|
+
const PET_CHAT_MIN_CHARS = 20;
|
|
8811
|
+
const PET_CHAT_BASE_URL_MAX = 300;
|
|
8812
|
+
const PET_CHAT_API_KEY_MAX = 400;
|
|
8813
|
+
const PET_CHAT_MODEL_MAX = 120;
|
|
8814
|
+
const PET_CHAT_PERSONA_MAX = 200;
|
|
8815
|
+
|
|
8816
|
+
const petChatStr = (v, max) => (typeof v === 'string' ? v.slice(0, max) : '');
|
|
8817
|
+
const petChatFloat = (v, lo, hi, fallback) => {
|
|
8818
|
+
const n = Number(v);
|
|
8819
|
+
return Number.isFinite(n) ? Math.min(hi, Math.max(lo, n)) : fallback;
|
|
8820
|
+
};
|
|
8821
|
+
const petChatInt = (v, lo, hi, fallback) => {
|
|
8822
|
+
const n = Number(v);
|
|
8823
|
+
return Number.isFinite(n) ? Math.min(hi, Math.max(lo, Math.round(n))) : fallback;
|
|
8824
|
+
};
|
|
8825
|
+
|
|
8826
|
+
/**
|
|
8827
|
+
* 桌宠对话设置的消毒。
|
|
8828
|
+
*
|
|
8829
|
+
* 口径与全表一致:**不"修好它"** —— 认不出的值即回落默认,而不是猜一个近似值。
|
|
8830
|
+
* `baseUrl` 只认 `http(s)://` 或空串(空 = 用该 provider 的默认端点,见 routes/pet-chat.js):
|
|
8831
|
+
* 主机名拼错的 URL 与其"修好",不如让用户重新填一次。
|
|
8832
|
+
* `apiKey` 原样保留(只在本机 profile 里),但**限长**,避免设置文件被灌爆。
|
|
8833
|
+
*/
|
|
8834
|
+
/**
|
|
8835
|
+
* 朗读音色(v0.1 收敛:只剩 name + muted)。
|
|
8836
|
+
*
|
|
8837
|
+
* 迁移:老档里的 `voiceOut.voiceURI` / `voiceOut.enabled` / `voiceEngine` 在这里被吸收 ——
|
|
8838
|
+
* `voiceURI` 非空就当作用户选过的音色;`enabled:false` 等价于 `muted:true`。
|
|
8839
|
+
* 这样升级不会丢用户已经选过的音色,也不会把静音的人突然打开。
|
|
8840
|
+
*/
|
|
8841
|
+
function readVoice(raw, legacy) {
|
|
8842
|
+
const def = DEFAULTS.petChat.voice;
|
|
8843
|
+
const src = raw && typeof raw === 'object' && !Array.isArray(raw) ? raw : {};
|
|
8844
|
+
const old = legacy && typeof legacy === 'object' && !Array.isArray(legacy) ? legacy : {};
|
|
8845
|
+
const name = petChatStr(src.name, 120).trim() || petChatStr(old.voiceURI, 200).trim() || def.name;
|
|
8846
|
+
const muted = typeof src.muted === 'boolean' ? src.muted : old.enabled === false;
|
|
8847
|
+
return { name, muted };
|
|
8848
|
+
}
|
|
8849
|
+
function readPetChat(raw) {
|
|
8850
|
+
const def = DEFAULTS.petChat;
|
|
8851
|
+
const src = raw && typeof raw === 'object' && !Array.isArray(raw) ? raw : {};
|
|
8852
|
+
const persona = src.persona && typeof src.persona === 'object' && !Array.isArray(src.persona) ? src.persona : {};
|
|
8853
|
+
const wake = src.wake && typeof src.wake === 'object' && !Array.isArray(src.wake) ? src.wake : {};
|
|
8854
|
+
const baseUrl = petChatStr(src.baseUrl, PET_CHAT_BASE_URL_MAX).trim();
|
|
8855
|
+
return {
|
|
8856
|
+
enabled: src.enabled === true,
|
|
8857
|
+
provider: PET_CHAT_PROVIDER_VALUES.includes(src.provider) ? src.provider : def.provider,
|
|
8858
|
+
baseUrl: baseUrl === '' || /^https?:\/\//i.test(baseUrl) ? baseUrl : '',
|
|
8859
|
+
apiKey: petChatStr(src.apiKey, PET_CHAT_API_KEY_MAX),
|
|
8860
|
+
model: petChatStr(src.model, PET_CHAT_MODEL_MAX).trim(),
|
|
8861
|
+
// 名字:新键优先;老档的 persona.name 迁移过来(不丢用户起过的名字)
|
|
8862
|
+
petName: petChatStr(src.petName, PET_CHAT_PERSONA_MAX).trim()
|
|
8863
|
+
|| petChatStr(persona.name, PET_CHAT_PERSONA_MAX).trim(),
|
|
8864
|
+
ownerName: petChatStr(src.ownerName, PET_CHAT_PERSONA_MAX).trim(),
|
|
8865
|
+
voice: readVoice(src.voice, src.voiceOut),
|
|
8866
|
+
wake: {
|
|
8867
|
+
click: wake.click !== false,
|
|
8868
|
+
name: wake.name === true,
|
|
8869
|
+
keyword: petChatStr(wake.keyword, 40).trim(),
|
|
8870
|
+
},
|
|
8871
|
+
// 记忆常开:设置里没有这个开关(追加决定 1),旧档里的 false 也不再尊重
|
|
8872
|
+
memoryEnabled: true,
|
|
8873
|
+
};
|
|
8874
|
+
}
|
|
8875
|
+
|
|
8774
8876
|
/** 壁纸属性:只收标量值,字符串限长(防设置文件被灌爆)。 */
|
|
8775
8877
|
function readUserProps(raw) {
|
|
8776
8878
|
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return {};
|
|
@@ -8838,6 +8940,7 @@ window.__ModuleLoader__.load({
|
|
|
8838
8940
|
return (bw >= 1 && bw <= MASCOT_BOX_MAX_W && bh >= 1 && bh <= MASCOT_BOX_MAX_H) ? v : def;
|
|
8839
8941
|
}
|
|
8840
8942
|
case 'map': return (v && typeof v === 'object' && !Array.isArray(v)) ? Object.assign({}, v) : {};
|
|
8943
|
+
case 'petChat': return readPetChat(v);
|
|
8841
8944
|
// ⚠️ `def` **必须**传进去(见 readModeMap 头注释):丢掉它等于把这个键的默认值变成
|
|
8842
8945
|
// 死代码 —— 真实会话里恒为 `{}`,那就是"控件在、开关滑杆动了没反应"的根因。
|
|
8843
8946
|
case 'modeMap': return readModeMap(v, def);
|
|
@@ -9077,6 +9180,10 @@ window.__ModuleLoader__.load({
|
|
|
9077
9180
|
],
|
|
9078
9181
|
// 适配器 + 媒体集成(`adapterTarget` 是跨簇共用键,归这里)
|
|
9079
9182
|
media: ['audioSource', 'adapterTarget', 'mediaIntegration', 'mediaLyricsOnline'],
|
|
9183
|
+
// 桌宠对话(整包一个键)。**必须登记进这个对象**(`SETTINGS_NAMESPACE_NAMES` 就是它的键):
|
|
9184
|
+
// 客户端差量保存走 `PUT /settings/<ns>`,ns 不在名单里 ⇒ 宿主回 404
|
|
9185
|
+
// `unknown settings namespace` ⇒ 表现为"点保存一直失败"。
|
|
9186
|
+
petChat: ['petChat'],
|
|
9080
9187
|
};
|
|
9081
9188
|
|
|
9082
9189
|
/** 组件簇名(**只有这 7 个有路由**:`meta` 不在这张表里 ⇒ `/settings/meta` 是未知 ns ⇒ 404)。 */
|
|
@@ -18514,9 +18621,122 @@ window.__ModuleLoader__.load({
|
|
|
18514
18621
|
weT("站点上还没有桌宠。")));
|
|
18515
18622
|
}
|
|
18516
18623
|
|
|
18624
|
+
// ── 桌宠对话(/folia/pet-chat/*)────────────────────────────────────────
|
|
18625
|
+
// 放在页签底部,紧跟「显示桌宠 / 声音 / 音量 / 复位位置 / 大小」之后。
|
|
18626
|
+
children.push(React.createElement(PetChatSettings, { key: "petChat" }));
|
|
18627
|
+
|
|
18517
18628
|
return React.createElement("div", { className: "we-picker__section" }, children);
|
|
18518
18629
|
}
|
|
18519
18630
|
|
|
18631
|
+
/* ── 桌宠对话设置区 ─────────────────────────────────────────────────────── */
|
|
18632
|
+
|
|
18633
|
+
const CHAT_DEFAULTS = {
|
|
18634
|
+
provider: 'openai',
|
|
18635
|
+
baseUrl: 'https://api.deepseek.com',
|
|
18636
|
+
model: 'deepseek-chat',
|
|
18637
|
+
apiKey: '',
|
|
18638
|
+
apiKeyMasked: '',
|
|
18639
|
+
hasApiKey: false,
|
|
18640
|
+
petName: '',
|
|
18641
|
+
ownerName: '',
|
|
18642
|
+
};
|
|
18643
|
+
|
|
18644
|
+
/**
|
|
18645
|
+
* 设置页(v0.1 验收口径):**三项,无开关**。
|
|
18646
|
+
* 1) 模型 Key 2) 名字(桌宠名 = 唤醒词 + 你的称呼) 3) 音色(v0.2 占位,灰色只读)
|
|
18647
|
+
*
|
|
18648
|
+
* 为什么连"开启对话"都没有:工单要求用户不做选择 —— 填了 Key 就等于启用,
|
|
18649
|
+
* 主动搭话/记忆都是固定策略。删除任何开关,就少一次"用户要不要打开"的决策。
|
|
18650
|
+
*/
|
|
18651
|
+
function PetChatSettings() {
|
|
18652
|
+
const [draft, setDraft] = React.useState(CHAT_DEFAULTS);
|
|
18653
|
+
const [status, setStatus] = React.useState({ ok: null, text: '' });
|
|
18654
|
+
const [note, setNote] = React.useState(null);
|
|
18655
|
+
const [busy, setBusy] = React.useState(false);
|
|
18656
|
+
const update = React.useCallback((patch) => setDraft((prev) => ({ ...prev, ...patch })), []);
|
|
18657
|
+
|
|
18658
|
+
const load = React.useCallback(async () => {
|
|
18659
|
+
try {
|
|
18660
|
+
const resp = await apiJson('/pet-chat/config', { parse: 'always' });
|
|
18661
|
+
const doc = (resp && resp.data) || null;
|
|
18662
|
+
if (doc && doc.ok !== false) {
|
|
18663
|
+
setDraft({ ...CHAT_DEFAULTS, ...doc, apiKey: '' });
|
|
18664
|
+
setStatus(doc.hasApiKey
|
|
18665
|
+
? { ok: true, text: weT('已保存的 Key:{mask}', { mask: doc.apiKeyMasked || '••••' }) }
|
|
18666
|
+
: { ok: null, text: weT('还没有填 API Key') });
|
|
18667
|
+
}
|
|
18668
|
+
} catch { /* 首次加载失败不打扰 */ }
|
|
18669
|
+
}, []);
|
|
18670
|
+
React.useEffect(() => { void load(); }, [load]);
|
|
18671
|
+
|
|
18672
|
+
const save = async () => {
|
|
18673
|
+
setBusy(true);
|
|
18674
|
+
try {
|
|
18675
|
+
// 填了 Key 就启用:面板不放任何开关,语义由 Key 的有无决定
|
|
18676
|
+
const body = { ...draft, apiKey: draft.apiKey || '', enabled: Boolean(draft.apiKey) || Boolean(draft.hasApiKey) };
|
|
18677
|
+
const resp = await apiJson('/pet-chat/config', { method: 'POST', body, parse: 'always' });
|
|
18678
|
+
const doc = (resp && resp.data) || {};
|
|
18679
|
+
if (doc.saved) {
|
|
18680
|
+
setNote({ ok: true, text: weT('已保存') });
|
|
18681
|
+
await load();
|
|
18682
|
+
const state = await apiJson('/pet-chat/state', { parse: 'always' });
|
|
18683
|
+
const sdoc = (state && state.data) || {};
|
|
18684
|
+
setStatus(sdoc.reachable
|
|
18685
|
+
? { ok: true, text: weT('已连接 · {m}', { m: sdoc.model || draft.model }) }
|
|
18686
|
+
: { ok: false, text: sdoc.lastError ? weT('未连接:{e}', { e: sdoc.lastError }) : weT('已保存,但还没连上') });
|
|
18687
|
+
} else setNote({ ok: false, text: weT('保存失败') });
|
|
18688
|
+
} catch (e) {
|
|
18689
|
+
setNote({ ok: false, text: weT('保存失败:{msg}', { msg: (e && e.message) || '' }) });
|
|
18690
|
+
} finally { setBusy(false); }
|
|
18691
|
+
};
|
|
18692
|
+
|
|
18693
|
+
const row = (key, label, node) => React.createElement('label', {
|
|
18694
|
+
key, style: { display: 'flex', gap: '6px', alignItems: 'center', fontSize: '12px', margin: '4px 0' },
|
|
18695
|
+
}, weT(label), node);
|
|
18696
|
+
|
|
18697
|
+
const child = [];
|
|
18698
|
+
child.push(React.createElement('div', { key: 'title', style: { fontWeight: 600, margin: '14px 0 4px', fontSize: '13px' } }, weT('桌宠语音助手')));
|
|
18699
|
+
child.push(React.createElement('div', { key: 'hint', className: 'we-picker__hint', style: { margin: '0 0 6px' } },
|
|
18700
|
+
weT('三项就够:填 Key、起名字、选音色。主动搭话与记忆是固定策略;停止/恢复对它说一声就行。')));
|
|
18701
|
+
|
|
18702
|
+
child.push(React.createElement('div', { key: 'key', style: { display: 'flex', gap: '6px', alignItems: 'center', fontSize: '12px', margin: '4px 0' } },
|
|
18703
|
+
weT('模型 Key'),
|
|
18704
|
+
React.createElement('input', {
|
|
18705
|
+
type: 'password', value: draft.apiKey || '',
|
|
18706
|
+
placeholder: draft.hasApiKey ? (draft.apiKeyMasked || '••••••••') : weT('填 DeepSeek API Key'),
|
|
18707
|
+
disabled: busy, style: { flex: 1, minWidth: 0 },
|
|
18708
|
+
onChange: (e) => update({ apiKey: e.target.value }),
|
|
18709
|
+
}),
|
|
18710
|
+
));
|
|
18711
|
+
|
|
18712
|
+
child.push(row('name', '名字', React.createElement('input', {
|
|
18713
|
+
type: 'text', value: draft.petName || '', placeholder: weT('桌宠叫什么(也是唤醒词)'), disabled: busy,
|
|
18714
|
+
style: { flex: 1, minWidth: 0 }, onChange: (e) => update({ petName: e.target.value }),
|
|
18715
|
+
})));
|
|
18716
|
+
child.push(row('owner', '称呼', React.createElement('input', {
|
|
18717
|
+
type: 'text', value: draft.ownerName || '', placeholder: weT('它该怎么称呼你'), disabled: busy,
|
|
18718
|
+
style: { flex: 1, minWidth: 0 }, onChange: (e) => update({ ownerName: e.target.value }),
|
|
18719
|
+
})));
|
|
18720
|
+
|
|
18721
|
+
// 音色:v0.2 占位(灰色、不可改),避免用户以为现在能选
|
|
18722
|
+
child.push(row('voice', '音色', React.createElement('select', {
|
|
18723
|
+
className: 'we-picker__playlist-select', disabled: true, value: 'zh-CN-XiaoxiaoNeural',
|
|
18724
|
+
},
|
|
18725
|
+
React.createElement('option', { value: 'zh-CN-XiaoxiaoNeural' }, weT('晓晓(v0.2 可选)')),
|
|
18726
|
+
)));
|
|
18727
|
+
|
|
18728
|
+
child.push(React.createElement('div', { key: 'status', className: 'we-picker__hint', style: { margin: '6px 0', color: status.ok === false ? '#f87171' : undefined } },
|
|
18729
|
+
status.text || weT('未连接')));
|
|
18730
|
+
if (note && note.text) {
|
|
18731
|
+
child.push(React.createElement('div', { key: 'note', className: 'we-picker__hint', style: { color: note.ok ? undefined : '#f87171' } }, note.text));
|
|
18732
|
+
}
|
|
18733
|
+
child.push(React.createElement('div', { key: 'save', style: { display: 'flex', gap: '6px', marginTop: '4px' } },
|
|
18734
|
+
React.createElement('button', { type: 'button', className: 'we-picker__btn', disabled: busy, onClick: save }, weT('保存')),
|
|
18735
|
+
));
|
|
18736
|
+
|
|
18737
|
+
return React.createElement('div', { style: { ...PET_STYLE.card, marginTop: '10px' } }, child);
|
|
18738
|
+
}
|
|
18739
|
+
|
|
18520
18740
|
/** 页签组装点调用它。 */
|
|
18521
18741
|
function renderPetsTab() {
|
|
18522
18742
|
return React.createElement(PetsTabPanel, null);
|
|
@@ -20168,6 +20388,421 @@ window.__ModuleLoader__.load({
|
|
|
20168
20388
|
} catch { return () => {}; }
|
|
20169
20389
|
}
|
|
20170
20390
|
|
|
20391
|
+
// ── 内联模块:src/pet-voice-input.js —— 语音输入(宿主录音版):POST /pet-chat/record → text → /chat SSE 回填,前端不碰媒体 API(构建期注入;勿手改本段)──
|
|
20392
|
+
/**
|
|
20393
|
+
* pet-voice-input.js — 桌宠语音输入(v0.1,宿主侧录音版)。
|
|
20394
|
+
*
|
|
20395
|
+
* 为什么不在前端录:DSH 的 Electron 只放行 clipboard/notifications 权限,
|
|
20396
|
+
* 音频采集在 Electron 里被权限层拒绝且没有弹窗(工单「追加决定 3」)。所以这里**不碰任何
|
|
20397
|
+
* media API**:点一下 → 让宿主录(ffmpeg dshow)→ 拿 text → 走 SSE 逐字回气泡。
|
|
20398
|
+
*
|
|
20399
|
+
* 判据(test/verify-pet-voice.mjs)用假 postRecord/postChat 覆盖全链路与失败码。
|
|
20400
|
+
*/
|
|
20401
|
+
function petVoiceInputCreate(deps) {
|
|
20402
|
+
const options = deps || {};
|
|
20403
|
+
const postRecord = options.postRecord;
|
|
20404
|
+
const postChat = options.postChat;
|
|
20405
|
+
const onText = typeof options.onText === 'function' ? options.onText : () => {};
|
|
20406
|
+
const onError = typeof options.onError === 'function' ? options.onError : () => {};
|
|
20407
|
+
const onState = typeof options.onState === 'function' ? options.onState : () => {};
|
|
20408
|
+
|
|
20409
|
+
let active = false;
|
|
20410
|
+
|
|
20411
|
+
async function finishWithText(text) {
|
|
20412
|
+
if (!text) return;
|
|
20413
|
+
onText(text);
|
|
20414
|
+
if (typeof postChat === 'function') await postChat(text, onState);
|
|
20415
|
+
}
|
|
20416
|
+
|
|
20417
|
+
async function start() {
|
|
20418
|
+
if (active) return true;
|
|
20419
|
+
active = true;
|
|
20420
|
+
onState({ state: 'listening' });
|
|
20421
|
+
let result;
|
|
20422
|
+
try {
|
|
20423
|
+
result = await postRecord({});
|
|
20424
|
+
} catch (error) {
|
|
20425
|
+
active = false;
|
|
20426
|
+
onError({ code: (error && error.code) || 'network', message: String((error && error.message) || error) });
|
|
20427
|
+
return false;
|
|
20428
|
+
}
|
|
20429
|
+
const doc = result || {};
|
|
20430
|
+
if (doc.ok !== true) {
|
|
20431
|
+
active = false;
|
|
20432
|
+
onError({ code: doc.code || 'record-failed', message: doc.hint || '' });
|
|
20433
|
+
return false;
|
|
20434
|
+
}
|
|
20435
|
+
onState({ state: 'transcribing', text: doc.text });
|
|
20436
|
+
try {
|
|
20437
|
+
await finishWithText(String(doc.text || ''));
|
|
20438
|
+
} catch (error) {
|
|
20439
|
+
onError({ code: 'network', message: String((error && error.message) || error) });
|
|
20440
|
+
return false;
|
|
20441
|
+
} finally {
|
|
20442
|
+
active = false;
|
|
20443
|
+
onState({ state: 'idle' });
|
|
20444
|
+
}
|
|
20445
|
+
return true;
|
|
20446
|
+
}
|
|
20447
|
+
|
|
20448
|
+
function stop() { active = false; onState({ state: 'idle' }); }
|
|
20449
|
+
|
|
20450
|
+
return { start, stop, isActive: () => active };
|
|
20451
|
+
}
|
|
20452
|
+
|
|
20453
|
+
// ── 内联模块:src/pet-bubble.js —— 头顶气泡:锚定桌宠头顶、跟随位置/缩放、逐字显示、最多 6 行、朗读结束 +3s 淡出(构建期注入;勿手改本段)──
|
|
20454
|
+
/**
|
|
20455
|
+
* pet-bubble.js — 头顶气泡(v0.1 S2)。
|
|
20456
|
+
*
|
|
20457
|
+
* 与旧面板的区别:**只显示**,不承载输入框 / 历史列表 / 关闭按钮;输入走右键「打字说…」,
|
|
20458
|
+
* 语音走唤醒链路(S3)。这样做是因为旧面板把"窗口"和"助手"混在一起,
|
|
20459
|
+
* 用户点桌宠时弹出一个像聊天软件的窗口,与"桌宠在旁边说话"的产品形态冲突。
|
|
20460
|
+
*
|
|
20461
|
+
* 依赖全部注入(document / 定时器 / 锚点),这样 Node 里能用假 DOM 跑判据;
|
|
20462
|
+
* 浏览器侧由 pet-chat.js 用真实 window 构造。
|
|
20463
|
+
*/
|
|
20464
|
+
function petBubbleCreate(deps) {
|
|
20465
|
+
const options = deps || {};
|
|
20466
|
+
const doc = options.document;
|
|
20467
|
+
// 没有定时器的环境(极简 DOM 替身的冒烟测试)不能因为裸 setTimeout 直接炸:
|
|
20468
|
+
// 退化成立即执行 / 空取消,气泡仍能显示,只是没有延迟淡出。
|
|
20469
|
+
const setTimer = typeof options.setTimeout === 'function'
|
|
20470
|
+
? options.setTimeout
|
|
20471
|
+
: (typeof setTimeout === 'function' ? setTimeout : (fn) => { if (typeof fn === 'function') fn(); return 0; });
|
|
20472
|
+
const clearTimer = typeof options.clearTimeout === 'function'
|
|
20473
|
+
? options.clearTimeout
|
|
20474
|
+
: (typeof clearTimeout === 'function' ? clearTimeout : () => {});
|
|
20475
|
+
const getAnchor = typeof options.getAnchor === 'function' ? options.getAnchor : () => null;
|
|
20476
|
+
/** 最多显示几行(超出用 CSS 行钳制,见 lineClamp 样式)。 */
|
|
20477
|
+
const MAX_LINES = 6;
|
|
20478
|
+
|
|
20479
|
+
let el = null;
|
|
20480
|
+
let text = '';
|
|
20481
|
+
let visible = false;
|
|
20482
|
+
let fadeTimer = null;
|
|
20483
|
+
|
|
20484
|
+
/** 锚点 → 气泡位置:水平居中于桌宠,垂直贴在头顶上方。 */
|
|
20485
|
+
function place() {
|
|
20486
|
+
if (!el) return;
|
|
20487
|
+
const anchor = getAnchor();
|
|
20488
|
+
if (!anchor) return;
|
|
20489
|
+
const width = Number(anchor.width) || 0;
|
|
20490
|
+
const height = Number(anchor.height) || 0;
|
|
20491
|
+
const left = Math.round(Number(anchor.left || 0) + width / 2);
|
|
20492
|
+
const top = Math.round(Number(anchor.top || 0) - 8);
|
|
20493
|
+
el.style.left = `${left}px`;
|
|
20494
|
+
el.style.top = `${top}px`;
|
|
20495
|
+
// 锚点也跟着缩放:桌宠放大时气泡不要贴在旧位置
|
|
20496
|
+
el.style.transform = `translate(-50%, -100%) scale(${Number(anchor.scale) || 1})`;
|
|
20497
|
+
}
|
|
20498
|
+
|
|
20499
|
+
function ensure() {
|
|
20500
|
+
if (el || !doc || typeof doc.createElement !== 'function') return el;
|
|
20501
|
+
el = doc.createElement('div');
|
|
20502
|
+
el.className = 'we-pet-bubble';
|
|
20503
|
+
el.style.position = 'fixed';
|
|
20504
|
+
el.style.zIndex = '9999';
|
|
20505
|
+
el.style.maxWidth = '260px';
|
|
20506
|
+
el.style.padding = '8px 10px';
|
|
20507
|
+
el.style.borderRadius = '12px';
|
|
20508
|
+
el.style.background = 'rgba(24,24,28,.92)';
|
|
20509
|
+
el.style.color = '#f2f2f5';
|
|
20510
|
+
el.style.fontSize = '12px';
|
|
20511
|
+
el.style.lineHeight = '1.5';
|
|
20512
|
+
el.style.pointerEvents = 'none';
|
|
20513
|
+
el.style.opacity = '0';
|
|
20514
|
+
el.style.transition = 'opacity .18s ease';
|
|
20515
|
+
// 超过 6 行省略:气泡永远不长大到挡住桌宠
|
|
20516
|
+
el.style.display = '-webkit-box';
|
|
20517
|
+
el.style.webkitLineClamp = String(MAX_LINES);
|
|
20518
|
+
el.style.webkitBoxOrient = 'vertical';
|
|
20519
|
+
el.style.overflow = 'hidden';
|
|
20520
|
+
el.style.whiteSpace = 'pre-wrap';
|
|
20521
|
+
if (doc.body && typeof doc.body.appendChild === 'function') doc.body.appendChild(el);
|
|
20522
|
+
return el;
|
|
20523
|
+
}
|
|
20524
|
+
|
|
20525
|
+
function cancelFade() {
|
|
20526
|
+
if (fadeTimer != null) { clearTimer(fadeTimer); fadeTimer = null; }
|
|
20527
|
+
}
|
|
20528
|
+
|
|
20529
|
+
/** 显示(或继续显示)一段文本;重复调用会重排文本而不是叠出第二个气泡。 */
|
|
20530
|
+
function show(nextText) {
|
|
20531
|
+
if (!ensure()) return;
|
|
20532
|
+
cancelFade();
|
|
20533
|
+
text = String(nextText == null ? '' : nextText);
|
|
20534
|
+
el.textContent = text;
|
|
20535
|
+
el.style.opacity = '1';
|
|
20536
|
+
visible = true;
|
|
20537
|
+
place();
|
|
20538
|
+
}
|
|
20539
|
+
|
|
20540
|
+
/** 逐字/逐段追加(SSE 每个 chunk 调一次)。 */
|
|
20541
|
+
function append(chunk) {
|
|
20542
|
+
if (!ensure()) return;
|
|
20543
|
+
cancelFade();
|
|
20544
|
+
text += String(chunk == null ? '' : chunk);
|
|
20545
|
+
el.textContent = text;
|
|
20546
|
+
el.style.opacity = '1';
|
|
20547
|
+
visible = true;
|
|
20548
|
+
place();
|
|
20549
|
+
}
|
|
20550
|
+
|
|
20551
|
+
/** 隐藏;带 delay 时先挂着,到点淡出(朗读结束后 +3s 用这个)。 */
|
|
20552
|
+
function hide(delayMs) {
|
|
20553
|
+
if (!el) return;
|
|
20554
|
+
cancelFade();
|
|
20555
|
+
const delay = Number(delayMs) || 0;
|
|
20556
|
+
const doHide = () => {
|
|
20557
|
+
fadeTimer = null;
|
|
20558
|
+
el.style.opacity = '0';
|
|
20559
|
+
visible = false;
|
|
20560
|
+
};
|
|
20561
|
+
if (delay > 0) { fadeTimer = setTimer(doHide, delay); return; }
|
|
20562
|
+
doHide();
|
|
20563
|
+
}
|
|
20564
|
+
|
|
20565
|
+
/** 状态:听 / 想 / 答(客户端据此换桌宠动作、给气泡配色)。 */
|
|
20566
|
+
function setState(kind) {
|
|
20567
|
+
if (!el) return;
|
|
20568
|
+
el.dataset = el.dataset || {};
|
|
20569
|
+
el.dataset.state = String(kind || '');
|
|
20570
|
+
}
|
|
20571
|
+
|
|
20572
|
+
function isVisible() { return visible; }
|
|
20573
|
+
|
|
20574
|
+
function dispose() {
|
|
20575
|
+
cancelFade();
|
|
20576
|
+
if (el && typeof el.remove === 'function') el.remove();
|
|
20577
|
+
el = null;
|
|
20578
|
+
text = '';
|
|
20579
|
+
visible = false;
|
|
20580
|
+
}
|
|
20581
|
+
|
|
20582
|
+
return {
|
|
20583
|
+
show, append, hide, setState, place, isVisible, dispose,
|
|
20584
|
+
// 判据要读的内部状态
|
|
20585
|
+
get text() { return text; },
|
|
20586
|
+
get element() { return el; },
|
|
20587
|
+
MAX_LINES,
|
|
20588
|
+
};
|
|
20589
|
+
}
|
|
20590
|
+
|
|
20591
|
+
// ── 内联模块:src/pet-chat.js —— 桌宠语音助手客户端:点桌宠唤醒 → 气泡显示 + edge 朗读(失败回落系统音色),无面板无输入框(构建期注入;勿手改本段)──
|
|
20592
|
+
/**
|
|
20593
|
+
* pet-chat.js — 桌宠语音助手(v0.1 客户端)。
|
|
20594
|
+
*
|
|
20595
|
+
* v0.1 范围(docs/PET-V01-ACCEPTANCE.md):**语音输入 + 头顶文字气泡 + 名字/记忆 + 主动搭话**,
|
|
20596
|
+
* **不含任何朗读/TTS**(v0.2 再做)。所以这里没有 speechSynthesis、没有 /pet-chat/speak 调用。
|
|
20597
|
+
*
|
|
20598
|
+
* 交互:点桌宠 = 唤醒 → 气泡显示它的话(3 秒后淡出,点一下立刻收起)。
|
|
20599
|
+
* 没有聊天窗口:无输入框、无历史列表、无开关按钮。
|
|
20600
|
+
*/
|
|
20601
|
+
const PET_CHAT_PRESET_LINES = {
|
|
20602
|
+
greeting: [
|
|
20603
|
+
'我在呢。',
|
|
20604
|
+
'叫我就来。',
|
|
20605
|
+
'嗯?我在听。',
|
|
20606
|
+
'你回来啦。',
|
|
20607
|
+
'有我在,别急。',
|
|
20608
|
+
'今天想聊点什么?',
|
|
20609
|
+
],
|
|
20610
|
+
wallpaper: [
|
|
20611
|
+
'要不要换张壁纸?',
|
|
20612
|
+
'这张看久了,换一张吧。',
|
|
20613
|
+
'桌面有点暗,换个亮一点的?',
|
|
20614
|
+
'轮播开着,让它自己换吧。',
|
|
20615
|
+
'我给你挑一张安静的。',
|
|
20616
|
+
'这张当壁纸挺合适。',
|
|
20617
|
+
'换张清爽的,眼睛舒服点。',
|
|
20618
|
+
'需要我记住你喜欢的风格吗?',
|
|
20619
|
+
],
|
|
20620
|
+
company: [
|
|
20621
|
+
'我在这儿待着。',
|
|
20622
|
+
'忙你的,我不吵。',
|
|
20623
|
+
'要喝水吗?我提醒你。',
|
|
20624
|
+
'坐久了,起来动一动。',
|
|
20625
|
+
'累了就歇会儿。',
|
|
20626
|
+
'今天也辛苦了。',
|
|
20627
|
+
'我陪着你。',
|
|
20628
|
+
'慢慢来,不急。',
|
|
20629
|
+
],
|
|
20630
|
+
fallback: [
|
|
20631
|
+
'这个我还不会,等我学学。',
|
|
20632
|
+
'没听清,再说一次?',
|
|
20633
|
+
'换个说法试试?',
|
|
20634
|
+
'我先记下来。',
|
|
20635
|
+
'这个得你来定。',
|
|
20636
|
+
],
|
|
20637
|
+
night: [
|
|
20638
|
+
'夜深了,早点睡。',
|
|
20639
|
+
'我先安静一会儿。',
|
|
20640
|
+
'明天见。',
|
|
20641
|
+
],
|
|
20642
|
+
};
|
|
20643
|
+
|
|
20644
|
+
/** 轮流取一句预设台词(分组轮换,避免总说同一组)。 */
|
|
20645
|
+
let petChatPresetCursor = 0;
|
|
20646
|
+
const PET_CHAT_PRESET_ORDER = ['greeting', 'wallpaper', 'company', 'fallback', 'night'];
|
|
20647
|
+
function petChatPresetLine() {
|
|
20648
|
+
const group = PET_CHAT_PRESET_LINES[PET_CHAT_PRESET_ORDER[petChatPresetCursor % PET_CHAT_PRESET_ORDER.length]];
|
|
20649
|
+
petChatPresetCursor += 1;
|
|
20650
|
+
return group[Math.floor(Math.random() * group.length)];
|
|
20651
|
+
}
|
|
20652
|
+
|
|
20653
|
+
/** 头顶气泡实例:锚点取桌宠层矩形,跟随位置与缩放。 */
|
|
20654
|
+
const petBubble = petBubbleCreate({
|
|
20655
|
+
document: typeof document !== 'undefined' ? document : undefined,
|
|
20656
|
+
getAnchor: () => {
|
|
20657
|
+
try {
|
|
20658
|
+
const layer = document && document.querySelector ? document.querySelector('#we-pet-layer') : null;
|
|
20659
|
+
if (!layer || typeof layer.getBoundingClientRect !== 'function') return null;
|
|
20660
|
+
const rect = layer.getBoundingClientRect();
|
|
20661
|
+
const style = window.getComputedStyle(layer);
|
|
20662
|
+
const scale = Number(style.getPropertyValue('--we-pet-scale')) || 1;
|
|
20663
|
+
return { left: rect.left, top: rect.top, width: rect.width, height: rect.height, scale };
|
|
20664
|
+
} catch { return null; }
|
|
20665
|
+
},
|
|
20666
|
+
});
|
|
20667
|
+
|
|
20668
|
+
/** 语音输入(v0.1):前端不碰麦克风 —— 宿主用 ffmpeg 录,这里只发请求、收文本。 */
|
|
20669
|
+
const petVoiceIn = petVoiceInputCreate({
|
|
20670
|
+
postRecord: async () => {
|
|
20671
|
+
const res = await apiPostJson('/pet-chat/record', { language: 'zh' }, { parse: 'always' });
|
|
20672
|
+
return (res && res.data) || {};
|
|
20673
|
+
},
|
|
20674
|
+
postChat: async (text, onState) => {
|
|
20675
|
+
petBubble.setState('answer');
|
|
20676
|
+
const res = await apiFetch('/pet-chat/chat', {
|
|
20677
|
+
method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ text }),
|
|
20678
|
+
});
|
|
20679
|
+
const reader = res.body.getReader();
|
|
20680
|
+
const decoder = new TextDecoder();
|
|
20681
|
+
let buffer = '';
|
|
20682
|
+
for (;;) {
|
|
20683
|
+
const { value, done } = await reader.read(); // eslint-disable-line no-await-in-loop
|
|
20684
|
+
if (done) break;
|
|
20685
|
+
buffer += decoder.decode(value, { stream: true });
|
|
20686
|
+
for (;;) {
|
|
20687
|
+
const cut = buffer.indexOf('\n\n');
|
|
20688
|
+
if (cut < 0) break;
|
|
20689
|
+
const frame = buffer.slice(0, cut);
|
|
20690
|
+
buffer = buffer.slice(cut + 2);
|
|
20691
|
+
const line = frame.split('\n').find((item) => item.startsWith('data:'));
|
|
20692
|
+
if (!line) continue;
|
|
20693
|
+
let payload = null;
|
|
20694
|
+
try { payload = JSON.parse(line.slice(5).trim()); } catch { payload = null; }
|
|
20695
|
+
if (payload && typeof payload.t === 'string') petBubble.append(payload.t);
|
|
20696
|
+
}
|
|
20697
|
+
}
|
|
20698
|
+
if (typeof onState === 'function') onState({ state: 'idle' });
|
|
20699
|
+
petBubble.hide(3000);
|
|
20700
|
+
},
|
|
20701
|
+
onText: (text) => { petBubble.append(text); },
|
|
20702
|
+
onError: (error) => {
|
|
20703
|
+
// 失败一律回落打字:只给一行提示,不弹错误框
|
|
20704
|
+
const map = {
|
|
20705
|
+
'no-device': '没找到麦克风,先打字吧',
|
|
20706
|
+
'ffmpeg-missing': '缺少 ffmpeg,先打字吧',
|
|
20707
|
+
'asr-not-ready': '语音输入还没就绪:去 DSH 设置里开启(需下载模型)',
|
|
20708
|
+
timeout: '这次没听清,再说一次或直接打字',
|
|
20709
|
+
'no-speech': '没听到声音,再说一次或直接打字',
|
|
20710
|
+
network: '网络不太顺,重试或直接打字',
|
|
20711
|
+
};
|
|
20712
|
+
const message = map[error && error.code] || '没听清,直接打字也行';
|
|
20713
|
+
petBubble.show(message);
|
|
20714
|
+
petBubble.hide(3000);
|
|
20715
|
+
petChatOpenTyping({ hint: message });
|
|
20716
|
+
},
|
|
20717
|
+
});
|
|
20718
|
+
|
|
20719
|
+
/**
|
|
20720
|
+
* 打字兜底(右键 → 打字说…):一个小输入条挂在桌宠上方,回车发 /chat。
|
|
20721
|
+
* 为什么不用 window.prompt:Electron 里 prompt 返回 null,用户会以为坏了。
|
|
20722
|
+
*/
|
|
20723
|
+
function petChatOpenTyping(extra = {}) {
|
|
20724
|
+
if (typeof document === 'undefined' || !document.createElement) return;
|
|
20725
|
+
const existed = document.querySelector('#we-pet-typing');
|
|
20726
|
+
if (existed) { existed.focus(); return; }
|
|
20727
|
+
const box = document.createElement('div');
|
|
20728
|
+
box.id = 'we-pet-typing';
|
|
20729
|
+
box.style.cssText = 'position:fixed;z-index:10000;left:50%;bottom:120px;transform:translateX(-50%);'
|
|
20730
|
+
+ 'display:flex;gap:6px;background:rgba(24,24,28,.95);padding:8px;border-radius:10px;';
|
|
20731
|
+
const input = document.createElement('input');
|
|
20732
|
+
input.type = 'text';
|
|
20733
|
+
input.placeholder = (extra && extra.hint) || '打字说…(回车发送)';
|
|
20734
|
+
input.style.cssText = 'width:240px;padding:6px 8px;border-radius:8px;border:1px solid #444;background:#111;color:#eee;';
|
|
20735
|
+
const send = () => {
|
|
20736
|
+
const text = String(input.value || '').trim();
|
|
20737
|
+
if (!text) return;
|
|
20738
|
+
box.remove();
|
|
20739
|
+
petBubble.show(text);
|
|
20740
|
+
void petVoiceIn.postChat(text);
|
|
20741
|
+
};
|
|
20742
|
+
input.addEventListener('keydown', (event) => {
|
|
20743
|
+
if (event.key === 'Enter') send();
|
|
20744
|
+
if (event.key === 'Escape') box.remove();
|
|
20745
|
+
});
|
|
20746
|
+
box.appendChild(input);
|
|
20747
|
+
document.body.appendChild(box);
|
|
20748
|
+
input.focus();
|
|
20749
|
+
}
|
|
20750
|
+
|
|
20751
|
+
/** 说一句:气泡显示 + 3 秒后淡出。
|
|
20752
|
+
* v0.1 不朗读 —— 这里刻意不做音频(验收⑦:lib/ 里不允许出现 speechSynthesis)。
|
|
20753
|
+
*/
|
|
20754
|
+
function petChatSay(text) {
|
|
20755
|
+
const line = String(text || '').trim();
|
|
20756
|
+
if (!line) return;
|
|
20757
|
+
petBubble.show(line);
|
|
20758
|
+
petBubble.hide(3000);
|
|
20759
|
+
}
|
|
20760
|
+
|
|
20761
|
+
/** 点桌宠:气泡可见 ⇒ 立刻收起(同时停止录音);否则唤醒并开始听。 */
|
|
20762
|
+
function petChatWake() {
|
|
20763
|
+
if (petBubble.isVisible()) { petBubble.hide(0); petVoiceIn.stop(); return; }
|
|
20764
|
+
petBubble.setState('listen');
|
|
20765
|
+
void petVoiceIn.start().then((started) => {
|
|
20766
|
+
if (!started) return; // 失败分支已经由 onError 提示(回落打字)
|
|
20767
|
+
petBubble.show('我在听…');
|
|
20768
|
+
});
|
|
20769
|
+
}
|
|
20770
|
+
|
|
20771
|
+
/**
|
|
20772
|
+
* 常驻挂载(`WE_FEATURE_MOUNTS` 的一项):绑定点桌宠 / 快捷键。
|
|
20773
|
+
* 返回 cleanup —— 卸载时摘监听、销毁气泡。
|
|
20774
|
+
*/
|
|
20775
|
+
function mountPetChat() {
|
|
20776
|
+
if (typeof document === 'undefined' || typeof document.addEventListener !== 'function') return () => {};
|
|
20777
|
+
const onDocumentClick = (event) => {
|
|
20778
|
+
const target = event.target;
|
|
20779
|
+
if (!target || typeof target.closest !== 'function') return;
|
|
20780
|
+
if (target.closest('#we-pet-layer')) petChatWake();
|
|
20781
|
+
};
|
|
20782
|
+
const onKeyDown = (event) => {
|
|
20783
|
+
if (event.altKey && event.ctrlKey && String(event.key).toLowerCase() === 'p') {
|
|
20784
|
+
event.preventDefault();
|
|
20785
|
+
petChatWake();
|
|
20786
|
+
}
|
|
20787
|
+
};
|
|
20788
|
+
const onContextMenu = (event) => {
|
|
20789
|
+
const target = event.target;
|
|
20790
|
+
if (!target || typeof target.closest !== 'function') return;
|
|
20791
|
+
if (!target.closest('#we-pet-layer')) return;
|
|
20792
|
+
event.preventDefault();
|
|
20793
|
+
petChatOpenTyping();
|
|
20794
|
+
};
|
|
20795
|
+
document.addEventListener('contextmenu', onContextMenu, true);
|
|
20796
|
+
document.addEventListener('click', onDocumentClick, true);
|
|
20797
|
+
document.addEventListener('keydown', onKeyDown, true);
|
|
20798
|
+
return () => {
|
|
20799
|
+
document.removeEventListener('contextmenu', onContextMenu, true);
|
|
20800
|
+
document.removeEventListener('click', onDocumentClick, true);
|
|
20801
|
+
document.removeEventListener('keydown', onKeyDown, true);
|
|
20802
|
+
petBubble.dispose();
|
|
20803
|
+
};
|
|
20804
|
+
}
|
|
20805
|
+
|
|
20171
20806
|
// ── 内联模块:src/features.js —— 客户端功能注册表:页签条 / 整区面板 / 常驻挂载层。装配点(quick-panel、client.js)只查表,不写功能名(构建期注入;勿手改本段)──
|
|
20172
20807
|
/**
|
|
20173
20808
|
* features.js(客户端)— **功能注册表**:页签声明、面板工厂、挂载钩子。
|
|
@@ -20246,6 +20881,8 @@ window.__ModuleLoader__.load({
|
|
|
20246
20881
|
*/
|
|
20247
20882
|
const WE_FEATURE_MOUNTS = [
|
|
20248
20883
|
{ id: "pets", mount: mountPetLayer },
|
|
20884
|
+
// 桌宠对话的气泡层:点宠物才出现,不点就只是两条监听。
|
|
20885
|
+
{ id: "pet-chat", mount: mountPetChat },
|
|
20249
20886
|
// 皮肤兼容层:补写 `data-pane` / `data-dsh-frame`(皮肤包写的是 web-all 的 compat 词表)。
|
|
20250
20887
|
// 它只写自己的惰性属性、幂等、可失败,所以随墙纸引擎常驻,不依赖皮肤是否在台上。
|
|
20251
20888
|
{ id: "skin-compat", mount: installSkinCompat },
|