source-code-mgmt 1.8.0 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -59,13 +59,14 @@ window.__ModuleLoader__.load({
59
59
  };
60
60
 
61
61
  // ---------- fetch helpers ----------
62
+ // 每个请求都带上当前语言(?lang=zh|en),host 端据此返回对应语言的错误/结果消息。
62
63
  async function jget(path) {
63
- const res = await fetch(API + path);
64
+ const res = await fetch(API + path + (path.indexOf("?") >= 0 ? "&" : "?") + "lang=" + currentLang());
64
65
  if (!res.ok) throw new Error("HTTP " + String(res.status));
65
66
  return await res.json();
66
67
  }
67
68
  async function jpost(path, body) {
68
- const res = await fetch(API + path, {
69
+ const res = await fetch(API + path + (path.indexOf("?") >= 0 ? "&" : "?") + "lang=" + currentLang(), {
69
70
  method: "POST",
70
71
  headers: { "content-type": "application/json" },
71
72
  body: JSON.stringify(body || {}),
@@ -177,6 +178,31 @@ window.__ModuleLoader__.load({
177
178
  // ---------- small presentational bits ----------
178
179
  const h = React.createElement;
179
180
 
181
+ // ---------- i18n: follows DSH’s language setting (Settings → General → Language), live ----------
182
+ const EN_DICT = {"展开":"Expand","折叠":"Collapse","展开该部分":"Expand this section","折叠该部分":"Collapse this section","已安装":"Installed","❌ 未安装":"❌ Not installed","复制安装命令":"Copy install command","一键安装(会自动选包管理器)":"Install automatically (picks a package manager)","安装中…":"Installing…","安装":"Install"," 执行成功":" executed successfully","(如未生效需以管理员身份重试)":" (retry as administrator if it did not take effect)","安装失败":"Install failed","① 环境检查":"① Environment","✅ 均存在":"✅ All present","操作系统":"OS","已找到":"Found","检测中":"Checking","失败: ":"Failed: ","未找到的工具可用上方「安装」按钮一键安装(":"Missing tools can be installed with the \"Install\" button above (","Windows 用 winget / 内置功能":"winget / built-in features on Windows","用系统包管理器":"your system package manager",",可能需管理员权限);也可手动复制安装命令执行,安装后点「重新检查」。":"; admin rights may be required). You can also copy the install command and run it manually, then click \"Re-check\".","重新检查":"Re-check",":已存在,无需重复操作":": already exists, no need to repeat","成功":" succeeded","失败":" failed","失败:":"Failed: ","平台":"Platform","选择代码托管平台:GitHub 或 Gitee(默认 GitHub),③代码管理会跟随切换":"Choose the code hosting platform: GitHub or Gitee (GitHub default); step ③ follows this switch","GitHub(默认)":"GitHub (default)","② SSH 密钥与连接":"② SSH Key & Connection","密钥":"Key"," 已生成":" generated","⚠️ 未生成":"⚠️ Not generated","GH 登录":"GH login","已登录":"Logged in","⚠️ 未登录":"⚠️ Not logged in","SSH 配置":"SSH config"," 已配置(443)":" configured (443)","⚠️ 未配置/限制 22 端口需配置":"⚠️ Not configured / port 22 blocked — use 443","生成密钥":"Generate key","配置 SSH(config)":"Configure SSH config","配置 SSH":"Configure SSH","测试连接":"Test connection","SSH 连接成功(":"SSH connection succeeded (","已认证":"authenticated","连接失败,请确认密钥已上传到 ":"Connection failed. Make sure the key is uploaded to "," 或已登录 gh":" or that gh is logged in","测试失败:":"Test failed: ","公钥(复制上传到 ":"Public key (copy and upload to ","Gitee → 设置 → SSH 公钥":"Gitee → Settings → SSH keys",",或运行 gh auth login 自动上传):":", or run gh auth login to upload it automatically):","该目录不是 git 仓库":"This folder is not a git repository","读取令牌状态失败:":"Failed to read token status: ","已保存 Gitee 令牌(账号:":"Gitee token saved (account: ","保存令牌失败":"Failed to save token","保存令牌失败:":"Failed to save token: ","已清除 Gitee 令牌":"Gitee token cleared","清除失败":"Clear failed","清除令牌失败:":"Failed to clear token: ","已推送":"Pushed","推送失败":"Push failed","推送失败:":"Push failed: ","已拉取远程更新(本地已对齐到远程最新状态)":"Pulled remote updates (local is now aligned with the latest remote state)","拉取失败":"Pull failed","拉取失败:":"Pull failed: ","已拉取远程更新并推送更改":"Pulled remote updates and pushed changes","合并推送失败":"Merge-push failed","合并推送失败:":"Merge-push failed: ","强制推送会用本地版本覆盖远程仓库,远程上非本地的更改将被丢弃。确定继续?":"Force-push overwrites the remote repo with your local version; remote-only changes will be lost. Continue?","已强制推送,远程已更新为本地状态":"Force-pushed; the remote is now your local state","强制推送失败":"Force-push failed","强制推送失败:":"Force-push failed: ","强制拉取会把远程更新并入本地。如果本地有不想保留的内容,将按冲突处理或遗失。确定继续?":"Force-pull merges remote updates into local; anything you don't want kept may conflict or be lost. Continue?","已强制拉取远程更新":"Force-pulled remote updates","强制拉取失败":"Force-pull failed","强制拉取失败:":"Force-pull failed: ","请先加载一个有效的文件夹":"Load a valid folder first","确定把仓库 ":"Change repo "," 改为「":" visibility to「","公开":"Public","私有":"Private","」?修改可见性可能影响 Star、关注者等。":"」? Changing visibility may affect stars, watchers, etc.","已把仓库设置为「":"Repo set to「","修改可见性失败":"Failed to change visibility","修改可见性失败:":"Failed to change visibility: ","仓库已创建并推送:":"Repo created and pushed: ","创建失败":"Create failed","创建失败:":"Create failed: ","未选择目录":"No folder selected","选择失败:":"Selection failed: ","请输入或选择目录路径":"Enter or pick a folder path","添加目录失败":"Failed to add folder","添加目录失败:":"Failed to add folder: ","删除失败":"Delete failed","删除失败:":"Delete failed: ","强制对齐会用远程分支覆盖本地(丢弃本地未推送的更改与提交),确定继续?":"Force-align overwrites local with the remote branch (drops unpushed local changes and commits). Continue?","已强制对齐到远程分支":"Force-aligned to the remote branch","强制对齐失败":"Force-align failed","强制对齐失败:":"Force-align failed: ","已是 git 仓库":"Already a git repository","已创建 git 仓库,请自行拉取或推送":"Git repository created — pull or push as you wish","创建 git 失败":"Failed to init git","创建 git 失败:":"Failed to init git: ","暂存失败":"Stage failed","暂存失败:":"Stage failed: ","取消暂存失败":"Unstage failed","取消暂存失败:":"Unstage failed: ","已提交 ":"Committed "," 个文件":" file(s)","提交失败":"Commit failed","提交失败:":"Commit failed: ","已提交「":"Committed「","(自动生成)":" (auto-generated)","」并推送":"」 and pushed","已推送本地已有的提交":"Pushed existing local commits","读取分支失败":"Failed to load branches","读取分支失败:":"Failed to load branches: ","切换到分支「":"Switch to branch「","」?(若当前有未提交改动,git 会拒绝切换)":"」? (git will refuse if you have uncommitted changes)","已切换到分支 ":"Switched to branch ","切换分支失败":"Failed to switch branch","切换分支失败:":"Failed to switch branch: ","读取历史失败":"Failed to load history","读取历史失败:":"Failed to load history: ","revert 提交「":"Revert commit「","」——会生成一个反向提交,期间可能产生冲突,确定继续?":"」 — this creates a reverse commit and may cause conflicts. Continue?","已 revert 提交 ":"Reverted commit ","revert 失败":"Revert failed","revert 失败:":"Revert failed: ","cherry-pick 提交「":"Cherry-pick commit「","」到当前分支——期间可能产生冲突,确定继续?":"」 onto the current branch — this may cause conflicts. Continue?","已 cherry-pick 提交 ":"Cherry-picked commit ","cherry-pick 失败":"Cherry-pick failed","cherry-pick 失败:":"Cherry-pick failed: ","读取失败":"Failed to load","已复制":"Copied","短哈希":"short hash","完整哈希":"full hash","提交信息":"commit message","复制失败:请手动复制":"Copy failed — copy it manually","③ 代码管理":"③ Code Management","Gitee 私人令牌(OpenAPI,需 projects 权限)":"Gitee personal token (OpenAPI, requires projects permission)","✅ 已配置":"✅ Configured","(账号 ":" (account ","清除令牌":"Clear token","粘贴 Gitee 私人令牌(https://gitee.com/personal_access_tokens)":"Paste the Gitee personal token (https://gitee.com/personal_access_tokens)","保存令牌":"Save token","令牌只保存在本机 ~/.dsh/storages(0600),不会写进插件目录;需勾选个人令牌的 projects 权限。公钥需已上传到 Gitee(② 里检查)。":"The token is stored only on this machine at ~/.dsh/storages (0600), never in the plugin directory; the personal token must have projects permission. Your public key must be uploaded to Gitee (checked in ②).","选择工作区":"Workspace","选择 DSH 已登记的工作区文件夹":"Choose a workspace folder registered in DSH","(暂无可选工作区)":"(no workspaces available)","— 请选择 —":"— Select —","选择目录":"Choose folder","自定义目录:":"Custom folder: ","删除该目录记录":"Remove this folder entry","删除该目录记录(不删除实际文件夹)":"Remove this folder entry (does not delete the actual folder)","目录":"Folder","分支":"Branch","(无)":"(none)","切换分支":"Switch branch","切换":"Switch","查看提交历史":"View commit history","历史":"History","远程":"Remote","改动":"Changes","无":"None","查看改动的文件列表":"View the list of changed files","查看":"View","同步":"Sync","本地领先 ":"Ahead by "," 提交":" commit(s)","、落后 ":", behind by ","落后 ":"behind by ","与远程一致":"Up to date with remote","查看本地与远程的提交差异":"View commit differences between local and remote","⚠️ 以下 ":"⚠️ The following "," 项 >100MB(超过 GitHub 限制,推送时将自动忽略不上传):":" item(s) >100MB (over GitHub's limit — auto-ignored on push):","/(整个文件夹)":"/ (entire folder)","创建 Git":"Init Git","仅初始化 git 仓库,不拉取不推送,由你决定下一步":"Initializes a git repo only — no pull/push; you decide the next step","本地有改动且远程有更新,可直接用「强制对齐」将本地重置为远程状态":"You have local changes AND remote updates — use \"Force align\" to reset local to the remote state","强制对齐":"Force align","本地完全重置为远程分支(丢弃本地差异),解决“文件相同仍显示同步差异”的情况":"Fully resets local to the remote branch (drops local differences); fixes \"files identical but sync still shows a difference\"","推送更改":"Push changes","拉取更新":"Pull updates","✓ 已是最新":"✓ Up to date","⟳ 正在刷新状态,联网同步 GitHub/Gitee 最新数据…":"⟳ Refreshing status — syncing the latest GitHub/Gitee data…","⟳ 切换平台,正在重新检测「":"⟳ Switching platform, re-checking「","」仓库状态…":"」 repo status…","推送中…":"Pushing…","推送暂存":"Push staged","把已暂存的内容用填写的(或自动生成的)信息提交后推送到远程;不会自动暂存其他未暂存的改动":"Commits only what is staged (with your message, or auto-generated) and pushes it; does not auto-stage other changes","刷新中…":"Refreshing…","刷新状态":"Refresh status","提交信息(留空则用默认)":"Commit message (default if empty)","填写提交信息后点「提交」;留空则自动生成(chore: update <文件夹名>)":"Type a message then click \"Commit\"; leave empty to auto-generate (chore: update <folder>)","提交":"Commit","仓库名称自动取文件夹名(不可修改)":"Repo name is taken from the folder name (read-only)","(未加载文件夹)":"(no folder loaded)","仓库可见性:私有 / 公开":"Repo visibility: private / public","(修改当前仓库的可见性)":" (changes the current repo's visibility)","新建仓库并推送":"Create repo & push","修改仓库状态":"Change repo status","✓ 仓库已是「":"✓ Repo is already「","」状态,如需修改请调整左侧可见性选择。":"」 — to change it, adjust the visibility dropdown.","将把仓库从「":"Will change the repo from「","」改为「":"」 to「","」,点击「修改仓库状态」执行。":"」 — click \"Change repo status\" to apply.","⚠️ 同名仓库已经创建(无法读取当前可见性,可能未":"⚠️ A repo with this name already exists (couldn't read its visibility — maybe not ","配置 Gitee 令牌":"Gitee token configured","登录 gh":"logged into gh","✓ 同名仓库 ":"✓ No repo named "," 不存在,可在 ":" exists — you can create it on ","「新建仓库并推送」创建(可选私有/公开)。":" with \"Create repo & push\" (private or public).","已忽略未上传(":"Skipped uploads ("," 项 >100MB):":" item(s) >100MB):","已提交":"Committed"," 并推送":" and pushed","(推送省略)":" (push skipped)","查看详情":"View details","改动文件":"Changed files","提交历史":"Commit history","与远程同步差异":"Sync differences vs remote","关闭":"Close","已安装 dsh-better-sidebar,此处只列改动文件列表;具体改动内容请到 dsh-better-sidebar 的「源代码管理 / Git 面板」查看。":"dsh-better-sidebar is installed — this lists changed files only; see the actual changes in its \"Source Control / Git\" panel.","点击收起":"Click to collapse","点击查看改动内容":"Click to view the diff","新文件(untracked)暂无内容 diff":"New (untracked) file — no diff yet","已暂存":"Staged","未暂存":"Unstaged","取消暂存":"Unstage","暂存":"Stage","加载中…":"Loading…","▾ 收起":"▾ Collapse","▸ 查看":"▸ View","正在加载改动内容…":"Loading changes…","(无内容差异)":"(no diff)","当前没有改动。":"No changes.","正在读取分支…":"Loading branches…","(无分支)":"(no branches)","(当前)":"(current)","正在读取历史…":"Loading history…","(暂无提交)":"(no commits)","更多操作(右键也可打开)":"More actions (right-click also works)","查看提交差异":"View commit diff","复制短哈希":"Copy short hash","复制完整哈希":"Copy full hash","复制提交信息":"Copy commit message","还原此提交":"Revert this commit","拾取此提交":"Cherry-pick this commit","正在加载提交 diff…":"Loading commit diff…","本地落后 ":"Behind by "," 个提交(远程有而本地没有):":" commit(s) (on remote, not local):"," 个提交(本地有而远程没有):":" commit(s) (on local, not remote):","✓ 已与远程同步,无差异。":"✓ In sync with remote — no differences.","选择代码目录":"Choose a code folder","可手动输入/粘贴目录绝对路径,或点击「浏览…」弹出本地文件夹选择器。确认后将添加到下方下拉并记住,下次打开无需重新选择。":"Paste an absolute folder path, or click \"Browse…\" for the native picker. Confirmed folders are added to the dropdown and remembered.","C:\\Users\\你的用户名\\项目目录":"C:\\Users\\your-name\\project","浏览…":"Browse…","取消":"Cancel","确定":"OK","新增":"Added","删除":"Deleted","重命名":"Renamed","修改":"Modified","旧版本":"Old","新版本":"New","源代码管理":"Source Control","按顺序完成:①环境检查 → ②SSH 密钥与连接 → ③代码管理。推送会自动忽略 >100MB 的文件(":"Work through in order: ① Environment → ② SSH Key & Connection → ③ Code Management. Files over 100MB are auto-ignored on push ("," 限制)并说明原因。":" limit) with the reason shown.","代码管理":"Code Management","拖动调整面板宽度":"Drag to resize the panel"};
183
+ let scmLang = (() => { try { return String(navigator.language || "zh").toLowerCase().split("-")[0] === "en" ? "en" : "zh" } catch { return "zh" } })();
184
+ let scmLocaleFace = null; // ctx.locale (the DSH LocaleRuntime), set in apply()
185
+ function currentLang() { try { if (scmLocaleFace && typeof scmLocaleFace.getLocale === "function") return scmLocaleFace.getLocale().active } catch {} return scmLang }
186
+ function t(key, params) {
187
+ let s = key;
188
+ try { if (currentLang() === "en") s = EN_DICT[key] ?? key } catch {}
189
+ if (params && params.length) { let i = 0; s = String(s).replace(/\$\{\}/g, () => String(params[i++] ?? "")) }
190
+ return s
191
+ }
192
+ /** Re-render the subtree when DSH switches language (subscribe to the LocaleRuntime).
193
+ * 依赖 scmLocaleFace:若 client-locale 晚于本插件激活、捕获发生在组件挂载之后,
194
+ * effect 会重跑并补上订阅;订阅后立即重渲染一次,晚捕获时立刻用上当前语言。 */
195
+ function useLocale() {
196
+ const [, force] = useState(0);
197
+ useEffect(() => {
198
+ if (!scmLocaleFace || typeof scmLocaleFace.subscribe !== "function") return;
199
+ const off = scmLocaleFace.subscribe(() => force((n) => n + 1));
200
+ force((n) => n + 1);
201
+ return off;
202
+ }, [scmLocaleFace]);
203
+ }
204
+
205
+
180
206
  function Field({ label, value, children }) {
181
207
  return h("div", { style: { display: "flex", alignItems: "center", gap: 8, marginBottom: 6 } },
182
208
  h("span", { style: { color: T.secondary, fontSize: 13, width: 84, flexShrink: 0 } }, label),
@@ -227,8 +253,8 @@ window.__ModuleLoader__.load({
227
253
  canCollapse ? h("span", { style: { flex: 1 } }) : null,
228
254
  canCollapse ? h("button", {
229
255
  type: "button",
230
- title: collapsed ? "展开" : "折叠",
231
- "aria-label": collapsed ? "展开该部分" : "折叠该部分",
256
+ title: collapsed ? t("展开") : t("折叠"),
257
+ "aria-label": collapsed ? t("展开该部分") : t("折叠该部分"),
232
258
  onClick: () => setCollapsed(!collapsed),
233
259
  style: collapseBtnStyle(),
234
260
  }, collapsed ? "▸" : "▾") : null
@@ -292,16 +318,16 @@ window.__ModuleLoader__.load({
292
318
  const toolRow = (tool, label, installed, version) => {
293
319
  const hint = INSTALL_HINTS[tool] || ""
294
320
  const status = installed
295
- ? h("span", { style: { color: T.label, fontSize: 13 } }, "✅ " + (version || "已安装"))
321
+ ? h("span", { style: { color: T.label, fontSize: 13 } }, "✅ " + (version || t("已安装")))
296
322
  : h("span", { style: { display: "inline-flex", alignItems: "center", gap: 8 } },
297
- h("span", { style: { color: T.danger, fontSize: 13 } }, "❌ 未安装"),
298
- h("button", { type: "button", title: "复制安装命令", disabled: installing !== null, style: changeBtnStyle(), onClick: (e) => { e.stopPropagation(); void copyText(hint); } }, "复制安装命令"),
299
- h("button", { type: "button", title: "一键安装(会自动选包管理器)", disabled: installing !== null, style: { ...changeBtnStyle(), color: T.brand, fontWeight: 600 }, onClick: (e) => { e.stopPropagation(); void doInstall(tool); } }, installing === tool ? "安装中…" : "安装")
323
+ h("span", { style: { color: T.danger, fontSize: 13 } }, t("❌ 未安装")),
324
+ h("button", { type: "button", title: t("复制安装命令"), disabled: installing !== null, style: changeBtnStyle(), onClick: (e) => { e.stopPropagation(); void copyText(hint); } }, t("复制安装命令")),
325
+ h("button", { type: "button", title: t("一键安装(会自动选包管理器)"), disabled: installing !== null, style: { ...changeBtnStyle(), color: T.brand, fontWeight: 600 }, onClick: (e) => { e.stopPropagation(); void doInstall(tool); } }, installing === tool ? t("安装中…") : t("安装"))
300
326
  )
301
327
  const feedback = installResult && installResult.tool === tool
302
328
  ? (installResult.ok
303
- ? h("div", { style: { marginTop: 4, color: T.success, fontSize: 12 } }, "✅ " + (installResult.command || "已安装") + " 执行成功" + (installResult.needElevation ? "(如未生效需以管理员身份重试)" : ""))
304
- : h("div", { style: { marginTop: 4, color: T.danger, fontSize: 12 } }, "❌ " + (installResult.error || "安装失败") + (installResult.command ? ":" + installResult.command : "")))
329
+ ? h("div", { style: { marginTop: 4, color: T.success, fontSize: 12 } }, "✅ " + (installResult.command || t("已安装")) + t(" 执行成功") + (installResult.needElevation ? t("(如未生效需以管理员身份重试)") : ""))
330
+ : h("div", { style: { marginTop: 4, color: T.danger, fontSize: 12 } }, "❌ " + (installResult.error || t("安装失败")) + (installResult.command ? ":" + installResult.command : "")))
305
331
  : null
306
332
  return h("div", { key: tool, style: { marginTop: 4 } },
307
333
  h(Field, { label }, status),
@@ -309,16 +335,16 @@ window.__ModuleLoader__.load({
309
335
  )
310
336
  }
311
337
 
312
- return h(Box, { title: "① 环境检查", badge: allPresent ? "✅ 均存在" : null, defaultCollapsed: !!allPresent },
313
- h(Field, { label: "操作系统" }, h("span", { style: { color: T.label, fontSize: 13 } }, env ? (env.platformLabel || env.platform) : "...")),
338
+ return h(Box, { title: t("① 环境检查"), badge: allPresent ? t("✅ 均存在") : null, defaultCollapsed: !!allPresent },
339
+ h(Field, { label: t("操作系统") }, h("span", { style: { color: T.label, fontSize: 13 } }, env ? (env.platformLabel || env.platform) : "...")),
314
340
  env ? h(React.Fragment, null,
315
341
  toolRow("git", "Git", env.git.installed, env.git.version),
316
342
  toolRow("gh", "GitHub CLI", env.gh.installed, env.gh.version),
317
- toolRow("ssh", "SSH", !!(env.ssh && env.ssh.installed), env.ssh && env.ssh.installed ? "已找到" : null)
318
- ) : h(Field, { label: "检测中", value: err ? "失败: " + err : "…" }),
343
+ toolRow("ssh", "SSH", !!(env.ssh && env.ssh.installed), env.ssh && env.ssh.installed ? t("已找到") : null)
344
+ ) : h(Field, { label: t("检测中"), value: err ? t("失败: ") + err : "…" }),
319
345
  (!env || !env.git.installed || !env.gh.installed || !(env.ssh && env.ssh.installed)) ? h("div", { style: { marginTop: 8, fontSize: 12, color: T.secondary, lineHeight: 1.6 } },
320
- "未找到的工具可用上方「安装」按钮一键安装(" + (winOs ? "Windows 用 winget / 内置功能" : "用系统包管理器") + ",可能需管理员权限);也可手动复制安装命令执行,安装后点「重新检查」。"
321
- ) : h(Btn, { label: "重新检查", onClick: load, tone: "ghost" })
346
+ t("未找到的工具可用上方「安装」按钮一键安装(") + (winOs ? t("Windows 用 winget / 内置功能") : t("用系统包管理器")) + t(",可能需管理员权限);也可手动复制安装命令执行,安装后点「重新检查」。")
347
+ ) : h(Btn, { label: t("重新检查"), onClick: load, tone: "ghost" })
322
348
  );
323
349
  }
324
350
 
@@ -346,11 +372,11 @@ window.__ModuleLoader__.load({
346
372
  setBusy(true); setMsg(null); setErr(null);
347
373
  try {
348
374
  const r = await jpost(path, payload);
349
- if (r.alreadyExists || r.alreadyConfigured) setMsg(label + ":已存在,无需重复操作");
350
- else if (r.ok) setMsg(label + "成功");
351
- else setErr(r.error || label + "失败");
375
+ if (r.alreadyExists || r.alreadyConfigured) setMsg(label + t(":已存在,无需重复操作"));
376
+ else if (r.ok) setMsg(label + t("成功"));
377
+ else setErr(r.error || label + t("失败"));
352
378
  void load();
353
- } catch (e) { setErr(label + "失败:" + e); }
379
+ } catch (e) { setErr(label + t("失败:") + e); }
354
380
  finally { setBusy(false); }
355
381
  }, [load]);
356
382
 
@@ -362,52 +388,52 @@ window.__ModuleLoader__.load({
362
388
 
363
389
  // 标题行的平台切换下拉:折叠时也可见、可交互;切换后自动展开(要做配置)。
364
390
  const titleExtra = h("span", { style: { display: "inline-flex", alignItems: "center", gap: 6, flexShrink: 0 } },
365
- h("span", { style: { fontSize: 12, color: T.secondary } }, "平台"),
391
+ h("span", { style: { fontSize: 12, color: T.secondary } }, t("平台")),
366
392
  h("select", {
367
393
  value: prov,
368
394
  onChange: (e) => { setProv(e.target.value); setCollapsed(false); },
369
- title: "选择代码托管平台:GitHub 或 Gitee(默认 GitHub),③代码管理会跟随切换",
395
+ title: t("选择代码托管平台:GitHub 或 Gitee(默认 GitHub),③代码管理会跟随切换"),
370
396
  style: { font: "inherit", fontSize: 12, padding: "3px 6px", border: "1px solid " + T.border, borderRadius: 6, background: T.layer1, color: T.label, outline: "none", cursor: "pointer" },
371
397
  },
372
- h("option", { value: "github" }, "GitHub(默认)"),
398
+ h("option", { value: "github" }, t("GitHub(默认)")),
373
399
  h("option", { value: "gitee" }, "Gitee"),
374
400
  )
375
401
  );
376
402
 
377
403
  return h(Box, {
378
- title: "② SSH 密钥与连接",
404
+ title: t("② SSH 密钥与连接"),
379
405
  defaultCollapsed: true,
380
406
  collapsed,
381
407
  onToggle: (v) => setCollapsed(v),
382
408
  titleExtra,
383
409
  },
384
410
  // key status(显示实际检测到的密钥名,可能不是 id_ed25519)
385
- h(Field, { label: "密钥" }, h("span", { style: { color: T.label, fontSize: 13 } },
386
- ssh ? (ssh.hasKey ? "✅ " + (ssh.keyBase || "id_ed25519") + " 已生成" : "⚠️ 未生成") : "…")
411
+ h(Field, { label: t("密钥") }, h("span", { style: { color: T.label, fontSize: 13 } },
412
+ ssh ? (ssh.hasKey ? "✅ " + (ssh.keyBase || "id_ed25519") + t(" 已生成") : t("⚠️ 未生成")) : "…")
387
413
  ),
388
- h(Field, { label: "GH 登录" }, h("span", { style: { color: T.label, fontSize: 13 } },
389
- ssh ? (ssh.ghLoggedIn ? "✅ " + (ssh.ghAccount || "已登录") : "⚠️ 未登录") : "…")
414
+ h(Field, { label: t("GH 登录") }, h("span", { style: { color: T.label, fontSize: 13 } },
415
+ ssh ? (ssh.ghLoggedIn ? "✅ " + (ssh.ghAccount || t("已登录")) : t("⚠️ 未登录")) : "…")
390
416
  ),
391
- h(Field, { label: "SSH 配置" }, h("span", { style: { color: T.label, fontSize: 13 } },
392
- ssh ? (providerConfigured ? "✅ " + providerHost + " 已配置(443)" : "⚠️ 未配置/限制 22 端口需配置") : "…")
417
+ h(Field, { label: t("SSH 配置") }, h("span", { style: { color: T.label, fontSize: 13 } },
418
+ ssh ? (providerConfigured ? "✅ " + providerHost + t(" 已配置(443)") : t("⚠️ 未配置/限制 22 端口需配置")) : "…")
393
419
  ),
394
420
 
395
421
  h("div", { style: { display: "flex", gap: 8, flexWrap: "wrap", marginTop: 10 } },
396
- h(Btn, { label: "生成密钥", onClick: () => act("/gen-key", "生成密钥"), disabled: busy }),
397
- h(Btn, { label: "配置 SSH(config)", onClick: () => act("/write-config", "配置 SSH", { provider: prov }), disabled: busy }),
398
- h(Btn, { label: "测试连接", onClick: async () => {
422
+ h(Btn, { label: t("生成密钥"), onClick: () => act("/gen-key", t("生成密钥")), disabled: busy }),
423
+ h(Btn, { label: t("配置 SSH(config)"), onClick: () => act("/write-config", t("配置 SSH"), { provider: prov }), disabled: busy }),
424
+ h(Btn, { label: t("测试连接"), onClick: async () => {
399
425
  setBusy(true); setErr(null); setMsg(null);
400
426
  try {
401
427
  const r = await jpost("/ssh-test", { provider: prov });
402
- if (r.connected) setMsg("SSH 连接成功(" + (prov === "gitee" ? "Gitee" : "GitHub") + "):" + (r.account ? "Hi " + r.account : "已认证"));
403
- else setErr("连接失败,请确认密钥已上传到 " + (prov === "gitee" ? "Gitee" : "GitHub") + " 或已登录 gh");
428
+ if (r.connected) setMsg(t("SSH 连接成功(") + (prov === "gitee" ? "Gitee" : "GitHub") + "):" + (r.account ? "Hi " + r.account : t("已认证")));
429
+ else setErr(t("连接失败,请确认密钥已上传到 ") + (prov === "gitee" ? "Gitee" : "GitHub") + t(" 或已登录 gh"));
404
430
  void load();
405
- } catch (e) { setErr("测试失败:" + e); }
431
+ } catch (e) { setErr(t("测试失败:") + e); }
406
432
  finally { setBusy(false); }
407
433
  }, tone: "primary", noBg: true, disabled: busy }),
408
434
  ),
409
435
  ssh && ssh.pubContent ? h("div", { style: { marginTop: 10 } },
410
- h("div", { style: { color: T.secondary, fontSize: 12, marginBottom: 4 } }, "公钥(复制上传到 " + (prov === "gitee" ? "Gitee → 设置 → SSH 公钥" : "GitHub → Settings → SSH keys") + ",或运行 gh auth login 自动上传):"),
436
+ h("div", { style: { color: T.secondary, fontSize: 12, marginBottom: 4 } }, t("公钥(复制上传到 ") + (prov === "gitee" ? t("Gitee → 设置 → SSH 公钥") : "GitHub → Settings → SSH keys") + t(",或运行 gh auth login 自动上传):")),
411
437
  h("code", { style: { display: "block", whiteSpace: "pre-wrap", wordBreak: "break-all", fontSize: 11, lineHeight: 1.5, color: T.secondary, background: T.layer1, padding: 10, borderRadius: 8 } }, ssh.pubContent)
412
438
  ) : null,
413
439
  msg ? h("div", { style: { marginTop: 10, color: T.success, fontSize: 13 } }, "✅ " + msg) : null,
@@ -539,7 +565,7 @@ window.__ModuleLoader__.load({
539
565
  // 先清掉上次残留的缓存(文件集刚可能变化),再并发拉取。
540
566
  clearDiffCache(r && r.dir);
541
567
  if (!hasBetterSidebar) void prefetchDiffs(r && r.dir, r && r.changedFiles, 3);
542
- if (r && !r.isGitRepo) setErr(r.error || "该目录不是 git 仓库");
568
+ if (r && !r.isGitRepo) setErr(r.error || t("该目录不是 git 仓库"));
543
569
  } catch (e) { setErr(String(e)); }
544
570
  finally {
545
571
  // 只有本次是最新调用时才收起「刷新中…」提示,避免旧请求失败把提示提前关掉。
@@ -575,7 +601,7 @@ window.__ModuleLoader__.load({
575
601
  setGiteeOwnerName(r.owner || "");
576
602
  setGiteeTokenMsg(null);
577
603
  setGiteeTokenErr(null);
578
- } catch (e) { setGiteeConfigured(false); setGiteeTokenErr("读取令牌状态失败:" + e); }
604
+ } catch (e) { setGiteeConfigured(false); setGiteeTokenErr(t("读取令牌状态失败:") + e); }
579
605
  }, []);
580
606
 
581
607
  const saveGiteeToken = useCallback(async () => {
@@ -586,14 +612,14 @@ window.__ModuleLoader__.load({
586
612
  setGiteeConfigured(true);
587
613
  setGiteeOwnerName(r.owner || "");
588
614
  setGiteeToken("");
589
- setGiteeTokenMsg("已保存 Gitee 令牌(账号:" + (r.owner || "?") + ")");
615
+ setGiteeTokenMsg(t("已保存 Gitee 令牌(账号:") + (r.owner || "?") + ")");
590
616
  // 令牌就绪后刷新仓库,让同名检测等按 Gitee 生效
591
617
  loadRepo(dir || cache.defDir || "", true, true);
592
618
  } else {
593
619
  setGiteeConfigured(false);
594
- setGiteeTokenErr(r.error || "保存令牌失败");
620
+ setGiteeTokenErr(r.error || t("保存令牌失败"));
595
621
  }
596
- } catch (e) { setGiteeConfigured(false); setGiteeTokenErr("保存令牌失败:" + e); }
622
+ } catch (e) { setGiteeConfigured(false); setGiteeTokenErr(t("保存令牌失败:") + e); }
597
623
  finally { setGiteeTokenBusy(false); }
598
624
  }, [giteeToken, dir, loadRepo]);
599
625
 
@@ -604,9 +630,9 @@ window.__ModuleLoader__.load({
604
630
  setGiteeConfigured(false);
605
631
  setGiteeOwnerName("");
606
632
  setGiteeToken("");
607
- setGiteeTokenMsg(r.ok ? "已清除 Gitee 令牌" : "清除失败");
633
+ setGiteeTokenMsg(r.ok ? t("已清除 Gitee 令牌") : t("清除失败"));
608
634
  loadRepo(dir || cache.defDir || "", true, true);
609
- } catch (e) { setGiteeTokenErr("清除令牌失败:" + e); }
635
+ } catch (e) { setGiteeTokenErr(t("清除令牌失败:") + e); }
610
636
  finally { setGiteeTokenBusy(false); }
611
637
  }, [dir, loadRepo]);
612
638
 
@@ -628,10 +654,10 @@ window.__ModuleLoader__.load({
628
654
  try {
629
655
  const r = await jpost("/push", { dir: dir || undefined });
630
656
  setResult(r);
631
- if (r.ok) setMsg("已推送");
632
- else setErr(r.error || r.pushError || "推送失败");
657
+ if (r.ok) setMsg(t("已推送"));
658
+ else setErr(r.error || r.pushError || t("推送失败"));
633
659
  void loadRepo(dir, true, true);
634
- } catch (e) { setErr("推送失败:" + e); }
660
+ } catch (e) { setErr(t("推送失败:") + e); }
635
661
  finally { setBusy(false); }
636
662
  }, [dir, loadRepo]);
637
663
 
@@ -644,10 +670,10 @@ window.__ModuleLoader__.load({
644
670
  try {
645
671
  const r = await jpost("/align", { dir: dir || undefined });
646
672
  setResult(r);
647
- if (r.ok) setMsg("已拉取远程更新(本地已对齐到远程最新状态)");
648
- else setErr(r.error || "拉取失败");
673
+ if (r.ok) setMsg(t("已拉取远程更新(本地已对齐到远程最新状态)"));
674
+ else setErr(r.error || t("拉取失败"));
649
675
  void loadRepo(dir, true, true);
650
- } catch (e) { setErr("拉取失败:" + e); }
676
+ } catch (e) { setErr(t("拉取失败:") + e); }
651
677
  finally { setBusy(false); }
652
678
  }, [dir, loadRepo]);
653
679
 
@@ -656,66 +682,66 @@ window.__ModuleLoader__.load({
656
682
  try {
657
683
  const r = await jpost("/merge-push", { dir: dir || undefined });
658
684
  setResult(r);
659
- if (r.ok) setMsg("已拉取远程更新并推送更改");
660
- else setErr(r.error || "合并推送失败");
685
+ if (r.ok) setMsg(t("已拉取远程更新并推送更改"));
686
+ else setErr(r.error || t("合并推送失败"));
661
687
  void loadRepo(dir, true, true);
662
- } catch (e) { setErr("合并推送失败:" + e); }
688
+ } catch (e) { setErr(t("合并推送失败:") + e); }
663
689
  finally { setBusy(false); }
664
690
  }, [dir, loadRepo]);
665
691
 
666
692
  const forcePush = useCallback(async () => {
667
- if (!window.confirm("强制推送会用本地版本覆盖远程仓库,远程上非本地的更改将被丢弃。确定继续?")) return;
693
+ if (!window.confirm(t("强制推送会用本地版本覆盖远程仓库,远程上非本地的更改将被丢弃。确定继续?"))) return;
668
694
  setBusy(true); setMsg(null); setErr(null); setResult(null);
669
695
  try {
670
696
  const r = await jpost("/force-push", { dir: dir || undefined });
671
697
  setResult(r);
672
- if (r.ok) setMsg("已强制推送,远程已更新为本地状态");
673
- else setErr(r.error || "强制推送失败");
698
+ if (r.ok) setMsg(t("已强制推送,远程已更新为本地状态"));
699
+ else setErr(r.error || t("强制推送失败"));
674
700
  void loadRepo(dir, true, true);
675
- } catch (e) { setErr("强制推送失败:" + e); }
701
+ } catch (e) { setErr(t("强制推送失败:") + e); }
676
702
  finally { setBusy(false); }
677
703
  }, [dir, loadRepo]);
678
704
 
679
705
  const forcePull = useCallback(async () => {
680
- if (!window.confirm("强制拉取会把远程更新并入本地。如果本地有不想保留的内容,将按冲突处理或遗失。确定继续?")) return;
706
+ if (!window.confirm(t("强制拉取会把远程更新并入本地。如果本地有不想保留的内容,将按冲突处理或遗失。确定继续?"))) return;
681
707
  setBusy(true); setMsg(null); setErr(null); setResult(null);
682
708
  try {
683
709
  const r = await jpost("/force-pull", { dir: dir || undefined });
684
710
  setResult(r);
685
- if (r.ok) setMsg("已强制拉取远程更新");
686
- else setErr(r.error || "强制拉取失败");
711
+ if (r.ok) setMsg(t("已强制拉取远程更新"));
712
+ else setErr(r.error || t("强制拉取失败"));
687
713
  void loadRepo(dir, true, true);
688
- } catch (e) { setErr("强制拉取失败:" + e); }
714
+ } catch (e) { setErr(t("强制拉取失败:") + e); }
689
715
  finally { setBusy(false); }
690
716
  }, [dir, loadRepo]);
691
717
 
692
718
  const changeVisibility = useCallback(async () => {
693
719
  const name = (repo && repo.defaultRepoName) || "";
694
- if (!name) { setErr("请先加载一个有效的文件夹"); return; }
720
+ if (!name) { setErr(t("请先加载一个有效的文件夹")); return; }
695
721
  const target = visibility === "public" ? "public" : "private";
696
- if (!window.confirm("确定把仓库 " + name + " 改为「" + (target === "public" ? "公开" : "私有") + "」?修改可见性可能影响 Star、关注者等。")) return;
722
+ if (!window.confirm(t("确定把仓库 ") + name + t(" 改为「") + (target === "public" ? t("公开") : t("私有")) + t("」?修改可见性可能影响 Star、关注者等。"))) return;
697
723
  setBusy(true); setMsg(null); setErr(null); setResult(null);
698
724
  try {
699
725
  const r = await jpost("/set-visibility", { dir: dir || undefined, name, visibility: target, provider: provRef.current || "github" });
700
726
  setResult(r);
701
- if (r.ok) setMsg("已把仓库设置为「" + (target === "public" ? "公开" : "私有") + "」");
702
- else setErr(r.error || "修改可见性失败");
727
+ if (r.ok) setMsg(t("已把仓库设置为「") + (target === "public" ? t("公开") : t("私有")) + "」");
728
+ else setErr(r.error || t("修改可见性失败"));
703
729
  void loadRepo(dir, true, true);
704
- } catch (e) { setErr("修改可见性失败:" + e); }
730
+ } catch (e) { setErr(t("修改可见性失败:") + e); }
705
731
  finally { setBusy(false); }
706
732
  }, [dir, repo, visibility, loadRepo]);
707
733
 
708
734
  const create = useCallback(async () => {
709
735
  const name = (repo && repo.defaultRepoName) || "";
710
- if (!name) { setErr("请先加载一个有效的文件夹"); return; }
736
+ if (!name) { setErr(t("请先加载一个有效的文件夹")); return; }
711
737
  setBusy(true); setMsg(null); setErr(null); setResult(null);
712
738
  try {
713
739
  const r = await jpost("/create", { dir: dir || undefined, name, visibility, provider: provRef.current || "github" });
714
740
  setResult(r);
715
- if (r.ok) setMsg("仓库已创建并推送:" + (r.url || name) + (r.provider === "gitee" ? "(Gitee)" : ""));
716
- else setErr(r.error || "创建失败");
741
+ if (r.ok) setMsg(t("仓库已创建并推送:") + (r.url || name) + (r.provider === "gitee" ? "(Gitee)" : ""));
742
+ else setErr(r.error || t("创建失败"));
717
743
  void loadRepo(dir, true, true);
718
- } catch (e) { setErr("创建失败:" + e); }
744
+ } catch (e) { setErr(t("创建失败:") + e); }
719
745
  finally { setBusy(false); }
720
746
  }, [dir, repo, visibility, loadRepo]);
721
747
 
@@ -732,15 +758,15 @@ window.__ModuleLoader__.load({
732
758
  try {
733
759
  const r = await jpost("/pick-dir", { initial: pickPath || cache.defDir || undefined });
734
760
  if (r.ok && r.dir) setPickPath(r.dir);
735
- else setPickErr(r.error || "未选择目录");
736
- } catch (e) { setPickErr("选择失败:" + e); }
761
+ else setPickErr(r.error || t("未选择目录"));
762
+ } catch (e) { setPickErr(t("选择失败:") + e); }
737
763
  finally { setPicking(false); }
738
764
  }, [pickPath]);
739
765
 
740
766
  // 确认:持久化加入列表 + 加载
741
767
  const confirmPick = useCallback(async () => {
742
768
  const path = String(pickPath || "").trim();
743
- if (!path) { setPickErr("请输入或选择目录路径"); return; }
769
+ if (!path) { setPickErr(t("请输入或选择目录路径")); return; }
744
770
  setPicking(true); setPickErr(null);
745
771
  try {
746
772
  const r = await jpost("/add-workspace", { dir: path });
@@ -754,9 +780,9 @@ window.__ModuleLoader__.load({
754
780
  setPickOpen(false);
755
781
  loadRepo(r.dir, true, true);
756
782
  } else {
757
- setPickErr(r.error || "添加目录失败");
783
+ setPickErr(r.error || t("添加目录失败"));
758
784
  }
759
- } catch (e) { setPickErr("添加目录失败:" + e); }
785
+ } catch (e) { setPickErr(t("添加目录失败:") + e); }
760
786
  finally { setPicking(false); }
761
787
  }, [pickPath, loadRepo]);
762
788
 
@@ -781,23 +807,23 @@ window.__ModuleLoader__.load({
781
807
  if (next) loadRepo(next, true, true); else setRepo(null);
782
808
  }
783
809
  } else {
784
- setErr(r.error || "删除失败");
810
+ setErr(r.error || t("删除失败"));
785
811
  }
786
- } catch (e) { setErr("删除失败:" + e); }
812
+ } catch (e) { setErr(t("删除失败:") + e); }
787
813
  finally { setBusy(false); }
788
814
  }, [dir, loadRepo]);
789
815
 
790
816
  // 强制对齐:本地完全重置为远程分支状态(丢弃本地差异)
791
817
  const align = useCallback(async () => {
792
- if (!window.confirm("强制对齐会用远程分支覆盖本地(丢弃本地未推送的更改与提交),确定继续?")) return;
818
+ if (!window.confirm(t("强制对齐会用远程分支覆盖本地(丢弃本地未推送的更改与提交),确定继续?"))) return;
793
819
  setBusy(true); setMsg(null); setErr(null); setResult(null);
794
820
  try {
795
821
  const r = await jpost("/align", { dir: dir || undefined });
796
822
  setResult(r);
797
- if (r.ok) setMsg("已强制对齐到远程分支");
798
- else setErr(r.error || "强制对齐失败");
823
+ if (r.ok) setMsg(t("已强制对齐到远程分支"));
824
+ else setErr(r.error || t("强制对齐失败"));
799
825
  void loadRepo(dir, true, true);
800
- } catch (e) { setErr("强制对齐失败:" + e); }
826
+ } catch (e) { setErr(t("强制对齐失败:") + e); }
801
827
  finally { setBusy(false); }
802
828
  }, [dir, loadRepo]);
803
829
 
@@ -807,10 +833,10 @@ window.__ModuleLoader__.load({
807
833
  try {
808
834
  const r = await jpost("/init-git", { dir: dir || undefined });
809
835
  setResult(r);
810
- if (r.ok) setMsg(r.alreadyRepo ? "已是 git 仓库" : "已创建 git 仓库,请自行拉取或推送");
811
- else setErr(r.error || "创建 git 失败");
836
+ if (r.ok) setMsg(r.alreadyRepo ? t("已是 git 仓库") : t("已创建 git 仓库,请自行拉取或推送"));
837
+ else setErr(r.error || t("创建 git 失败"));
812
838
  void loadRepo(dir, true, true);
813
- } catch (e) { setErr("创建 git 失败:" + e); }
839
+ } catch (e) { setErr(t("创建 git 失败:") + e); }
814
840
  finally { setBusy(false); }
815
841
  }, [dir, loadRepo]);
816
842
 
@@ -826,8 +852,8 @@ window.__ModuleLoader__.load({
826
852
  // 重新拉取最新 repo(含最新「已暂存/未暂存」标记),并清 diff 展开状态。
827
853
  if (dir) delete cache.reposByDir[dir];
828
854
  loadRepo(dir, true, true);
829
- } else setErr(r.error || "暂存失败");
830
- } catch (e) { setErr("暂存失败:" + e); }
855
+ } else setErr(r.error || t("暂存失败"));
856
+ } catch (e) { setErr(t("暂存失败:") + e); }
831
857
  finally { setStageBusy(false); }
832
858
  }, [dir, loadRepo]);
833
859
 
@@ -839,8 +865,8 @@ window.__ModuleLoader__.load({
839
865
  if (r.ok) {
840
866
  if (dir) delete cache.reposByDir[dir];
841
867
  loadRepo(dir, true, true);
842
- } else setErr(r.error || "取消暂存失败");
843
- } catch (e) { setErr("取消暂存失败:" + e); }
868
+ } else setErr(r.error || t("取消暂存失败"));
869
+ } catch (e) { setErr(t("取消暂存失败:") + e); }
844
870
  finally { setStageBusy(false); }
845
871
  }, [dir, loadRepo]);
846
872
 
@@ -853,11 +879,11 @@ window.__ModuleLoader__.load({
853
879
  const r = await jpost("/commit", { dir: dir || undefined, message });
854
880
  setResult(r);
855
881
  if (r.ok) {
856
- setMsg("已提交 " + r.staged + " 个文件" + (r.hash ? "(" + r.hash + ")" : ""));
882
+ setMsg(t("已提交 ") + r.staged + t(" 个文件") + (r.hash ? "(" + r.hash + ")" : ""));
857
883
  setCommitMsg("");
858
884
  void loadRepo(dir, true, true);
859
- } else setErr(r.error || "提交失败");
860
- } catch (e) { setErr("提交失败:" + e); }
885
+ } else setErr(r.error || t("提交失败"));
886
+ } catch (e) { setErr(t("提交失败:") + e); }
861
887
  finally { setBusy(false); }
862
888
  }, [dir, repo, commitMsg, repoName, loadRepo]);
863
889
 
@@ -870,14 +896,14 @@ window.__ModuleLoader__.load({
870
896
  setResult(r);
871
897
  if (r.ok) {
872
898
  const info = r.committed
873
- ? "已提交「" + (r.message || "(自动生成)") + "」并推送" + (r.commitHash ? "(" + r.commitHash + ")" : "")
874
- : "已推送本地已有的提交";
899
+ ? t("已提交「") + (r.message || t("(自动生成)")) + t("」并推送") + (r.commitHash ? "(" + r.commitHash + ")" : "")
900
+ : t("已推送本地已有的提交");
875
901
  setMsg(info);
876
902
  setCommitMsg("");
877
- } else setErr(r.error || r.pushError || "推送失败");
903
+ } else setErr(r.error || r.pushError || t("推送失败"));
878
904
  // 推送成功后刷新状态(full 联网同步,显示「刷新中…」)。
879
905
  void loadRepo(dir, true, true);
880
- } catch (e) { setErr("推送失败:" + e); }
906
+ } catch (e) { setErr(t("推送失败:") + e); }
881
907
  finally { setPushStagedBusy(false); }
882
908
  }, [dir, commitMsg, loadRepo]);
883
909
 
@@ -887,24 +913,24 @@ window.__ModuleLoader__.load({
887
913
  try {
888
914
  const r = await jpost("/branches", { dir: dir || undefined });
889
915
  if (r.ok) { setBranches(r.branches || []); setBranchCurrent(r.current || ""); }
890
- else setErr(r.error || "读取分支失败");
891
- } catch (e) { setErr("读取分支失败:" + e); }
916
+ else setErr(r.error || t("读取分支失败"));
917
+ } catch (e) { setErr(t("读取分支失败:") + e); }
892
918
  finally { setBranchBusy(false); }
893
919
  }, [dir]);
894
920
 
895
921
  // 切换到某分支。
896
922
  const doCheckout = useCallback(async (branch) => {
897
923
  if (branch === branchCurrent) { setDetail(null); return; }
898
- if (!window.confirm("切换到分支「" + branch + "」?(若当前有未提交改动,git 会拒绝切换)")) return;
924
+ if (!window.confirm(t("切换到分支「") + branch + t("」?(若当前有未提交改动,git 会拒绝切换)"))) return;
899
925
  setBranchBusy(true); setMsg(null); setErr(null);
900
926
  try {
901
927
  const r = await jpost("/checkout", { dir: dir || undefined, branch });
902
928
  if (r.ok) {
903
- setMsg("已切换到分支 " + branch);
929
+ setMsg(t("已切换到分支 ") + branch);
904
930
  setDetail(null);
905
931
  void loadRepo(dir, true, true);
906
- } else setErr(r.error || "切换分支失败");
907
- } catch (e) { setErr("切换分支失败:" + e); }
932
+ } else setErr(r.error || t("切换分支失败"));
933
+ } catch (e) { setErr(t("切换分支失败:") + e); }
908
934
  finally { setBranchBusy(false); }
909
935
  }, [dir, branchCurrent, loadRepo]);
910
936
 
@@ -914,38 +940,38 @@ window.__ModuleLoader__.load({
914
940
  try {
915
941
  const r = await jpost("/log", { dir: dir || undefined, count: 30 });
916
942
  if (r.ok) setCommits(r.commits || []);
917
- else setErr(r.error || "读取历史失败");
918
- } catch (e) { setErr("读取历史失败:" + e); }
943
+ else setErr(r.error || t("读取历史失败"));
944
+ } catch (e) { setErr(t("读取历史失败:") + e); }
919
945
  finally { setCommitsLoading(false); }
920
946
  }, [dir]);
921
947
 
922
948
  // 对某提交执行 revert(改写历史,需确认)。
923
949
  const doRevert = useCallback(async (hash, subject) => {
924
- if (!window.confirm("revert 提交「" + (subject || hash) + "」——会生成一个反向提交,期间可能产生冲突,确定继续?")) return;
950
+ if (!window.confirm(t("revert 提交「") + (subject || hash) + t("」——会生成一个反向提交,期间可能产生冲突,确定继续?"))) return;
925
951
  setHistoryBusy(true); setMsg(null); setErr(null);
926
952
  try {
927
953
  const r = await jpost("/revert", { dir: dir || undefined, hash });
928
954
  if (r.ok) {
929
- setMsg("已 revert 提交 " + hash);
955
+ setMsg(t("已 revert 提交 ") + hash);
930
956
  setDetail(null);
931
957
  void loadRepo(dir, true, true);
932
- } else setErr(r.error || "revert 失败");
933
- } catch (e) { setErr("revert 失败:" + e); }
958
+ } else setErr(r.error || t("revert 失败"));
959
+ } catch (e) { setErr(t("revert 失败:") + e); }
934
960
  finally { setHistoryBusy(false); }
935
961
  }, [dir, loadRepo]);
936
962
 
937
963
  // 对某提交执行 cherry-pick(改写历史,需确认)。
938
964
  const doCherryPick = useCallback(async (hash, subject) => {
939
- if (!window.confirm("cherry-pick 提交「" + (subject || hash) + "」到当前分支——期间可能产生冲突,确定继续?")) return;
965
+ if (!window.confirm(t("cherry-pick 提交「") + (subject || hash) + t("」到当前分支——期间可能产生冲突,确定继续?"))) return;
940
966
  setHistoryBusy(true); setMsg(null); setErr(null);
941
967
  try {
942
968
  const r = await jpost("/cherrypick", { dir: dir || undefined, hash });
943
969
  if (r.ok) {
944
- setMsg("已 cherry-pick 提交 " + hash);
970
+ setMsg(t("已 cherry-pick 提交 ") + hash);
945
971
  setDetail(null);
946
972
  void loadRepo(dir, true, true);
947
- } else setErr(r.error || "cherry-pick 失败");
948
- } catch (e) { setErr("cherry-pick 失败:" + e); }
973
+ } else setErr(r.error || t("cherry-pick 失败"));
974
+ } catch (e) { setErr(t("cherry-pick 失败:") + e); }
949
975
  finally { setHistoryBusy(false); }
950
976
  }, [dir, loadRepo]);
951
977
 
@@ -955,7 +981,7 @@ window.__ModuleLoader__.load({
955
981
  setHistoryDetail({ hash, loading: true, diff: "", error: null });
956
982
  try {
957
983
  const r = await jpost("/commit-diff", { dir: dir || undefined, hash });
958
- setHistoryDetail({ hash, loading: false, diff: (r && r.diff) || "", error: r && !r.ok ? (r.error || "读取失败") : null });
984
+ setHistoryDetail({ hash, loading: false, diff: (r && r.diff) || "", error: r && !r.ok ? (r.error || t("读取失败")) : null });
959
985
  } catch (e) {
960
986
  setHistoryDetail({ hash, loading: false, diff: "", error: String(e) });
961
987
  }
@@ -970,42 +996,42 @@ window.__ModuleLoader__.load({
970
996
  const ok = await copyText(text);
971
997
  setCommitMenu(null);
972
998
  if (ok) {
973
- setCopiedTip("已复制" + (kind === "short" ? "短哈希" : kind === "full" ? "完整哈希" : "提交信息"));
999
+ setCopiedTip(t("已复制") + (kind === "short" ? t("短哈希") : kind === "full" ? t("完整哈希") : t("提交信息")));
974
1000
  window.setTimeout(() => setCopiedTip(null), 1600);
975
1001
  } else {
976
- setErr("复制失败:请手动复制");
1002
+ setErr(t("复制失败:请手动复制"));
977
1003
  }
978
1004
  }, []);
979
1005
 
980
- return h(Box, { title: "③ 代码管理" },
1006
+ return h(Box, { title: t("③ 代码管理") },
981
1007
  // 平台提示 + Gitee 令牌(仅 gitee 模式)
982
1008
  prov === "gitee" ? h("div", { style: { border: "1px solid " + T.border, borderRadius: 10, padding: 10, marginBottom: 10, background: T.layer1 } },
983
1009
  h("div", { style: { fontSize: 12, fontWeight: 600, color: T.label, marginBottom: 6 } },
984
- "Gitee 私人令牌(OpenAPI,需 projects 权限)"),
1010
+ t("Gitee 私人令牌(OpenAPI,需 projects 权限)")),
985
1011
  giteeConfigured === true
986
1012
  ? h("div", { style: { display: "flex", alignItems: "center", gap: 8, flexWrap: "wrap" } },
987
- h("span", { style: { color: T.success, fontSize: 12 } }, "✅ 已配置" + (giteeOwnerName ? "(账号 " + giteeOwnerName + ")" : "")),
988
- h(Btn, { label: "清除令牌", onClick: clearGiteeToken, disabled: giteeTokenBusy, noBg: true, tone: "danger" })
1013
+ h("span", { style: { color: T.success, fontSize: 12 } }, t("✅ 已配置") + (giteeOwnerName ? t("(账号 ") + giteeOwnerName + ")" : "")),
1014
+ h(Btn, { label: t("清除令牌"), onClick: clearGiteeToken, disabled: giteeTokenBusy, noBg: true, tone: "danger" })
989
1015
  )
990
1016
  : h("div", null,
991
1017
  h("div", { style: { display: "flex", gap: 8, flexWrap: "wrap", alignItems: "center" } },
992
1018
  h("input", {
993
1019
  type: "password", value: giteeToken, disabled: giteeTokenBusy,
994
- placeholder: "粘贴 Gitee 私人令牌(https://gitee.com/personal_access_tokens)",
1020
+ placeholder: t("粘贴 Gitee 私人令牌(https://gitee.com/personal_access_tokens)"),
995
1021
  onChange: (e) => setGiteeToken(e.target.value),
996
1022
  onKeyDown: (e) => { if (e.key === "Enter") void saveGiteeToken(); },
997
1023
  style: { flex: 1, minWidth: 200, font: "inherit", fontSize: 12, padding: "6px 10px", border: "1px solid " + T.border, borderRadius: 8, background: "var(--dsw-alias-bg-layer-2, rgba(128,128,128,.14))", color: T.label, outline: "none" },
998
1024
  }),
999
- h(Btn, { label: "保存令牌", onClick: saveGiteeToken, tone: "primary", noBg: true, disabled: giteeTokenBusy || !String(giteeToken || "").trim() }),
1025
+ h(Btn, { label: t("保存令牌"), onClick: saveGiteeToken, tone: "primary", noBg: true, disabled: giteeTokenBusy || !String(giteeToken || "").trim() }),
1000
1026
  ),
1001
1027
  h("div", { style: { fontSize: 11, color: T.secondary, marginTop: 6, lineHeight: 1.6 } },
1002
- "令牌只保存在本机 ~/.dsh/storages(0600),不会写进插件目录;需勾选个人令牌的 projects 权限。公钥需已上传到 Gitee(② 里检查)。")
1028
+ t("令牌只保存在本机 ~/.dsh/storages(0600),不会写进插件目录;需勾选个人令牌的 projects 权限。公钥需已上传到 Gitee(② 里检查)。"))
1003
1029
  ),
1004
1030
  giteeTokenMsg ? h("div", { style: { marginTop: 6, color: T.success, fontSize: 12 } }, "✅ " + giteeTokenMsg) : null,
1005
1031
  giteeTokenErr ? h("div", { style: { marginTop: 6, color: T.danger, fontSize: 12 } }, "❌ " + giteeTokenErr) : null
1006
1032
  ) : null,
1007
1033
  h("div", { style: { display: "flex", gap: 8, marginBottom: 10, alignItems: "center" } },
1008
- h("span", { style: { color: T.secondary, fontSize: 13, whiteSpace: "nowrap" } }, "选择工作区"),
1034
+ h("span", { style: { color: T.secondary, fontSize: 13, whiteSpace: "nowrap" } }, t("选择工作区")),
1009
1035
  h("select", {
1010
1036
  value: dir,
1011
1037
  disabled: workspaces.length === 0,
@@ -1019,83 +1045,83 @@ window.__ModuleLoader__.load({
1019
1045
  // full 同步:联网获取切换后工作区的最新状态,并显示「刷新中…」。
1020
1046
  loadRepo(v, true, true);
1021
1047
  },
1022
- title: "选择 DSH 已登记的工作区文件夹",
1048
+ title: t("选择 DSH 已登记的工作区文件夹"),
1023
1049
  style: { flex: 1, font: "inherit", fontSize: 12, padding: "6px 10px", border: "1px solid " + T.border, borderRadius: 8, background: T.layer1, color: T.label, outline: "none", cursor: "pointer" },
1024
1050
  },
1025
- workspaces.length === 0 ? h("option", { key: "__empty", value: "" }, "(暂无可选工作区)")
1026
- : h("option", { key: "__none", value: "" }, "— 请选择 —"),
1051
+ workspaces.length === 0 ? h("option", { key: "__empty", value: "" }, t("(暂无可选工作区)"))
1052
+ : h("option", { key: "__none", value: "" }, t("— 请选择 —")),
1027
1053
  workspaces.map((w) =>
1028
1054
  h("option", { key: w, value: w }, String(w).split(/[\\/]/).filter(Boolean).pop() || w)
1029
1055
  )
1030
1056
  ),
1031
- h(Btn, { label: "选择目录", onClick: openPicker, disabled: picking, noBg: true, tone: "primary" }),
1057
+ h(Btn, { label: t("选择目录"), onClick: openPicker, disabled: picking, noBg: true, tone: "primary" }),
1032
1058
  ),
1033
1059
  dir && customDirs && customDirs.includes(dir) ? h("div", { style: { display: "flex", flexWrap: "wrap", gap: 6, marginBottom: 10, alignItems: "center" } },
1034
- h("span", { style: { color: T.secondary, fontSize: 12, whiteSpace: "nowrap" } }, "自定义目录:"),
1060
+ h("span", { style: { color: T.secondary, fontSize: 12, whiteSpace: "nowrap" } }, t("自定义目录:")),
1035
1061
  h("span", { key: dir, style: { display: "inline-flex", alignItems: "center", gap: 4, padding: "2px 8px", border: "1px solid " + T.border, borderRadius: 12, fontSize: 12, background: T.layer1, color: T.label, cursor: "pointer" }, title: dir, onClick: () => { setResult(null); setMsg(null); setErr(null); setDir(dir); setDirDraft(dir); loadRepo(dir, true, true); } },
1036
1062
  String(dir).split(/[\\/]/).filter(Boolean).pop() || dir,
1037
1063
  h("span", {
1038
- role: "button", "aria-label": "删除该目录记录",
1039
- title: "删除该目录记录(不删除实际文件夹)",
1064
+ role: "button", "aria-label": t("删除该目录记录"),
1065
+ title: t("删除该目录记录(不删除实际文件夹)"),
1040
1066
  onClick: (e) => { e.stopPropagation(); void removeWorkspace(dir); },
1041
1067
  style: { color: T.danger, fontWeight: 700, padding: "0 2px", cursor: "pointer" },
1042
1068
  }, "✕")
1043
1069
  )
1044
1070
  ) : null,
1045
1071
  repo && repo.isGitRepo ? h("div", { style: { marginBottom: 10 } },
1046
- h(Field, { label: "目录", value: repo.dir }),
1047
- h(Field, { label: "分支" }, h("span", { style: { display: "inline-flex", alignItems: "center", gap: 8 } },
1048
- h("span", { style: { color: T.label, fontSize: 13 } }, repo.branch || "(无)"),
1072
+ h(Field, { label: t("目录"), value: repo.dir }),
1073
+ h(Field, { label: t("分支") }, h("span", { style: { display: "inline-flex", alignItems: "center", gap: 8 } },
1074
+ h("span", { style: { color: T.label, fontSize: 13 } }, repo.branch || t("(无)")),
1049
1075
  !hasBetterSidebar ? h(React.Fragment, null,
1050
1076
  repo.branch ? h("button", {
1051
1077
  type: "button",
1052
1078
  onClick: openBranches,
1053
- title: "切换分支",
1079
+ title: t("切换分支"),
1054
1080
  style: changeBtnStyle(),
1055
- }, "切换") : null,
1081
+ }, t("切换")) : null,
1056
1082
  h("button", {
1057
1083
  type: "button",
1058
1084
  onClick: openHistory,
1059
- title: "查看提交历史",
1085
+ title: t("查看提交历史"),
1060
1086
  style: changeBtnStyle(),
1061
- }, "历史")
1087
+ }, t("历史"))
1062
1088
  ) : null
1063
1089
  )),
1064
- h(Field, { label: "远程", value: repo.remoteUrl || "(无)" }),
1065
- h(Field, { label: "改动" }, h("span", { style: { display: "inline-flex", alignItems: "center", gap: 8 } },
1066
- h("span", { style: { color: T.label, fontSize: 13 } }, repo.dirty ? repo.dirtyCount + " 个文件" : "无"),
1090
+ h(Field, { label: t("远程"), value: repo.remoteUrl || t("(无)") }),
1091
+ h(Field, { label: t("改动") }, h("span", { style: { display: "inline-flex", alignItems: "center", gap: 8 } },
1092
+ h("span", { style: { color: T.label, fontSize: 13 } }, repo.dirty ? repo.dirtyCount + t(" 个文件") : t("无")),
1067
1093
  repo.changedFiles && repo.changedFiles.length > 0 ? h("button", {
1068
1094
  type: "button",
1069
1095
  onClick: () => setDetail("changes"),
1070
- title: "查看改动的文件列表",
1096
+ title: t("查看改动的文件列表"),
1071
1097
  style: changeBtnStyle(),
1072
- }, "查看")
1098
+ }, t("查看"))
1073
1099
  : null
1074
1100
  )),
1075
- h(Field, { label: "同步" }, h("span", { style: { display: "inline-flex", alignItems: "center", gap: 8 } },
1101
+ h(Field, { label: t("同步") }, h("span", { style: { display: "inline-flex", alignItems: "center", gap: 8 } },
1076
1102
  h("span", { style: { color: T.label, fontSize: 13 } },
1077
1103
  // 没有(属于当前账号/平台的)远程时不做同步判断,避免误显示「与远程一致」
1078
1104
  !repo.hasRemote
1079
- ? "(无)"
1080
- : (repo.ahead > 0 ? "本地领先 " + repo.ahead + " 提交" : "") +
1081
- (repo.ahead > 0 && repo.behind > 0 ? "、落后 " + repo.behind + " 提交" : (repo.behind > 0 ? "落后 " + repo.behind + " 提交" : "")) +
1082
- ((repo.ahead === 0 && repo.behind === 0) ? "与远程一致" : "")
1105
+ ? t("(无)")
1106
+ : (repo.ahead > 0 ? t("本地领先 ") + repo.ahead + t(" 提交") : "") +
1107
+ (repo.ahead > 0 && repo.behind > 0 ? t("、落后 ") + repo.behind + t(" 提交") : (repo.behind > 0 ? t("落后 ") + repo.behind + t(" 提交") : "")) +
1108
+ ((repo.ahead === 0 && repo.behind === 0) ? t("与远程一致") : "")
1083
1109
  ),
1084
1110
  (repo.ahead > 0 || repo.behind > 0) ? h("button", {
1085
1111
  type: "button",
1086
1112
  onClick: () => setDetail("sync"),
1087
- title: "查看本地与远程的提交差异",
1113
+ title: t("查看本地与远程的提交差异"),
1088
1114
  style: changeBtnStyle(),
1089
- }, "查看")
1115
+ }, t("查看"))
1090
1116
  : null
1091
1117
  )),
1092
1118
  repo.ignoredLarge && repo.ignoredLarge.length > 0 ? h("div", { style: { marginTop: 8 } },
1093
1119
  h("div", { style: { color: T.warn, fontSize: 12, marginBottom: 4 } },
1094
- "⚠️ 以下 " + repo.ignoredLarge.length + " 项 >100MB(超过 GitHub 限制,推送时将自动忽略不上传):"),
1120
+ t("⚠️ 以下 ") + repo.ignoredLarge.length + t(" 项 >100MB(超过 GitHub 限制,推送时将自动忽略不上传):")),
1095
1121
  h("div", { style: { maxHeight: 120, overflow: "auto", background: T.layer1, borderRadius: 8, padding: 8 } },
1096
1122
  repo.ignoredLarge.slice(0, 30).map((f, i) =>
1097
1123
  h("div", { key: i, style: { fontSize: 11, color: T.secondary, lineHeight: 1.5 } },
1098
- (f.kind === "dir" ? "📁 " + f.path + "/(整个文件夹)" : "📄 " + f.path) +
1124
+ (f.kind === "dir" ? "📁 " + f.path + t("/(整个文件夹)") : "📄 " + f.path) +
1099
1125
  " — " + fmtMB(f.bytes))
1100
1126
  )
1101
1127
  )
@@ -1111,7 +1137,7 @@ window.__ModuleLoader__.load({
1111
1137
  const btns = [];
1112
1138
  // 非 git 仓库但远程存在同名仓库 -> 只「创建 Git」(由用户决定后续拉取/推送)
1113
1139
  if (repo && !repo.isGitRepo && repo.repoExists === true) {
1114
- btns.push(h(Btn, { key: "init", label: "创建 Git", onClick: initGit, tone: "primary", noBg: true, disabled: isBlocked, title: "仅初始化 git 仓库,不拉取不推送,由你决定下一步" }));
1140
+ btns.push(h(Btn, { key: "init", label: t("创建 Git"), onClick: initGit, tone: "primary", noBg: true, disabled: isBlocked, title: t("仅初始化 git 仓库,不拉取不推送,由你决定下一步") }));
1115
1141
  } else if (hasRemote) {
1116
1142
  if (localChanges && remoteUpdates) {
1117
1143
  // 本地和远程都有更新:原名展示「拉取更新并推送更改 / 强制推送 /
@@ -1119,28 +1145,28 @@ window.__ModuleLoader__.load({
1119
1145
  // 分支保护等原因失败且行为难预测,故不再展示——该状态唯一的
1120
1146
  // 操作按钮是「强制对齐」(fetch + reset --hard,本地完全重置为远程)。
1121
1147
  btns.push(h("span", { key: "both-note", style: { color: T.warn, fontSize: 12 } },
1122
- "本地有改动且远程有更新,可直接用「强制对齐」将本地重置为远程状态"));
1148
+ t("本地有改动且远程有更新,可直接用「强制对齐」将本地重置为远程状态")));
1123
1149
  if (repo && repo.isGitRepo) {
1124
- btns.push(h(Btn, { key: "align", label: "强制对齐", onClick: align, disabled: isBlocked, title: "本地完全重置为远程分支(丢弃本地差异),解决“文件相同仍显示同步差异”的情况" }));
1150
+ btns.push(h(Btn, { key: "align", label: t("强制对齐"), onClick: align, disabled: isBlocked, title: t("本地完全重置为远程分支(丢弃本地差异),解决“文件相同仍显示同步差异”的情况") }));
1125
1151
  }
1126
1152
  } else if (localChanges) {
1127
1153
  // 只有本地有更改 -> 只显示推送(正常 push)
1128
- btns.push(h(Btn, { key: "push", label: "推送更改", onClick: push, tone: "primary", noBg: true, disabled: isBlocked || repo?.repoExists === false }));
1154
+ btns.push(h(Btn, { key: "push", label: t("推送更改"), onClick: push, tone: "primary", noBg: true, disabled: isBlocked || repo?.repoExists === false }));
1129
1155
  } else if (remoteUpdates) {
1130
1156
  // 只有远程有更新(本地干净)-> 只显示「拉取更新」。
1131
1157
  // 实现复用「强制对齐」逻辑(fetch + reset --hard):本地干净
1132
1158
  // 无改动可丢,reset 等同快速前进到远程最新,直接执行不弹确认。
1133
- btns.push(h(Btn, { key: "pull", label: "拉取更新", onClick: pull, disabled: isBlocked || repo?.repoExists !== true }));
1159
+ btns.push(h(Btn, { key: "pull", label: t("拉取更新"), onClick: pull, disabled: isBlocked || repo?.repoExists !== true }));
1134
1160
  } else {
1135
1161
  // 完全同步 -> 无按钮,显示已是最新
1136
- btns.push(h("span", { key: "synced", style: { color: T.success, fontSize: 13 } }, "✓ 已是最新"));
1162
+ btns.push(h("span", { key: "synced", style: { color: T.success, fontSize: 13 } }, t("✓ 已是最新")));
1137
1163
  }
1138
1164
  }
1139
1165
  // 刷新/切换平台进行中给出明确提示,让用户知道正在联网同步或重新检测。
1140
1166
  const refreshingTip = refreshing
1141
- ? h("div", { style: { color: T.brand, fontSize: 12, marginTop: 8 } }, "⟳ 正在刷新状态,联网同步 GitHub/Gitee 最新数据…")
1167
+ ? h("div", { style: { color: T.brand, fontSize: 12, marginTop: 8 } }, t("⟳ 正在刷新状态,联网同步 GitHub/Gitee 最新数据…"))
1142
1168
  : switching
1143
- ? h("div", { style: { color: T.brand, fontSize: 12, marginTop: 8 } }, "⟳ 切换平台,正在重新检测「" + (prov === "gitee" ? "Gitee" : "GitHub") + "」仓库状态…")
1169
+ ? h("div", { style: { color: T.brand, fontSize: 12, marginTop: 8 } }, t("⟳ 切换平台,正在重新检测「") + (prov === "gitee" ? "Gitee" : "GitHub") + t("」仓库状态…"))
1144
1170
  : null
1145
1171
  return h("div", { style: { display: "flex", gap: 8, flexWrap: "wrap", alignItems: "center" } },
1146
1172
  btns,
@@ -1149,15 +1175,15 @@ window.__ModuleLoader__.load({
1149
1175
  (!hasBetterSidebar && repo && repo.hasRemote
1150
1176
  && (repo.ahead > 0 || ((repo.changedFiles || []).some((f) => f.staged)))) ? h(Btn, {
1151
1177
  key: "push-staged",
1152
- label: pushStagedBusy ? "推送中…" : "推送暂存",
1178
+ label: pushStagedBusy ? t("推送中…") : t("推送暂存"),
1153
1179
  onClick: doPushStaged,
1154
1180
  tone: "primary", noBg: true,
1155
1181
  disabled: busy || pushStagedBusy || !dir,
1156
- title: "把已暂存的内容用填写的(或自动生成的)信息提交后推送到远程;不会自动暂存其他未暂存的改动",
1182
+ title: t("把已暂存的内容用填写的(或自动生成的)信息提交后推送到远程;不会自动暂存其他未暂存的改动"),
1157
1183
  }) : null,
1158
1184
  // keepRepo=true 保留旧内容避免闪烁;full=true 触发 loadRepo 的「刷新中…」提示 + 联网同步。
1159
1185
  h(Btn, {
1160
- label: refreshing ? "刷新中…" : "刷新状态",
1186
+ label: refreshing ? t("刷新中…") : t("刷新状态"),
1161
1187
  onClick: () => { setResult(null); setMsg(null); setErr(null); loadRepo(dir, true, true); },
1162
1188
  disabled: busy || refreshing,
1163
1189
  }),
@@ -1168,62 +1194,62 @@ window.__ModuleLoader__.load({
1168
1194
  !hasBetterSidebar && repo && repo.isGitRepo && repo.dirty ? h("div", { style: { display: "flex", gap: 8, marginTop: 10, alignItems: "center" } },
1169
1195
  h("input", {
1170
1196
  type: "text", value: commitMsg,
1171
- placeholder: "提交信息(留空则用默认)",
1172
- title: "填写提交信息后点「提交」;留空则自动生成(chore: update <文件夹名>)",
1197
+ placeholder: t("提交信息(留空则用默认)"),
1198
+ title: t("填写提交信息后点「提交」;留空则自动生成(chore: update <文件夹名>)"),
1173
1199
  onChange: (e) => setCommitMsg(e.target.value),
1174
1200
  onKeyDown: (e) => { if (e.key === "Enter") void doCommit(); },
1175
1201
  style: { flex: 1, font: "inherit", fontSize: 12, padding: "6px 10px", border: "1px solid " + T.border, borderRadius: 8, background: T.layer1, color: T.label, outline: "none" },
1176
1202
  }),
1177
- h(Btn, { label: "提交", onClick: doCommit, tone: "primary", noBg: true, disabled: busy || stageBusy || repo.dirtyCount <= 0 || !dir }),
1203
+ h(Btn, { label: t("提交"), onClick: doCommit, tone: "primary", noBg: true, disabled: busy || stageBusy || repo.dirtyCount <= 0 || !dir }),
1178
1204
  ) : null,
1179
1205
  h("div", { style: { display: "flex", gap: 8, marginTop: 10, alignItems: "center" } },
1180
1206
  h("input", {
1181
1207
  type: "text", value: repoName, readOnly: true,
1182
- title: "仓库名称自动取文件夹名(不可修改)",
1183
- placeholder: "(未加载文件夹)",
1208
+ title: t("仓库名称自动取文件夹名(不可修改)"),
1209
+ placeholder: t("(未加载文件夹)"),
1184
1210
  style: { flex: 1, font: "inherit", fontSize: 12, padding: "6px 10px", border: "1px solid " + T.border, borderRadius: 8, background: T.layer1, color: T.label, outline: "none", cursor: "not-allowed", opacity: 0.85 },
1185
1211
  }),
1186
1212
  h("select", {
1187
1213
  value: visibility,
1188
1214
  onChange: (e) => setVisibility(e.target.value),
1189
- title: "仓库可见性:私有 / 公开" + (repo && repo.repoExists === true ? "(修改当前仓库的可见性)" : ""),
1215
+ title: t("仓库可见性:私有 / 公开") + (repo && repo.repoExists === true ? t("(修改当前仓库的可见性)") : ""),
1190
1216
  style: { font: "inherit", fontSize: 12, padding: "6px 8px", border: "1px solid " + T.border, borderRadius: 8, background: T.layer1, color: T.label, outline: "none", cursor: "pointer" },
1191
1217
  },
1192
- h("option", { value: "private" }, "私有"),
1193
- h("option", { value: "public" }, "公开")
1218
+ h("option", { value: "private" }, t("私有")),
1219
+ h("option", { value: "public" }, t("公开"))
1194
1220
  ),
1195
1221
  repo && repo.repoExists === true ? (
1196
1222
  // 仓库已存在:根据所选值与当前实际可见性决定按钮 / 提示
1197
1223
  repo.visibility === visibility ? h(Btn, {
1198
- key: "create", label: "新建仓库并推送", onClick: create, tone: "success",
1224
+ key: "create", label: t("新建仓库并推送"), onClick: create, tone: "success",
1199
1225
  disabled: true,
1200
1226
  }) : h(Btn, {
1201
- key: "setvis", label: "修改仓库状态", onClick: changeVisibility, tone: "success",
1227
+ key: "setvis", label: t("修改仓库状态"), onClick: changeVisibility, tone: "success",
1202
1228
  disabled: busy || !repoName,
1203
1229
  })
1204
1230
  ) : h(Btn, {
1205
- key: "create", label: "新建仓库并推送", onClick: create, tone: "success",
1231
+ key: "create", label: t("新建仓库并推送"), onClick: create, tone: "success",
1206
1232
  disabled: busy || !repoName,
1207
1233
  })
1208
1234
  ),
1209
1235
  repo && repo.repoExists === true ? h("div", { style: { marginTop: 8, fontSize: 12 } },
1210
1236
  repo.visibility
1211
1237
  ? (repo.visibility === visibility
1212
- ? h("span", { style: { color: T.success } }, "✓ 仓库已是「" + (repo.visibility === "public" ? "公开" : "私有") + "」状态,如需修改请调整左侧可见性选择。")
1213
- : h("span", { style: { color: T.warn } }, "将把仓库从「" + (repo.visibility === "public" ? "公开" : "私有") + "」改为「" + (visibility === "public" ? "公开" : "私有") + "」,点击「修改仓库状态」执行。"))
1214
- : h("span", { style: { color: T.secondary } }, "⚠️ 同名仓库已经创建(无法读取当前可见性,可能未" + (prov === "gitee" ? "配置 Gitee 令牌" : "登录 gh") + ")")
1238
+ ? h("span", { style: { color: T.success } }, t("✓ 仓库已是「") + (repo.visibility === "public" ? t("公开") : t("私有")) + t("」状态,如需修改请调整左侧可见性选择。"))
1239
+ : h("span", { style: { color: T.warn } }, t("将把仓库从「") + (repo.visibility === "public" ? t("公开") : t("私有")) + t("」改为「") + (visibility === "public" ? t("公开") : t("私有")) + t("」,点击「修改仓库状态」执行。")))
1240
+ : h("span", { style: { color: T.secondary } }, t("⚠️ 同名仓库已经创建(无法读取当前可见性,可能未") + (prov === "gitee" ? t("配置 Gitee 令牌") : t("登录 gh")) + ")")
1215
1241
  ) : repo && repo.repoExists === false ? h("div", { style: { marginTop: 8, color: T.success, fontSize: 12 } },
1216
- "✓ 同名仓库 " + repoName + " 不存在,可在 " + (prov === "gitee" ? "Gitee" : "GitHub") + "「新建仓库并推送」创建(可选私有/公开)。"
1242
+ t("✓ 同名仓库 ") + repoName + t(" 不存在,可在 ") + (prov === "gitee" ? "Gitee" : "GitHub") + t("「新建仓库并推送」创建(可选私有/公开)。")
1217
1243
  ) : null,
1218
1244
 
1219
1245
  result ? h("div", { style: { marginTop: 12, borderTop: "1px solid " + T.border, paddingTop: 10 } },
1220
1246
  msg ? h("div", { style: { color: T.success, fontSize: 13 } }, "✅ " + msg) : null,
1221
1247
  result.skipped && result.skipped.length > 0 ? h("div", { style: { marginTop: 8 } },
1222
1248
  h("div", { style: { color: T.warn, fontSize: 12, marginBottom: 4 } },
1223
- "已忽略未上传(" + result.skipped.length + " 项 >100MB):"),
1249
+ t("已忽略未上传(") + result.skipped.length + t(" 项 >100MB):")),
1224
1250
  result.skipped.map((s, i) => h("div", { key: i, style: { fontSize: 11, color: T.warn, lineHeight: 1.5 } }, "· " + s.path + " — " + s.reason)))
1225
1251
  : result.ok ? h("div", { style: { color: T.success, fontSize: 12, marginTop: 6 } },
1226
- "已提交" + (result.commitHash ? " " + result.commitHash : "") + (result.pushed ? " 并推送" : "(推送省略)"))
1252
+ t("已提交") + (result.commitHash ? " " + result.commitHash : "") + (result.pushed ? t(" 并推送") : t("(推送省略)")))
1227
1253
  : err ? h("div", { style: { marginTop: 8, color: T.danger, fontSize: 12 } }, "❌ " + err)
1228
1254
  : result.pushError ? h("div", { style: { marginTop: 8, color: T.danger, fontSize: 12 } }, "❌ " + result.pushError)
1229
1255
  : null
@@ -1231,19 +1257,19 @@ window.__ModuleLoader__.load({
1231
1257
  detail ? ReactDOM.createPortal(
1232
1258
  h("div", { style: { position: "fixed", inset: 0, zIndex: 2000, display: "flex", alignItems: "center", justifyContent: "center" }, role: "presentation" },
1233
1259
  h("div", { style: { position: "absolute", inset: 0, background: T.mask }, "aria-hidden": "true", onClick: () => setDetail(null) }),
1234
- h("div", { style: { position: "relative", zIndex: 1, width: detail === "changes" ? 700 : 520, maxWidth: "calc(100vw - 48px)", maxHeight: "calc(100vh - 100px)", display: "flex", flexDirection: "column", background: "var(--dsw-alias-bg-layer-3, #fff)", border: "1px solid " + T.border, borderRadius: 14, padding: 18, color: T.label, boxShadow: "var(--dsw-overlay-shadow, 0 12px 32px rgba(0,0,0,.35))" }, role: "dialog", "aria-modal": "true", "aria-label": "查看详情" },
1260
+ h("div", { style: { position: "relative", zIndex: 1, width: detail === "changes" ? 700 : 520, maxWidth: "calc(100vw - 48px)", maxHeight: "calc(100vh - 100px)", display: "flex", flexDirection: "column", background: "var(--dsw-alias-bg-layer-3, #fff)", border: "1px solid " + T.border, borderRadius: 14, padding: 18, color: T.label, boxShadow: "var(--dsw-overlay-shadow, 0 12px 32px rgba(0,0,0,.35))" }, role: "dialog", "aria-modal": "true", "aria-label": t("查看详情") },
1235
1261
  h("div", { style: { display: "flex", alignItems: "flex-start", gap: 12, marginBottom: 10 } },
1236
1262
  h("div", { style: { fontSize: 15, fontWeight: 600, flex: 1 } },
1237
- detail === "changes" ? "改动文件"
1238
- : detail === "branches" ? "切换分支"
1239
- : detail === "history" ? "提交历史"
1240
- : "与远程同步差异"),
1241
- h("button", { type: "button", style: closeBtnStyle(), "aria-label": "关闭", onClick: () => setDetail(null) }, "✕")
1263
+ detail === "changes" ? t("改动文件")
1264
+ : detail === "branches" ? t("切换分支")
1265
+ : detail === "history" ? t("提交历史")
1266
+ : t("与远程同步差异")),
1267
+ h("button", { type: "button", style: closeBtnStyle(), "aria-label": t("关闭"), onClick: () => setDetail(null) }, "✕")
1242
1268
  ),
1243
1269
  h("div", { style: { flex: 1, overflow: "auto" } },
1244
1270
  detail === "changes" ? h(React.Fragment, null,
1245
1271
  hasBetterSidebar ? h("div", { style: { marginBottom: 10, padding: "8px 10px", borderRadius: 8, background: T.layer1, color: T.secondary, fontSize: 12, lineHeight: 1.6 } },
1246
- "已安装 dsh-better-sidebar,此处只列改动文件列表;具体改动内容请到 dsh-better-sidebar 的「源代码管理 / Git 面板」查看。")
1272
+ t("已安装 dsh-better-sidebar,此处只列改动文件列表;具体改动内容请到 dsh-better-sidebar 的「源代码管理 / Git 面板」查看。"))
1247
1273
  : null,
1248
1274
  repo && repo.changedFiles && repo.changedFiles.length > 0
1249
1275
  ? repo.changedFiles.map((f, i) => {
@@ -1285,46 +1311,46 @@ window.__ModuleLoader__.load({
1285
1311
  borderBottom: "1px solid " + T.border, padding: "3px 2px",
1286
1312
  cursor: canHaveDiff ? "pointer" : "default",
1287
1313
  },
1288
- title: canHaveDiff ? (open ? "点击收起" : "点击查看改动内容") : "新文件(untracked)暂无内容 diff",
1314
+ title: canHaveDiff ? (open ? t("点击收起") : t("点击查看改动内容")) : t("新文件(untracked)暂无内容 diff"),
1289
1315
  onClick: onClick,
1290
1316
  },
1291
1317
  h("span", { style: { color: typeColor(f.type), fontSize: 11, flexShrink: 0, width: 52 } }, typeLabel(f.type)),
1292
1318
  h("span", { style: { color: T.label, wordBreak: "break-all", flex: 1 } }, f.path),
1293
1319
  !hasBetterSidebar ? h(React.Fragment, null,
1294
- h("span", { style: { fontSize: 11, flexShrink: 0, color: f.staged ? T.success : T.secondary } }, f.staged ? "已暂存" : "未暂存"),
1320
+ h("span", { style: { fontSize: 11, flexShrink: 0, color: f.staged ? T.success : T.secondary } }, f.staged ? t("已暂存") : t("未暂存")),
1295
1321
  h("button", {
1296
1322
  type: "button",
1297
- title: f.staged ? "取消暂存" : "暂存",
1323
+ title: f.staged ? t("取消暂存") : t("暂存"),
1298
1324
  disabled: stageBusy,
1299
1325
  style: changeBtnStyle(),
1300
1326
  onClick: (e) => { e.stopPropagation(); if (f.staged) void doUnstage(f.path); else void doStage(f.path); },
1301
- }, f.staged ? "取消暂存" : "暂存"),
1327
+ }, f.staged ? t("取消暂存") : t("暂存")),
1302
1328
  canHaveDiff ? h("span", { style: { color: T.brand, fontSize: 11, flexShrink: 0 } },
1303
- d.loading ? "加载中…" : (open ? "▾ 收起" : "▸ 查看"))
1329
+ d.loading ? t("加载中…") : (open ? t("▾ 收起") : t("▸ 查看")))
1304
1330
  : null
1305
1331
  ) : null
1306
1332
  ),
1307
1333
  open && canHaveDiff ? (
1308
- d.loading ? h("div", { style: { fontSize: 12, color: T.secondary, padding: "4px 8px" } }, "正在加载改动内容…")
1334
+ d.loading ? h("div", { style: { fontSize: 12, color: T.secondary, padding: "4px 8px" } }, t("正在加载改动内容…"))
1309
1335
  : d.error ? h("div", { style: { fontSize: 12, color: T.danger, padding: "4px 8px" } }, "❌ " + d.error)
1310
- : d.diff ? renderSideBySideDiff(d.diff) : h("div", { style: { fontSize: 12, color: T.secondary, padding: "4px 8px" } }, "(无内容差异)")
1336
+ : d.diff ? renderSideBySideDiff(d.diff) : h("div", { style: { fontSize: 12, color: T.secondary, padding: "4px 8px" } }, t("(无内容差异)"))
1311
1337
  ) : null
1312
1338
  );
1313
1339
  })
1314
- : h("div", { style: { color: T.secondary, fontSize: 13 } }, "当前没有改动。")
1340
+ : h("div", { style: { color: T.secondary, fontSize: 13 } }, t("当前没有改动。"))
1315
1341
  ) : detail === "branches" ? (
1316
- branchBusy ? h("div", { style: { color: T.secondary, fontSize: 13 } }, "正在读取分支…")
1317
- : branches.length === 0 ? h("div", { style: { color: T.secondary, fontSize: 13 } }, "(无分支)")
1342
+ branchBusy ? h("div", { style: { color: T.secondary, fontSize: 13 } }, t("正在读取分支…"))
1343
+ : branches.length === 0 ? h("div", { style: { color: T.secondary, fontSize: 13 } }, t("(无分支)"))
1318
1344
  : branches.map((b) =>
1319
1345
  h("div", { key: b, style: { display: "flex", alignItems: "center", gap: 8, padding: "6px 2px", borderBottom: "1px solid " + T.border } },
1320
1346
  h("span", { style: { flex: 1, color: b === branchCurrent ? T.success : T.label, fontSize: 13, fontWeight: b === branchCurrent ? 600 : 400 } },
1321
- b + (b === branchCurrent ? "(当前)" : "")),
1322
- b !== branchCurrent ? h(Btn, { label: "切换", onClick: () => doCheckout(b), disabled: historyBusy || branchBusy, noBg: true, tone: "primary" }) : null
1347
+ b + (b === branchCurrent ? t("(当前)") : "")),
1348
+ b !== branchCurrent ? h(Btn, { label: t("切换"), onClick: () => doCheckout(b), disabled: historyBusy || branchBusy, noBg: true, tone: "primary" }) : null
1323
1349
  )
1324
1350
  )
1325
1351
  ) : detail === "history" ? (
1326
- commitsLoading ? h("div", { style: { color: T.secondary, fontSize: 13 } }, "正在读取历史…")
1327
- : commits.length === 0 ? h("div", { style: { color: T.secondary, fontSize: 13 } }, "(暂无提交)")
1352
+ commitsLoading ? h("div", { style: { color: T.secondary, fontSize: 13 } }, t("正在读取历史…"))
1353
+ : commits.length === 0 ? h("div", { style: { color: T.secondary, fontSize: 13 } }, t("(暂无提交)"))
1328
1354
  : commits.map((c) => {
1329
1355
  const hd = historyDetail && historyDetail.hash === c.hash ? historyDetail : null
1330
1356
  const menuOpen = commitMenu === c.hashFull
@@ -1337,28 +1363,28 @@ window.__ModuleLoader__.load({
1337
1363
  h("div", { style: { display: "flex", alignItems: "center", gap: 8 } },
1338
1364
  h("span", { style: { fontFamily: "var(--ds-font-family-code, ui-monospace, monospace)", fontSize: 12, color: T.brand, flexShrink: 0 } }, c.hash),
1339
1365
  h("span", { style: { flex: 1, color: T.label, fontSize: 13, minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, c.subject || ""),
1340
- h("button", { type: "button", title: "更多操作(右键也可打开)", disabled: historyBusy, style: changeBtnStyle(), onClick: (e) => { e.stopPropagation(); setCommitMenu(menuOpen ? null : c.hashFull); } }, "⋯")
1366
+ h("button", { type: "button", title: t("更多操作(右键也可打开)"), disabled: historyBusy, style: changeBtnStyle(), onClick: (e) => { e.stopPropagation(); setCommitMenu(menuOpen ? null : c.hashFull); } }, "⋯")
1341
1367
  ),
1342
1368
  h("div", { style: { fontSize: 11, color: T.secondary, marginTop: 2 } },
1343
1369
  c.author + (c.date ? " · " + c.date : "")),
1344
1370
  menuOpen ? h("div", { style: menuPanelStyle() },
1345
1371
  h("div", { ...hoverProps(), style: menuItemStyle(), onClick: () => { setCommitMenu(null); openCommitDiff(c.hash); } },
1346
- h("span", { style: { width: 16, fontSize: 11, textAlign: "center", color: T.secondary } }, "▸"), "查看提交差异"),
1372
+ h("span", { style: { width: 16, fontSize: 11, textAlign: "center", color: T.secondary } }, "▸"), t("查看提交差异")),
1347
1373
  h("div", { ...hoverProps(), style: menuItemStyle(), onClick: () => copyCommit("short", c) },
1348
- h("span", { style: { width: 16, fontSize: 11, textAlign: "center", color: T.secondary } }, "⧉"), "复制短哈希"),
1374
+ h("span", { style: { width: 16, fontSize: 11, textAlign: "center", color: T.secondary } }, "⧉"), t("复制短哈希")),
1349
1375
  h("div", { ...hoverProps(), style: menuItemStyle(), onClick: () => copyCommit("full", c) },
1350
- h("span", { style: { width: 16, fontSize: 11, textAlign: "center", color: T.secondary } }, "⧉"), "复制完整哈希"),
1376
+ h("span", { style: { width: 16, fontSize: 11, textAlign: "center", color: T.secondary } }, "⧉"), t("复制完整哈希")),
1351
1377
  h("div", { ...hoverProps(), style: menuItemStyle(), onClick: () => copyCommit("msg", c) },
1352
- h("span", { style: { width: 16, fontSize: 11, textAlign: "center", color: T.secondary } }, "⧉"), "复制提交信息"),
1378
+ h("span", { style: { width: 16, fontSize: 11, textAlign: "center", color: T.secondary } }, "⧉"), t("复制提交信息")),
1353
1379
  h("div", { ...hoverProps(), style: menuItemStyle({ danger: true }), onClick: () => { setCommitMenu(null); doRevert(c.hash, c.subject); } },
1354
- h("span", { style: { width: 16, fontSize: 11, textAlign: "center", color: T.danger } }, "↩"), "还原此提交"),
1380
+ h("span", { style: { width: 16, fontSize: 11, textAlign: "center", color: T.danger } }, "↩"), t("还原此提交")),
1355
1381
  h("div", { ...hoverProps(), style: menuItemStyle({ danger: true }), onClick: () => { setCommitMenu(null); doCherryPick(c.hash, c.subject); } },
1356
- h("span", { style: { width: 16, fontSize: 11, textAlign: "center", color: T.danger } }, "↪"), "拾取此提交")
1382
+ h("span", { style: { width: 16, fontSize: 11, textAlign: "center", color: T.danger } }, "↪"), t("拾取此提交"))
1357
1383
  ) : null,
1358
1384
  hd ? (
1359
- hd.loading ? h("div", { style: { fontSize: 12, color: T.secondary, padding: "4px 8px" } }, "正在加载提交 diff…")
1385
+ hd.loading ? h("div", { style: { fontSize: 12, color: T.secondary, padding: "4px 8px" } }, t("正在加载提交 diff…"))
1360
1386
  : hd.error ? h("div", { style: { fontSize: 12, color: T.danger, padding: "4px 8px" } }, "❌ " + hd.error)
1361
- : hd.diff ? renderSideBySideDiff(hd.diff) : h("div", { style: { fontSize: 12, color: T.secondary, padding: "4px 8px" } }, "(无内容差异)")
1387
+ : hd.diff ? renderSideBySideDiff(hd.diff) : h("div", { style: { fontSize: 12, color: T.secondary, padding: "4px 8px" } }, t("(无内容差异)"))
1362
1388
  ) : null
1363
1389
  )
1364
1390
  })
@@ -1366,18 +1392,18 @@ window.__ModuleLoader__.load({
1366
1392
  h("div", null,
1367
1393
  repo && (repo.ahead > 0 || repo.behind > 0) ? h("div", null,
1368
1394
  repo.behind > 0 ? h("div", { style: { marginBottom: 10 } },
1369
- h("div", { style: { color: T.warn, fontSize: 12, fontWeight: 600, marginBottom: 4 } }, "本地落后 " + repo.behind + " 个提交(远程有而本地没有):"),
1395
+ h("div", { style: { color: T.warn, fontSize: 12, fontWeight: 600, marginBottom: 4 } }, t("本地落后 ") + repo.behind + t(" 个提交(远程有而本地没有):")),
1370
1396
  repo.behindCommits && repo.behindCommits.length > 0
1371
1397
  ? repo.behindCommits.map((c, i) => h("div", { key: i, style: { fontSize: 12, color: T.secondary, lineHeight: 1.7, fontFamily: "var(--ds-font-family-code, ui-monospace, monospace)" } }, c))
1372
1398
  : null
1373
1399
  ) : null,
1374
1400
  repo.ahead > 0 ? h("div", null,
1375
- h("div", { style: { color: T.brand, fontSize: 12, fontWeight: 600, marginBottom: 4 } }, "本地领先 " + repo.ahead + " 个提交(本地有而远程没有):"),
1401
+ h("div", { style: { color: T.brand, fontSize: 12, fontWeight: 600, marginBottom: 4 } }, t("本地领先 ") + repo.ahead + t(" 个提交(本地有而远程没有):")),
1376
1402
  repo.aheadCommits && repo.aheadCommits.length > 0
1377
1403
  ? repo.aheadCommits.map((c, i) => h("div", { key: i, style: { fontSize: 12, color: T.secondary, lineHeight: 1.7, fontFamily: "var(--ds-font-family-code, ui-monospace, monospace)" } }, c))
1378
1404
  : null
1379
1405
  ) : null
1380
- ) : h("div", { style: { color: T.success, fontSize: 13 } }, "✓ 已与远程同步,无差异。")
1406
+ ) : h("div", { style: { color: T.success, fontSize: 13 } }, t("✓ 已与远程同步,无差异。"))
1381
1407
  )
1382
1408
  )
1383
1409
  )
@@ -1388,22 +1414,22 @@ window.__ModuleLoader__.load({
1388
1414
  pickOpen ? ReactDOM.createPortal(
1389
1415
  h("div", { style: { position: "fixed", inset: 0, zIndex: 2000, display: "flex", alignItems: "center", justifyContent: "center" }, role: "presentation" },
1390
1416
  h("div", { style: { position: "absolute", inset: 0, background: T.mask }, "aria-hidden": "true", onClick: cancelPick }),
1391
- h("div", { style: { position: "relative", zIndex: 1, width: 480, maxWidth: "calc(100vw - 48px)", background: "var(--dsw-alias-bg-layer-3, #fff)", border: "1px solid " + T.border, borderRadius: 14, padding: 18, color: T.label, boxShadow: "var(--dsw-overlay-shadow, 0 12px 32px rgba(0,0,0,.35))" }, role: "dialog", "aria-modal": "true", "aria-label": "选择目录" },
1392
- h("div", { style: { fontSize: 15, fontWeight: 600, marginBottom: 10 } }, "选择代码目录"),
1417
+ h("div", { style: { position: "relative", zIndex: 1, width: 480, maxWidth: "calc(100vw - 48px)", background: "var(--dsw-alias-bg-layer-3, #fff)", border: "1px solid " + T.border, borderRadius: 14, padding: 18, color: T.label, boxShadow: "var(--dsw-overlay-shadow, 0 12px 32px rgba(0,0,0,.35))" }, role: "dialog", "aria-modal": "true", "aria-label": t("选择目录") },
1418
+ h("div", { style: { fontSize: 15, fontWeight: 600, marginBottom: 10 } }, t("选择代码目录")),
1393
1419
  h("div", { style: { fontSize: 12, color: T.secondary, marginBottom: 8, lineHeight: 1.6 } },
1394
- "可手动输入/粘贴目录绝对路径,或点击「浏览…」弹出本地文件夹选择器。确认后将添加到下方下拉并记住,下次打开无需重新选择。"),
1420
+ t("可手动输入/粘贴目录绝对路径,或点击「浏览…」弹出本地文件夹选择器。确认后将添加到下方下拉并记住,下次打开无需重新选择。")),
1395
1421
  h("input", {
1396
1422
  type: "text", value: pickPath, disabled: picking,
1397
- placeholder: "C:\\Users\\你的用户名\\项目目录",
1423
+ placeholder: t("C:\\Users\\你的用户名\\项目目录"),
1398
1424
  onChange: (e) => setPickPath(e.target.value),
1399
1425
  onKeyDown: (e) => { if (e.key === "Enter") void confirmPick(); },
1400
1426
  style: { width: "100%", boxSizing: "border-box", font: "inherit", fontSize: 13, padding: "8px 10px", border: "1px solid " + T.border, borderRadius: 8, background: T.layer1, color: T.label, outline: "none" },
1401
1427
  }),
1402
1428
  pickErr ? h("div", { style: { marginTop: 8, color: T.danger, fontSize: 12 } }, "❌ " + pickErr) : null,
1403
1429
  h("div", { style: { display: "flex", gap: 8, marginTop: 14, justifyContent: "flex-end" } },
1404
- h(Btn, { label: "浏览…", onClick: browseDir, disabled: picking, noBg: true }),
1405
- h(Btn, { label: "取消", onClick: cancelPick, disabled: picking }),
1406
- h(Btn, { label: "确定", onClick: confirmPick, tone: "primary", noBg: true, disabled: picking || !String(pickPath || "").trim() })
1430
+ h(Btn, { label: t("浏览…"), onClick: browseDir, disabled: picking, noBg: true }),
1431
+ h(Btn, { label: t("取消"), onClick: cancelPick, disabled: picking }),
1432
+ h(Btn, { label: t("确定"), onClick: confirmPick, tone: "primary", noBg: true, disabled: picking || !String(pickPath || "").trim() })
1407
1433
  )
1408
1434
  )
1409
1435
  ),
@@ -1473,13 +1499,13 @@ window.__ModuleLoader__.load({
1473
1499
  } catch { return false; }
1474
1500
  }
1475
1501
 
1476
- /** Chinese label for a changed-file status type. */
1477
- function typeLabel(t) {
1478
- return { untracked: "新增", added: "新增", deleted: "删除", renamed: "重命名", modified: "修改" }[t] || "修改";
1502
+ /** Localized label for a changed-file status type. */
1503
+ function typeLabel(type) {
1504
+ return { untracked: t("新增"), added: t("新增"), deleted: t("删除"), renamed: t("重命名"), modified: t("修改") }[type] || t("修改");
1479
1505
  }
1480
1506
  /** Color for a changed-file status type. */
1481
- function typeColor(t) {
1482
- return { untracked: T.success, added: T.success, deleted: T.danger, renamed: T.warn, modified: T.brand }[t] || T.label;
1507
+ function typeColor(type) {
1508
+ return { untracked: T.success, added: T.success, deleted: T.danger, renamed: T.warn, modified: T.brand }[type] || T.label;
1483
1509
  }
1484
1510
 
1485
1511
  /**
@@ -1546,8 +1572,8 @@ window.__ModuleLoader__.load({
1546
1572
  const gutter = { ...mono, fontSize: 10, lineHeight: 1.55, color: T.secondary, textAlign: "right", padding: "0 6px", whiteSpace: "nowrap", wordBreak: "normal", opacity: 0.7 };
1547
1573
  return h("div", { style: { border: "1px solid " + T.border, borderRadius: 8, overflow: "hidden", margin: "4px 0 8px", maxHeight: 280, overflowY: "auto", background: "rgba(0,0,0,.04)" } },
1548
1574
  h("div", { style: { display: "flex", borderBottom: "1px solid " + T.border, position: "sticky", top: 0, background: "var(--dsw-alias-bg-layer-3, #fff)", zIndex: 1 } },
1549
- h("div", { style: { flex: 1, padding: "3px 8px", fontSize: 12, fontWeight: 600, color: T.danger } }, "旧版本"),
1550
- h("div", { style: { flex: 1, padding: "3px 8px", fontSize: 12, fontWeight: 600, color: T.success } }, "新版本")
1575
+ h("div", { style: { flex: 1, padding: "3px 8px", fontSize: 12, fontWeight: 600, color: T.danger } }, t("旧版本")),
1576
+ h("div", { style: { flex: 1, padding: "3px 8px", fontSize: 12, fontWeight: 600, color: T.success } }, t("新版本"))
1551
1577
  ),
1552
1578
  rows.map((r, i) =>
1553
1579
  h("div", { key: i, style: { display: "flex", background: cellBg[r.type] || "transparent", borderBottom: r.type === "ctx" ? "none" : "1px solid rgba(128,128,128,.1)" } },
@@ -1564,16 +1590,18 @@ window.__ModuleLoader__.load({
1564
1590
  // `variant` 决定布局:'drawer'(右侧栏集成面板,显示关闭按钮、填充容器)与 'tab'
1565
1591
  // (作为 dsh-better-sidebar 侧边栏 Tab 内容,填充容器、隐藏关闭按钮)。
1566
1592
  function ScmPanel({ onClose, variant }) {
1593
+ // 跟随 DSH 语言设置:切换语言时整个面板(①②③)实时重渲染。
1594
+ useLocale();
1567
1595
  // 代码托管平台选择在②里操作、在③里跟随:lift 到面板级别共享。
1568
1596
  const [provider, setProvider] = useState("github");
1569
1597
  const embedded = variant === "tab" || variant === "drawer";
1570
- return h("div", { style: panelStyle(variant), role: "dialog", "aria-modal": embedded ? undefined : "true", "aria-label": "源代码管理" },
1598
+ return h("div", { style: panelStyle(variant), role: "dialog", "aria-modal": embedded ? undefined : "true", "aria-label": t("源代码管理") },
1571
1599
  h("div", { style: { display: "flex", alignItems: "flex-start", gap: 12 } },
1572
- h("h2", { style: { margin: 0, fontSize: 16, fontWeight: 600, lineHeight: 1.4, flex: 1 } }, "源代码管理"),
1573
- variant === "tab" ? null : h("button", { type: "button", style: closeBtnStyle(T), "aria-label": "关闭", onClick: onClose }, "✕")
1600
+ h("h2", { style: { margin: 0, fontSize: 16, fontWeight: 600, lineHeight: 1.4, flex: 1 } }, t("源代码管理")),
1601
+ variant === "tab" ? null : h("button", { type: "button", style: closeBtnStyle(T), "aria-label": t("关闭"), onClick: onClose }, "✕")
1574
1602
  ),
1575
1603
  h("p", { style: { margin: "6px 0 14px", color: T.secondary, fontSize: 12, lineHeight: 1.6 } },
1576
- "按顺序完成:①环境检查 → ②SSH 密钥与连接 → ③代码管理。推送会自动忽略 >100MB 的文件(" + (provider === "gitee" ? "Gitee" : "GitHub") + " 限制)并说明原因。"),
1604
+ t("按顺序完成:①环境检查 → ②SSH 密钥与连接 → ③代码管理。推送会自动忽略 >100MB 的文件(") + (provider === "gitee" ? "Gitee" : "GitHub") + t(" 限制)并说明原因。")),
1577
1605
  h(EnvSection, null),
1578
1606
  h("div", { style: { height: 12 } }),
1579
1607
  h(SshSection, { provider, setProvider }),
@@ -1703,6 +1731,8 @@ window.__ModuleLoader__.load({
1703
1731
  /** 右上角「代码管理」按钮 + 点击后打开的右侧集成面板(dsh-better-sidebar 外观,
1704
1732
  * 可拖拽左边缘调整宽度)。 */
1705
1733
  function HeaderScmAction() {
1734
+ // 跟随 DSH 语言设置:按钮文字(代码管理)实时切换。
1735
+ useLocale();
1706
1736
  const [open, setOpen] = useState(false);
1707
1737
  const [panelW, setPanelW] = useState(SCM_PANEL_W);
1708
1738
  const panelRef = useRef(null);
@@ -1719,8 +1749,8 @@ window.__ModuleLoader__.load({
1719
1749
  (w) => setPanelW(w),
1720
1750
  );
1721
1751
  return h(React.Fragment, null,
1722
- h("button", { type: "button", style: headerBtnStyle(), title: "源代码管理", "aria-label": "源代码管理", onClick: () => setOpen(true) },
1723
- repoIcon(14), h("span", { style: { fontSize: 13 } }, "代码管理")),
1752
+ h("button", { type: "button", style: headerBtnStyle(), title: t("源代码管理"), "aria-label": t("源代码管理"), onClick: () => setOpen(true) },
1753
+ repoIcon(14), h("span", { style: { fontSize: 13 } }, t("代码管理"))),
1724
1754
  open ? ReactDOM.createPortal(
1725
1755
  h("div", { style: { position: "fixed", inset: 0, zIndex: 1000, pointerEvents: "none" }, role: "presentation" },
1726
1756
  h("div", { ref: panelRef, style: {
@@ -1733,8 +1763,8 @@ window.__ModuleLoader__.load({
1733
1763
  // 左边缘拖拽条(改宽)
1734
1764
  h("div", {
1735
1765
  onPointerDown: onResize,
1736
- title: "拖动调整面板宽度",
1737
- "aria-label": "拖动调整面板宽度",
1766
+ title: t("拖动调整面板宽度"),
1767
+ "aria-label": t("拖动调整面板宽度"),
1738
1768
  style: {
1739
1769
  position: "absolute", top: 0, bottom: 0, left: -3, width: 7,
1740
1770
  cursor: "col-resize", pointerEvents: "auto", zIndex: 1,
@@ -1765,10 +1795,11 @@ window.__ModuleLoader__.load({
1765
1795
  }
1766
1796
 
1767
1797
  // ---------- cordis plugin body ----------
1768
- // 不写死 injectbetter-sidebar 是可选集成,未安装时绝不能因为缺服务而让本
1769
- // 插件报错。改在 apply 里用 ctx.get('betterSidebar') 判空——一次性属性读取,
1770
- // I/O、零网络,毫秒级,不影响 DSH 启动速度。
1771
- const inject = [];
1798
+ // 声明 'locale'DSH 的客户端插件都靠 inject 声明保证服务先于 apply 就绪(loader
1799
+ // 依赖图排序)。client-locale web-app 核心服务(与 slots/connection 同级),
1800
+ // 必在 loader 树里;better-sidebar 仍是可选集成(不入 inject),照旧用
1801
+ // ctx.get('betterSidebar') 判空 + 延迟重试,未安装时绝不会因为缺服务而报错。
1802
+ const inject = ['locale'];
1772
1803
 
1773
1804
  // 是否已安装(并激活)dsh-better-sidebar:决定「③代码管理」是否隐藏本插件自带的
1774
1805
  // 本地 Git 工作流(暂存/提交/分支/历史/并排 diff)——这些能力 better-sidebar 的
@@ -1776,6 +1807,32 @@ window.__ModuleLoader__.load({
1776
1807
  let hasBetterSidebar = false;
1777
1808
 
1778
1809
  function apply(ctx) {
1810
+ // 接管 DSH 的语言设置:client-locale 插件提供 ctx.locale(LocaleRuntime),
1811
+ // t() 实时读它;语言切换经 subscribe 触发 useLocale 重渲染。
1812
+ // 注意:client-locale 可能比本插件晚激活(和 better-sidebar 同样的顺序问题),
1813
+ // 因此捕获要带重试;重试窗口内组件先以浏览器语言渲染,捕获后立即切到 DSH 设置。
1814
+ const captureLocale = () => {
1815
+ try {
1816
+ if (scmLocaleFace) return true;
1817
+ const lf = (ctx && ctx.locale) || (typeof ctx.get === "function" ? ctx.get("locale") : undefined);
1818
+ if (lf && typeof lf.getLocale === "function") {
1819
+ scmLocaleFace = lf;
1820
+ try { scmLang = lf.getLocale().active || scmLang } catch {}
1821
+ return true;
1822
+ }
1823
+ return false;
1824
+ } catch { return false }
1825
+ };
1826
+ if (!captureLocale()) {
1827
+ // 兜底:等 client-locale 激活后再补抓(单次延迟,零轮询、零 I/O)。
1828
+ window.setTimeout(() => {
1829
+ const ok = captureLocale();
1830
+ if (!ok && typeof console !== "undefined") {
1831
+ console.warn("[source-code-mgmt] DSH locale service not found — UI follows the browser language. Install/enable @deepseek-ai/dsh-client-locale for live language switching.");
1832
+ }
1833
+ }, 1200);
1834
+ }
1835
+
1779
1836
  // DSH 打开(插件激活)时就预取环境/SSH/默认工作区/仓库状态,
1780
1837
  // 点开「代码管理」面板时直接使用缓存,无需重新加载。
1781
1838
  void preload();
@@ -1791,14 +1848,31 @@ window.__ModuleLoader__.load({
1791
1848
  // 分支 A:已安装 dsh-better-sidebar —— 把「代码管理」注册成它的侧边栏新 Tab
1792
1849
  // 页面。ctx.effect 保证 HMR / 插件卸载时自动注销该 Tab。
1793
1850
  hasBetterSidebar = true;
1794
- ctx.effect(() => bs.registerTab({
1795
- id: PLUGIN_ID,
1796
- title: "代码管理",
1797
- icon: (size) => repoIcon(size),
1798
- order: 50,
1799
- single: true,
1800
- component: () => h(ScmPanel, { variant: "tab" }),
1801
- }));
1851
+ // 语言切换时实时更新 Tab 标题(title 变了才重注册,避免注册抖动)。
1852
+ let lastTabTitle = null;
1853
+ let tabDisposer = null;
1854
+ const registerTabNow = () => {
1855
+ const title = t("代码管理");
1856
+ if (title === lastTabTitle) return;
1857
+ if (typeof tabDisposer === "function") { try { tabDisposer() } catch {} }
1858
+ lastTabTitle = title;
1859
+ tabDisposer = bs.registerTab({
1860
+ id: PLUGIN_ID,
1861
+ title,
1862
+ icon: (size) => repoIcon(size),
1863
+ order: 50,
1864
+ single: true,
1865
+ component: () => h(ScmPanel, { variant: "tab" }),
1866
+ });
1867
+ };
1868
+ ctx.effect(() => {
1869
+ registerTabNow();
1870
+ return () => { if (typeof tabDisposer === "function") { try { tabDisposer() } catch {} } };
1871
+ });
1872
+ if (scmLocaleFace && typeof scmLocaleFace.subscribe === "function") {
1873
+ ctx.effect(() => scmLocaleFace.subscribe(() => { try { registerTabNow(); } catch {} }),
1874
+ 'source-code-mgmt: tab title locale sync');
1875
+ }
1802
1876
  // 若此前已挂载了分支 B 的 header 入口(降级路径),立即拆除它。
1803
1877
  if (entryUnmount) { entryUnmount(); entryUnmount = null; }
1804
1878
  return true;