Skip to content

Commit 527a459

Browse files
authored
feat: 0.1.2-alpha.2 适配 + 六包 i18n 接入(#323 #348)
* feat(notifier): 完成风暴聚合抽为独立模块(M0 纯搬移,行为零变化,issue #366) * feat(notifier): 通知中心 service 核心——'wingsky.notifier' + Channel SPI + registerKind 待确认(M1,issue #366) - createNotifierService:统一通知管线(enabled → kind 确认 → 免打扰 → fail-soft 频道分发 → 历史落盘) - 内置事件源经 service.sendKind 收敛(NOTIFY_KINDS 文案模板语义不变,旧 boolean 判定对齐 results.ok) - 外部调用方经 service.send()(缺省广播;动态 kind 待确认前走 suppressed 落史) - Channel SPI:browser/system 两内置频道包一层 sse/system(帧契约/节流/降级不变) - cordis Context 声明合并(service.d.ts),消费方引类型 + inject 'wingsky.notifier' - ctx.provide 暴露(mcp-manager 同款 storageDomain 模式,fake ctx 静默降级) * test(notifier): 通知中心 service 契约测试——severity 映射 / send 受理 / 动态 kind 待确认 / 防冒认 / 频道路由(issue #366) * feat(notifier): 设置升级为独立 tab「通知中心」(settings.section,参照用量统计,issue #366) - client 由 settings.plugin.item 卡片迁移到 settings.section 独立顶层 tab - 不双注册(评审 B P0):旧插槽不再注入,避免设置页重复展示 - client-contract 断言同步:section 在 / plugin.item 注入不在 * feat(idle-archive): 接入通知中心——注册 idle-archive:due 动态 kind + notifyDue RPC(M1,issue #366) - 服务端探测 'wingsky.notifier'(可选增强,未装/缺服务行为不变) - apply 注册动态 kind 'idle-archive:due'(用户确认前通知自动 suppressed) - 新增 notifyDue RPC:客户端弹窗前 fire-and-forget 触发 browser/system 通知 - 客户端 scan 发现候选时调用;通知失败静默不影响弹窗主流程 * docs: dsh 0.1.2 适配计划(0.2.0 分支)——分阶段分模块适配清单(#323/#366/#348) * docs: 适配计划整合独立评审结论(P0×5/P1×5)——1.2 逻辑重设计、1.1 补 notifier/provider-usage、1.3 补降级、Phase 3 先核 t seat、Phase 4 补框架核对 * chore: 清理 6 包 dsh.client.inject 中 dsh-client-runtime 死引用(0.1.2 适配 Phase 1.1,#323) * feat(dsh-provider-usage): provider 检测迁移 0.1.2-alpha.2 投影面——modelSelection 投影优先 + modelCatalog 兜底(#323 适配 Phase 1.2) * feat(dsh-web-file-preview): openPath 收口迁移 ctx.remote.session.openWorkspacePath(0.1.2-alpha.2,适配 Phase 1.3,#323) * docs: 适配计划 1.6 评估结论——官方 alpha.2 已原生吸收子代理模型继承(#323) * chore: catalog 全量 bump 到 0.1.2-alpha.2——cordis 4.0.2 + 9 类型层包(适配 Phase 4 收口,#323) * docs: 适配计划 Phase 3 机制核实结论——官方 t seat 为 slots.register locale 参数 + LocaleNamespaceMap 合并(#348 P0-5) * feat(dsh-idle-archive): i18n 试点——双语字典 + 官方 locale 双通道接入(#348) - src/client/locales.ts:zh key 源 + en satisfies 锁平衡,双语文案覆盖弹窗/设置卡/toast - declare module 合并 LocaleNamespaceMap(官方 ui-jobs 同款模式);显式 import type 先把 ui-slots 拉进解析图绕开 TS2664(上游发布物 lib/types/*.d.ts 相对导入保留 .ts 后缀致 augmentation 模块名解析失败,microsoft/TypeScript#63960 同类,上游修复后可删) - 双通道接线:ctx.locale.register/bind(原生 DOM)+ slots.register locale: NS(React t seat); 语言切换 subscribe 重绑 t 并重绘 - tsconfig +rewriteRelativeImportExtensions(./locales.ts 后缀 emit 改写) - devDeps 仅留 ui-slots/store(纯类型面),未用 locale 类型包不引入 - smoke 补 i18n 接入哨兵断言(NS/register/bind/双语文案/locale 参数) * feat(dsh-lan-proxy): i18n 接入——设置卡双语字典 + 官方 locale 双通道(#348) - src/client/locales.ts:zh key 源 + en 全键对齐(31 键,覆盖卡片头/表单/压缩状态行/保存反馈) - declare module 合并 LocaleNamespaceMap(settings.lanProxy)+ 显式 import type ui-slots (上游发布物 .d.ts .ts 后缀缺陷 workaround,同 idle-archive) - 保存反馈重构为 msg+err 结构化状态:原 saved.indexOf("失败") 文案驱动逻辑在英文态失效 - 双通道:locale.register/bind + slots.register locale: NS;subscribe 重绑 t - smoke 中文断言更新为 i18n 接线哨兵语义(zh 字典覆盖 + t() key 断言) * feat(dsh-provider-usage): i18n 接入——胶囊/面板/设置 tab 三面双语(#348) - src/client/locales.ts:zh key 源 + en 全键对齐(69 键,覆盖胶囊 title/错误表/引导/设置 tab) - src/client/i18n.ts:多文件 client 的共享 t 活绑定(export let + bindLocale),语言切换整体重绑 - declare module 合并 LocaleNamespaceMap(providerUsage)+ 显式 import type ui-slots workaround - 模块级常量延迟求值:STATUS_LABEL→statusLabel()、PLACEMENT_OPTIONS label 存字典 key - providerBadgeText 加可选 t 参数(缺省中文不变,共享模块零 client 依赖不进宿主 bundle) - errNoApiKey 的 {PROVIDER} 字面占位经参数传值保持原文视觉(官方插值单遍替换已核实) - 引导指令(Agent prompt)不进字典;UNKNOWN_PROVIDER_HINT 常量保留(源契约断言更新为 i18n 语义) - smoke 补 i18n 接入哨兵 * feat(dsh-mcp-manager): i18n 接入——浮窗/面板/表单/设置卡四区双语(#348) - src/client/locales.ts:zh key 源 + en 全键对齐(86 键) - src/client/i18n.ts:多文件 client 共享 t 活绑定(同 provider-usage 模式) - declare module 合并 LocaleNamespaceMap(mcpManager)+ 显式 import type ui-slots workaround - constants.ts 状态文案 key 化:STATUS_TEXT 值改字典 key、STATUS_ORDER.title→titleKey (渲染期 t 求值,模块加载时不固化文案);未知状态回落原始 key 显示(数据不翻译) - placeholder 中 ${ENV} 字面引用经字典保留(官方插值缺失参数保留原样,已核实安全) - inject 加 locale;slots.register locale: NS;smoke 补 i18n 接线哨兵 * feat(dsh-web-file-preview): i18n 接入——预览 Modal/灯箱/错误态双语(#348) - src/client/locales.ts:zh key 源 + en 全键对齐(32 键,含补漏的 tab 栏/关闭/Diff 不可用) - src/client/i18n.ts:多文件 client 共享 t 活绑定(同 provider-usage 模式) - declare module 合并 LocaleNamespaceMap(filePreview)+ 显式 import type ui-slots workaround - fullscreenLabel 加可选 t 参数(缺省中文不变,纯函数四象限断言保持绿) - inject 加 locale;语言切换 subscribe 重绑(下次打开预览即生效);smoke 补 i18n 哨兵 * feat(dsh-notifier): i18n 接入——设置卡/历史列表/权限降级说明双语(#348) - src/client/locales.ts:zh key 源 + en 全键对齐(59 键,含三端降级长文案与 403 引导) - declare module 合并 LocaleNamespaceMap(notifier)+ 显式 import type ui-slots workaround - EVENT_KEYS/CHANNEL_KEYS/KIND_LABELS 三表 label 列字典 key 化(渲染期 t 求值); 未知 kind 回落 kind 本体(数据不翻译) - 保存反馈重构为 msg+err 结构化状态(原 saved.indexOf("失败") 文案驱动逻辑英文态失效) - toast.ps1 宿主端 PowerShell 固定文案按维护者拍板保留(边界文档明示) - inject 加 locale;slots.register locale: NS + label 经 t;smoke 补 i18n 接线哨兵 * docs(dsh-lan-proxy): 归档 i18n 隔离实测截图——双语设置卡 + 3082 改端口热更新(#348)
1 parent fdf8f94 commit 527a459

64 files changed

Lines changed: 3437 additions & 1162 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎docs/dsh-0.1.2-适配计划.md‎

Lines changed: 144 additions & 0 deletions
Large diffs are not rendered by default.

‎packages/dsh-codegraph/package.json‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@
6161
"@wingsky-1/dsh-mcp-manager": "workspace:*"
6262
},
6363
"peerDependencies": {
64-
"@deepseek-ai/cordis": "4.0.1",
65-
"@deepseek-ai/dsh-agent": "0.1.1-rc.2",
66-
"@deepseek-ai/dsh-llm": "0.1.1-rc.2",
67-
"@deepseek-ai/dsh-tools": "0.1.1-rc.2"
64+
"@deepseek-ai/cordis": "4.0.2",
65+
"@deepseek-ai/dsh-agent": "0.1.2-alpha.2",
66+
"@deepseek-ai/dsh-llm": "0.1.2-alpha.2",
67+
"@deepseek-ai/dsh-tools": "0.1.2-alpha.2"
6868
},
6969
"peerDependenciesMeta": {
7070
"@deepseek-ai/cordis": {

‎packages/dsh-idle-archive/package.json‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
},
2828
"client": {
2929
"inject": [
30-
"@deepseek-ai/dsh-client-runtime",
3130
"@deepseek-ai/dsh-client-connection",
3231
"@deepseek-ai/dsh-client-ui-slots"
3332
],
@@ -36,8 +35,8 @@
3635
},
3736
"peerDependencies": {
3837
"react": "^18.2.0",
39-
"@deepseek-ai/cordis": "4.0.1",
40-
"@deepseek-ai/dsh-host-webserver": "0.1.1-rc.2"
38+
"@deepseek-ai/cordis": "4.0.2",
39+
"@deepseek-ai/dsh-host-webserver": "0.1.2-alpha.2"
4140
},
4241
"peerDependenciesMeta": {
4342
"react": {
@@ -82,6 +81,8 @@
8281
},
8382
"devDependencies": {
8483
"@deepseek-ai/cordis": "catalog:",
84+
"@deepseek-ai/dsh-client-store": "catalog:",
85+
"@deepseek-ai/dsh-client-ui-slots": "catalog:",
8586
"@deepseek-ai/dsh-host-webserver": "catalog:",
8687
"schemastery": "^3.18.0"
8788
}

‎packages/dsh-idle-archive/src/client/index.ts‎

Lines changed: 89 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,38 @@
2020
import * as React from "react";
2121
// 样式:独立 style.css(见同目录),build-client 的 .css text-loader 构建期内联为字符串
2222
import STYLE from "./style.css";
23+
// i18n(issue #348):复用官方 dsh-client-locale——zh/en 双语字典,LocaleNamespaceMap
24+
// 声明合并进官方 ui-slots 类型面;仅 import type(编译期擦除,无运行时依赖)。
25+
import { zh, en, type IdleArchiveLocaleKey } from "./locales.ts";
26+
// 显式类型导入,先把 @deepseek-ai/dsh-client-ui-slots 拉进模块解析图:上游发布物
27+
// lib/types/*.d.ts 相对导入保留 .ts 后缀(renderer.ts / store.ts,磁盘只有 .d.ts),
28+
// declare module 增强的模块名解析(不走过 import 的解析缓存)会判 TS2664 cannot be
29+
// found(microsoft/TypeScript#63960 顺序依赖同类问题;TS 5.9/6/7 实测一致)。待上游
30+
// 修复发布物后此行可删。
31+
import type { LocaleNamespaceMap } from "@deepseek-ai/dsh-client-ui-slots";
32+
33+
declare module "@deepseek-ai/dsh-client-ui-slots" {
34+
interface LocaleNamespaceMap {
35+
/** dsh-idle-archive 弹窗/设置卡文案。 */
36+
"settings.idleArchive": IdleArchiveLocaleKey;
37+
}
38+
}
39+
40+
/** 本插件字典命名空间(宿主 locale 服务注册用)。 */
41+
const NS = "settings.idleArchive";
2342

2443
var CHANNEL = "/dsh-idle-archive";
2544
var MODAL_ID = "dsh-idle-archive-modal";
2645
var STYLE_ID = "dsh-idle-archive-style";
2746
var CSS_VERSION = "1";
2847
var DEFAULTS = { enabled: true, idleHours: 72, snoozeHours: 24, scanMinutes: 60, maxRows: 50 };
2948

49+
/** i18n 翻译函数(apply 时由 ctx.locale.bind(NS) 装配;未装配回落 key 本体,行为零变化)。 */
50+
var t: any = function (key: string, params?: any) {
51+
if (params === undefined) return key;
52+
return String(key); // 未装配时占位插值忽略(正常路径早已装配)
53+
};
54+
3055
/** 全局运行态(apply 内部使用)。 */
3156
var state: Record<string, any> = { settings: null, snoozed: {}, candidates: [], modalOpen: false };
3257
var rpc: any = null;
@@ -56,13 +81,13 @@ import STYLE from "./style.css";
5681
/** 相对时间描述。 */
5782
function fmtRelative(ts: any) {
5883
var diff = Date.now() - ts;
59-
if (diff < 60 * 1000) return "刚刚";
84+
if (diff < 60 * 1000) return t("justNow");
6085
var min = Math.floor(diff / 60000);
61-
if (min < 60) return min + " 分钟前";
86+
if (min < 60) return t("minutesAgo", { n: min });
6287
var h = Math.floor(min / 60);
63-
if (h < 24) return h + " 小时前";
88+
if (h < 24) return t("hoursAgo", { n: h });
6489
var d = Math.floor(h / 24);
65-
if (d < 30) return d + " 天前";
90+
if (d < 30) return t("daysAgo", { n: d });
6691
return new Date(ts).toLocaleDateString();
6792
}
6893

@@ -93,13 +118,13 @@ import STYLE from "./style.css";
93118
function doArchive(id: any) {
94119
if (!workspaces) return;
95120
(workspaces as any).archiveSession(id).then(function () {
96-
toast("已归档会话");
121+
toast(t("archivedOk"));
97122
state.candidates = state.candidates.filter(function (c: any) { return c.id !== id; });
98123
// 归档后清掉该会话的静默标记(下次扫描不会再出现,已归档者天然跳过)。
99124
rpc("clearSnooze", { sessionId: id }).catch(function () {});
100125
renderModal();
101126
}).catch(function (e: any) {
102-
toast("归档失败:" + (e && e.message || e), true);
127+
toast(t("archivedFail", { msg: (e && e.message || e) }), true);
103128
});
104129
}
105130

@@ -137,20 +162,20 @@ import STYLE from "./style.css";
137162
title.title = row.title;
138163
var time = document.createElement("div");
139164
time.className = "dia-row-time";
140-
time.textContent = "最后对话 " + fmtRelative(row.updatedAt) + "(" + new Date(row.updatedAt).toLocaleString() + ")";
165+
time.textContent = t("rowLastSeen", { rel: fmtRelative(row.updatedAt), abs: new Date(row.updatedAt).toLocaleString() });
141166
main.appendChild(title);
142167
main.appendChild(time);
143168

144169
var archiveBtn = document.createElement("button");
145170
archiveBtn.type = "button";
146171
archiveBtn.className = "dia-btn dia-btn-archive";
147-
archiveBtn.textContent = "归档";
172+
archiveBtn.textContent = t("archive");
148173
archiveBtn.addEventListener("click", function () { doArchive(row.id); });
149174

150175
var snoozeBtn = document.createElement("button");
151176
snoozeBtn.type = "button";
152177
snoozeBtn.className = "dia-btn";
153-
snoozeBtn.textContent = "暂不归档";
178+
snoozeBtn.textContent = t("snoozeRow");
154179
snoozeBtn.addEventListener("click", function () { doSnooze([row.id], (state.settings && state.settings.snoozeHours) || DEFAULTS.snoozeHours); });
155180

156181
el.appendChild(main);
@@ -178,21 +203,24 @@ import STYLE from "./style.css";
178203
var head = document.createElement("div");
179204
head.className = "dia-head";
180205
var headText = document.createElement("span");
181-
headText.textContent = "会话闲置提醒";
206+
headText.textContent = t("modalTitle");
182207
var closeBtn = document.createElement("button");
183208
closeBtn.type = "button";
184209
closeBtn.className = "dia-close";
185210
closeBtn.textContent = "×";
186-
closeBtn.title = "全部暂不归档(Y 小时内不再提醒)";
211+
closeBtn.title = t("closeTitle");
187212
closeBtn.addEventListener("click", function () { doSnooze(state.candidates.map(function (c: any) { return c.id; }), 1); });
188213
head.appendChild(headText);
189214
head.appendChild(closeBtn);
190215

191216
var hours = (state.settings && state.settings.idleHours) || DEFAULTS.idleHours;
192217
var desc = document.createElement("div");
193218
desc.className = "dia-desc";
194-
desc.textContent = "以下 " + candidates.length + " 个会话超过 " + hours + " 小时未对话。归档后从会话列表隐藏,会话记录仍保留;" +
195-
"「暂不归档」后 " + ((state.settings && state.settings.snoozeHours) || DEFAULTS.snoozeHours) + " 小时内不再提醒该会话。";
219+
desc.textContent = t("desc", {
220+
count: candidates.length,
221+
hours: hours,
222+
snooze: (state.settings && state.settings.snoozeHours) || DEFAULTS.snoozeHours,
223+
});
196224

197225
var list = document.createElement("div");
198226
list.className = "dia-list";
@@ -201,11 +229,11 @@ import STYLE from "./style.css";
201229
foot.className = "dia-foot";
202230
var hint = document.createElement("span");
203231
hint.className = "dia-hint";
204-
hint.textContent = "× / Esc:仅关闭(1 小时内不重复提醒);「全部暂不归档」:按静默时长不提醒";
232+
hint.textContent = t("hint");
205233
var allBtn = document.createElement("button");
206234
allBtn.type = "button";
207235
allBtn.className = "dia-all";
208-
allBtn.textContent = "全部暂不归档";
236+
allBtn.textContent = t("allSnooze");
209237
allBtn.addEventListener("click", function () {
210238
var hours = (state.settings && state.settings.snoozeHours) || DEFAULTS.snoozeHours;
211239
doSnooze(state.candidates.map(function (c: any) { return c.id; }), hours);
@@ -277,6 +305,15 @@ import STYLE from "./style.css";
277305
if (document.visibilityState !== "visible") return;
278306
var list = collectCandidates(false);
279307
if (!list.length) return;
308+
// 通知中心接入(issue #366 M1):弹窗前 fire-and-forget 触发 notifyDue——
309+
// 通知中心未装 / kind 未确认时服务端自动 suppressed/静默,不影响弹窗主流程。
310+
try {
311+
rpc("notifyDue", { count: list.length }).catch(function () {
312+
// 通知失败静默(弹窗照常)
313+
});
314+
} catch (error) {
315+
// rpc 初始化异常(connection 未就绪)也静默
316+
}
280317
var ids = list.map(function (c: any) { return c.id; });
281318
rpc("titles", { sessionIds: ids }).then(function (v: any) {
282319
if (disposed || state.modalOpen) return;
@@ -344,7 +381,7 @@ import STYLE from "./style.css";
344381
}, []);
345382

346383
if (!settings) {
347-
return React.createElement("li", { className: "dia-set-card" }, "会话闲置提醒:加载中…");
384+
return React.createElement("li", { className: "dia-set-card" }, t("settingsLoading"));
348385
}
349386

350387
function patch(p: any) {
@@ -356,11 +393,11 @@ import STYLE from "./style.css";
356393
rpc("config", { settings: settings }).then(function (v: any) {
357394
state.settings = v.settings;
358395
setSettings(v.settings);
359-
setSaved("已保存");
396+
setSaved(t("savedOk"));
360397
scheduleSoon();
361398
setTimeout(function () { setSaved(""); }, 1800);
362399
}).catch(function (e: any) {
363-
setSaved("保存失败:" + (e && e.message || e));
400+
setSaved(t("savedFail", { msg: (e && e.message || e) }));
364401
});
365402
}
366403

@@ -369,12 +406,12 @@ import STYLE from "./style.css";
369406
setSaved("");
370407
if (disposed || state.modalOpen) return;
371408
if (!state.settings || !state.settings.enabled) {
372-
toast("会话闲置提醒已禁用");
409+
toast(t("disabledHint"));
373410
return;
374411
}
375412
var list = collectCandidates(true);
376413
if (!list.length) {
377-
toast("暂无需要归档的会话");
414+
toast(t("noCandidates"));
378415
return;
379416
}
380417
rpc("titles", { sessionIds: list.map(function (c: any) { return c.id; }) }).then(function (v: any) {
@@ -398,8 +435,8 @@ import STYLE from "./style.css";
398435
onClick: function () { setOpen(!open); },
399436
},
400437
React.createElement("span", { className: "dia-set-headText" },
401-
React.createElement("span", { className: "dia-set-name" }, "会话闲置提醒"),
402-
React.createElement("span", { className: "dia-set-description" }, "闲置阈值 / 静默时长 / 扫描间隔 / 立即检查"),
438+
React.createElement("span", { className: "dia-set-name" }, t("settingsName")),
439+
React.createElement("span", { className: "dia-set-description" }, t("settingsDescription")),
403440
),
404441
React.createElement("svg", {
405442
className: "dia-set-chevron" + (open ? " dia-set-chevronOpen" : ""),
@@ -418,15 +455,15 @@ import STYLE from "./style.css";
418455
),
419456
open ? React.createElement("div", { className: "dia-set-body" },
420457
React.createElement("div", { className: "dia-set-row" },
421-
React.createElement("label", null, "启用"),
458+
React.createElement("label", null, t("enable")),
422459
React.createElement("input", {
423460
type: "checkbox",
424461
checked: settings.enabled,
425462
onChange: function (e: any) { patch({ enabled: e.target.checked }); },
426463
}),
427464
),
428465
React.createElement("div", { className: "dia-set-row" },
429-
React.createElement("label", null, "闲置阈值(小时)"),
466+
React.createElement("label", null, t("idleHours")),
430467
React.createElement("input", {
431468
className: "dia-set-input",
432469
type: "number",
@@ -437,7 +474,7 @@ import STYLE from "./style.css";
437474
}),
438475
),
439476
React.createElement("div", { className: "dia-set-row" },
440-
React.createElement("label", null, "拒绝后静默(小时)"),
477+
React.createElement("label", null, t("snoozeHours")),
441478
React.createElement("input", {
442479
className: "dia-set-input",
443480
type: "number",
@@ -448,7 +485,7 @@ import STYLE from "./style.css";
448485
}),
449486
),
450487
React.createElement("div", { className: "dia-set-row" },
451-
React.createElement("label", null, "扫描间隔(分钟)"),
488+
React.createElement("label", null, t("scanMinutes")),
452489
React.createElement("select", {
453490
className: "dia-set-input",
454491
value: settings.scanMinutes,
@@ -463,8 +500,8 @@ import STYLE from "./style.css";
463500
React.createElement("div", { className: "dia-set-foot" },
464501
React.createElement("span", { className: "dia-set-saved" }, saved),
465502
React.createElement("span", { style: { display: "flex", gap: 8 } },
466-
React.createElement("button", { type: "button", className: "dia-set-check", onClick: checkNow }, "立即检查"),
467-
React.createElement("button", { type: "button", className: "dia-set-save", onClick: save }, "保存"),
503+
React.createElement("button", { type: "button", className: "dia-set-check", onClick: checkNow }, t("checkNow")),
504+
React.createElement("button", { type: "button", className: "dia-set-save", onClick: save }, t("save")),
468505
),
469506
),
470507
) : null,
@@ -493,6 +530,17 @@ import STYLE from "./style.css";
493530

494531
injectStyle();
495532

533+
// i18n(issue #348):注册本插件字典;t 绑定官方 locale 服务(未装配回落 key 本体)。
534+
var locale: any = ctx.get("locale");
535+
if (locale && typeof locale.register === "function") {
536+
try {
537+
locale.register(NS, { zh: zh, en: en });
538+
t = locale.bind(NS);
539+
} catch (e) {
540+
console.warn("[dsh-idle-archive] locale 注册失败:", e);
541+
}
542+
}
543+
496544
// 先按默认配置可用,宿主状态加载后覆盖(配置/snooze 持久化在宿主)。
497545
state.settings = DEFAULTS;
498546
rpc("state", {}).then(function (st: any) {
@@ -524,14 +572,24 @@ import STYLE from "./style.css";
524572
if (slots) {
525573
slots.inject("settings.plugin.item", function () {
526574
return slots.register(
527-
{ name: "settings.plugin.item", id: "dsh-idle-archive", key: "dsh-idle-archive", order: 45 },
575+
{ name: "settings.plugin.item", id: "dsh-idle-archive", key: "dsh-idle-archive", order: 45, locale: NS },
528576
function () {
529577
return React.createElement(SettingsCard, null);
530578
}
531579
);
532580
});
533581
}
534582

583+
// i18n 切语言重绘:locale 快照变化 → 重绑 t 并重建弹窗(原生 DOM 通道按 revision 刷新)。
584+
var unsubLocale: any = null;
585+
if (locale && typeof locale.subscribe === "function" && typeof locale.getSnapshot === "function") {
586+
unsubLocale = locale.subscribe(function () {
587+
try { t = locale.bind(NS); } catch (e) { /* 忽略 */ }
588+
if (state.modalOpen) { closeModal(); state.candidates = state.candidates.slice(); }
589+
scheduleSoon();
590+
});
591+
}
592+
535593
// ⚠️ 清理必须写在 ctx.effect 返回的 disposer 里。
536594
ctx.effect(function () {
537595
return function () {
@@ -541,6 +599,7 @@ import STYLE from "./style.css";
541599
document.removeEventListener("visibilitychange", onVisibility);
542600
if (unsubSessions) unsubSessions();
543601
if (unsubWorkspaces) unsubWorkspaces();
602+
if (unsubLocale) unsubLocale();
544603
if (modalEl) modalEl.remove();
545604
var style = document.getElementById(STYLE_ID);
546605
if (style) style.remove();
@@ -552,4 +611,4 @@ import STYLE from "./style.css";
552611
}
553612

554613
// ---- 浏览器半区契约:apply/inject 由 build-client 经 factory 装配(干净模块)----
555-
export const inject: string[] = ["slots"];
614+
export const inject: string[] = ["slots", "locale"];

0 commit comments

Comments
 (0)