dsh-folia 4.26.0-pre.52 → 4.26.0-pre.53

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.
Files changed (2) hide show
  1. package/lib/client.js +80 -15
  2. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -741,6 +741,22 @@ window.__ModuleLoader__.load({
741
741
  // pre.49:桌宠页控制行最右侧的语音助手开关(点开才挂载设置块)。
742
742
  "智能大肥鱼": "Smart Chubby Fish",
743
743
  "桌宠语音助手": "Pet voice assistant",
744
+ // pre.53:朗读开关 + 音色(voice.muted / voice.name);桌宠页的音效标签同步改名。
745
+ "音色": "Voice",
746
+ "🔊 朗读回答": "🔊 Read replies aloud",
747
+ "关闭后只显示字幕、不合成语音(省算力);保存后立刻生效。":
748
+ "When off, replies are shown as subtitles only (no speech synthesis); takes effect as soon as you save.",
749
+ "填 Key、起名字、选音色,再决定要不要朗读。主动搭话与记忆是固定策略;停止/恢复对它说一声就行。":
750
+ "Fill in the key, give it a name, pick a voice, then decide whether it should read replies aloud. Proactive chat and memory are fixed behaviours; just tell it to stop or resume.",
751
+ "晓晓(女声,默认)": "Xiaoxiao (female, default)",
752
+ "晓伊(女声,活泼)": "Xiaoyi (female, lively)",
753
+ "云希(男声)": "Yunxi (male)",
754
+ "云健(男声,沉稳)": "Yunjian (male, calm)",
755
+ "已保存(朗读已关闭)": "Saved (read-aloud is off)",
756
+ "桌宠音效": "Pet sound effects",
757
+ "音效音量": "SFX volume",
758
+ "点击与动作音效;朗读回答的开关在「智能大肥鱼」页":
759
+ "Click and action sound effects; the read-aloud toggle lives in the Smart Chubby Fish section",
744
760
  "卸载": "Uninstall",
745
761
  "{cols} 列 · {size}": "{cols} cols · {size}",
746
762
  "还没有安装任何桌宠 —— 从下面的站点清单里挑一只。": "No pets installed yet — pick one from the site list below.",
@@ -18800,17 +18816,22 @@ window.__ModuleLoader__.load({
18800
18816
  }),
18801
18817
  weT("显示桌宠"),
18802
18818
  ),
18803
- React.createElement("label", { style: { display: "flex", gap: "6px", alignItems: "center", fontSize: "12px" } },
18819
+ React.createElement("label", {
18820
+ // pre.53:这里一直是**桌宠音效**(cfg.sound,见 pet-layer.js 的 petVoice),
18821
+ // 不是朗读回答。旧文案「声音」会被误解成语音朗读开关 ⇒ 明确写成「桌宠音效」。
18822
+ title: weT("点击与动作音效;朗读回答的开关在「智能大肥鱼」页"),
18823
+ style: { display: "flex", gap: "6px", alignItems: "center", fontSize: "12px" },
18824
+ },
18804
18825
  React.createElement("input", {
18805
18826
  type: "checkbox",
18806
18827
  checked: Boolean(cfg.sound),
18807
18828
  disabled: Boolean(busy),
18808
18829
  onChange: (e) => act("config", { sound: e.target.checked }, ""),
18809
18830
  }),
18810
- weT("声音"),
18831
+ weT("桌宠音效"),
18811
18832
  ),
18812
18833
  React.createElement("label", { style: { display: "flex", gap: "4px", alignItems: "center", fontSize: "12px" } },
18813
- weT("音量"),
18834
+ weT("音效音量"),
18814
18835
  React.createElement("select", {
18815
18836
  className: "we-picker__playlist-select",
18816
18837
  value: String(cfg.volume == null ? 0.6 : cfg.volume),
@@ -18998,14 +19019,23 @@ window.__ModuleLoader__.load({
18998
19019
  hasApiKey: false,
18999
19020
  petName: '',
19000
19021
  ownerName: '',
19022
+ // pre.53:朗读回答 = voice.muted 取反;音色 = voice.name(与 /pet-chat/config 同结构)。
19023
+ voice: { name: 'zh-CN-XiaoxiaoNeural', muted: false },
19001
19024
  };
19002
19025
 
19026
+ /** 固定可选的朗读音色(Edge neural;宿主 TTS 的 `preferredEngineForVoice` 会优先走 edge)。 */
19027
+ const ASSISTANT_VOICES = [
19028
+ { id: 'zh-CN-XiaoxiaoNeural', label: '晓晓(女声,默认)' },
19029
+ { id: 'zh-CN-XiaoyiNeural', label: '晓伊(女声,活泼)' },
19030
+ { id: 'zh-CN-YunxiNeural', label: '云希(男声)' },
19031
+ { id: 'zh-CN-YunjianNeural', label: '云健(男声,沉稳)' },
19032
+ ];
19033
+
19003
19034
  /**
19004
- * 设置页(v0.1 验收口径):**三项,无开关**。
19005
- * 1) 模型 Key 2) 名字(桌宠名 = 唤醒词 + 你的称呼) 3) 音色(v0.2 占位,灰色只读)
19035
+ * 设置页:模型 Key / 名字 / 称呼 / 音色 / **朗读回答开关** / 保存。
19006
19036
  *
19007
- * 为什么连"开启对话"都没有:工单要求用户不做选择 —— 填了 Key 就等于启用,
19008
- * 主动搭话/记忆都是固定策略。删除任何开关,就少一次"用户要不要打开"的决策。
19037
+ * 朗读开关是 pre.53 补的:对应 `voice.muted`(旧版只有默认不静音,没有界面入口)。
19038
+ * 关闭后只出字幕、不合成语音(客户端 petTts 在 `speak()` 入口直接跳过,省算力)。
19009
19039
  */
19010
19040
  /** apiJson 的返回是 { ok, status, data },而 /pet-chat/* 的 data 里还套一层 { ok, data }。
19011
19041
  * 各调用点各写一遍「多解一层」就是 P1 那个"保存成功却显示保存失败"的来源 —— 统一到这里解。 */
@@ -19025,7 +19055,9 @@ window.__ModuleLoader__.load({
19025
19055
  const resp = await apiJson('/pet-chat/config', { parse: 'always' });
19026
19056
  const doc = unwrapPetChat(resp);
19027
19057
  if (doc && doc.ok !== false) {
19028
- setDraft({ ...CHAT_DEFAULTS, ...doc, apiKey: '' });
19058
+ // voice 是嵌套对象:缺字段时补默认,避免 draft.voice 变 undefined 后开关读不了。
19059
+ const voice = Object.assign({}, CHAT_DEFAULTS.voice, (doc && doc.voice && typeof doc.voice === 'object') ? doc.voice : {});
19060
+ setDraft({ ...CHAT_DEFAULTS, ...doc, voice, apiKey: '' });
19029
19061
  setStatus(doc.hasApiKey
19030
19062
  ? { ok: true, text: weT('已保存的 Key:{mask}', { mask: doc.apiKeyMasked || '••••' }) }
19031
19063
  : { ok: null, text: weT('还没有填 API Key') });
@@ -19043,14 +19075,25 @@ window.__ModuleLoader__.load({
19043
19075
  const save = async () => {
19044
19076
  setBusy(true);
19045
19077
  try {
19046
- // 填了 Key 就启用:面板不放任何开关,语义由 Key 的有无决定
19047
- const body = { ...draft, apiKey: draft.apiKey || '', enabled: Boolean(draft.apiKey) || Boolean(draft.hasApiKey) };
19078
+ // 填了 Key 就启用:面板不放"开启对话"开关,语义由 Key 的有无决定。
19079
+ // pre.53:voice 必须显式带上(宿主保存时会整体替换 voice 对象)。
19080
+ const voice = Object.assign({}, CHAT_DEFAULTS.voice, draft.voice || {});
19081
+ const body = {
19082
+ ...draft, voice,
19083
+ apiKey: draft.apiKey || '',
19084
+ enabled: Boolean(draft.apiKey) || Boolean(draft.hasApiKey),
19085
+ };
19048
19086
  // ⚠️ 必须用 apiPostJson:apiJson 只拼 URL,不做 JSON.stringify,
19049
19087
  // 传对象会被浏览器发成 "[object Object]" ⇒ 宿主回 400 bad-json ⇒ 界面永远"保存失败"。
19050
19088
  const resp = await apiPostJson('/pet-chat/config', body, { parse: 'always' });
19051
19089
  const doc = unwrapPetChat(resp);
19052
19090
  if (doc.saved) {
19053
- setNote({ ok: true, text: weT('已保存') });
19091
+ // pre.53:保存后**立刻**生效 —— 静音时停掉正在念的那句,并刷新客户端缓存的 voice。
19092
+ if (voice.muted === true) {
19093
+ try { petSpeakStop(); } catch { /* 朗读是增强:停不下来也不能影响保存 */ }
19094
+ }
19095
+ try { void petChatRefreshVoice(); } catch { /* 刷新失败下次唤醒会再读 */ }
19096
+ setNote({ ok: true, text: voice.muted === true ? weT('已保存(朗读已关闭)') : weT('已保存') });
19054
19097
  await load();
19055
19098
  const state = await apiJson('/pet-chat/state', { parse: 'always' });
19056
19099
  const sdoc = unwrapPetChat(state);
@@ -19068,9 +19111,11 @@ window.__ModuleLoader__.load({
19068
19111
  }, weT(label), node);
19069
19112
 
19070
19113
  const child = [];
19114
+ const voice = Object.assign({}, CHAT_DEFAULTS.voice, draft.voice || {});
19115
+ const voiceOn = voice.muted !== true;
19071
19116
  child.push(React.createElement('div', { key: 'title', style: { fontWeight: 600, margin: '14px 0 4px', fontSize: '13px' } }, weT('桌宠语音助手')));
19072
19117
  child.push(React.createElement('div', { key: 'hint', className: 'we-picker__hint', style: { margin: '0 0 6px' } },
19073
- weT('三项就够:填 Key、起名字、选音色。主动搭话与记忆是固定策略;停止/恢复对它说一声就行。')));
19118
+ weT('填 Key、起名字、选音色,再决定要不要朗读。主动搭话与记忆是固定策略;停止/恢复对它说一声就行。')));
19074
19119
 
19075
19120
  child.push(React.createElement('div', { key: 'key', style: { display: 'flex', gap: '6px', alignItems: 'center', fontSize: '12px', margin: '4px 0' } },
19076
19121
  weT('模型 Key'),
@@ -19091,11 +19136,31 @@ window.__ModuleLoader__.load({
19091
19136
  style: { flex: 1, minWidth: 0 }, onChange: (e) => update({ ownerName: e.target.value }),
19092
19137
  })));
19093
19138
 
19094
- // 音色:v0.2 占位(灰色、不可改),避免用户以为现在能选
19139
+ // pre.53:朗读开关 = voice.muted 取反。关闭后只出字幕、不合成语音(客户端入口直接跳过)。
19140
+ child.push(React.createElement('label', {
19141
+ key: 'speak-toggle',
19142
+ style: { display: 'flex', gap: '6px', alignItems: 'center', fontSize: '12px', margin: '6px 0 2px' },
19143
+ },
19144
+ React.createElement('input', {
19145
+ type: 'checkbox',
19146
+ checked: voiceOn,
19147
+ disabled: busy,
19148
+ onChange: (e) => update({ voice: Object.assign({}, voice, { muted: !e.target.checked }) }),
19149
+ }),
19150
+ weT('🔊 朗读回答'),
19151
+ ));
19152
+ child.push(React.createElement('div', {
19153
+ key: 'speak-hint', className: 'we-picker__hint', style: { margin: '0 0 4px' },
19154
+ }, weT('关闭后只显示字幕、不合成语音(省算力);保存后立刻生效。')));
19155
+
19156
+ // 音色:voice.name。宿主保存时整体替换 voice 对象,所以 muted 在这里一并带上。
19095
19157
  child.push(row('voice', '音色', React.createElement('select', {
19096
- className: 'we-picker__playlist-select', disabled: true, value: 'zh-CN-XiaoxiaoNeural',
19158
+ className: 'we-picker__playlist-select',
19159
+ disabled: busy,
19160
+ value: voice.name || CHAT_DEFAULTS.voice.name,
19161
+ onChange: (e) => update({ voice: Object.assign({}, voice, { name: e.target.value }) }),
19097
19162
  },
19098
- React.createElement('option', { value: 'zh-CN-XiaoxiaoNeural' }, weT('晓晓(v0.2 可选)')),
19163
+ ...ASSISTANT_VOICES.map((v) => React.createElement('option', { key: v.id, value: v.id }, weT(v.label))),
19099
19164
  )));
19100
19165
 
19101
19166
  child.push(React.createElement('div', { key: 'status', className: 'we-picker__hint', style: { margin: '6px 0', color: status.ok === false ? '#f87171' : undefined } },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-folia",
3
3
  "displayName": "Folia · 壁纸引擎与桌宠",
4
- "version": "4.26.0-pre.52",
4
+ "version": "4.26.0-pre.53",
5
5
  "description": "DSH 壁纸引擎:本机 WE 壁纸实时渲染,视频/网页/开机动画/桌宠皮肤,一键拉取在线素材。",
6
6
  "type": "module",
7
7
  "engines": {