dsh-multipane 1.0.10 → 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +12 -0
  2. package/lib/client.js +153 -28
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -246,6 +246,18 @@ C:\Users\weiai\.dsh\plugin-src\_probe\sync-client.ps1 -Push # 台式机 ->
246
246
 
247
247
  ## 更新记录
248
248
 
249
+ ### 1.0.12(2026-11-10)
250
+ - 修上一版读取更新结果的两个字段:`restartRequired` 实际在 `outcome` 里、失败原因在 `failure.message`(不在顶层)。
251
+ 之前会把「需要重启」误判成「刷新即可」,失败时也只显示状态名而不是市场给的原因。
252
+
253
+ ### 1.0.11(2026-11-10)
254
+ - **插件内一键更新**:设置页的「检查更新」改为走插件市场(dshmarket)的公开 update API v1 —— 发现新版直接给「立即更新」按钮,
255
+ 由插件市场负责装包、校验版本、保留回滚点;完成后按它返回的 `refreshRequired` / `restartRequired` 告诉你刷新还是重启
256
+ (桌面版实测 `restart.supported=false`,一般**刷新页面即可**)。市场没装时自动回退成「查 npm + 提示手动安装」。
257
+ - **检查更新有明确反馈**:正在检查 / 已是最新(绿)/ 发现新版(黄,带「立即更新」)/ 失败(红),四种状态各自变色,不再"点了没反应"。
258
+ - **预览不再画多余元素**:标签之间的那条竖线(重排插入线)平时不显示,只在鼠标移到「重排插入线浓度」那一行时出现;
259
+ 同理,鼠标移到「悬停时浓度」时预览会把「悬停」标签框出来 —— 这两个设置都不是摆设,只是默认状态下的差异太细看不出来。
260
+
249
261
  ### 1.0.10(2026-11-10)
250
262
  - **修「关掉多栏视图后侧栏样式还在」**:关闭时只清了 `data-dsv-row`,没有删除插件自己的样式表——而其中
251
263
  `[data-row-key^="session:"]:not([data-dsv-row]) * { opacity: .5 }` 这条**不需要任何行标记**,
package/lib/client.js CHANGED
@@ -17,8 +17,15 @@ window.__ModuleLoader__.load({
17
17
  */
18
18
  const PLUGIN_LABEL = "多栏视图";
19
19
  /* 与 package.json 的 version 必须一致(发版时两处同改;check-names.cjs 会校验)。 */
20
- const PLUGIN_VERSION = "1.0.10";
20
+ const PLUGIN_VERSION = "1.0.12";
21
21
  const NPM_LATEST_URL = "https://registry.npmjs.org/dsh-multipane/latest";
22
+ /* 插件市场的公开更新 API v1(dshmarket 提供,见其 UPDATE-API-V1.md)。
23
+ 它自己负责装包/校验版本/回滚,我们只负责触发和显示结果——
24
+ 不要再自己去跑 npm install,那会覆盖正在运行的文件。 */
25
+ const PKG_NAME = "dsh-multipane";
26
+ const MARKET_CAPS_URL = "/dsh-market/api/v1/capabilities";
27
+ const MARKET_UPDATES_URL = "/dsh-market/api/v1/updates";
28
+ const MARKET_OPS_URL = "/dsh-market/api/v1/operations";
22
29
  /* 按 x.y.z 数值比较,不能用字符串比大小:字典序下 "1.0.10" < "1.0.9",
23
30
  而且降级场景(本地 1.0.10、线上 1.0.9)会被误判成「有新版本」。 */
24
31
  function compareVersion(a, b) {
@@ -1797,8 +1804,10 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
1797
1804
  /* 版本 / 检查更新:一行文字 + 一个按钮,失败也不挡路 */
1798
1805
  .dsv-update-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap;padding:0 2px 4px}
1799
1806
  .dsv-update-text{font-size:11.5px;line-height:1.6;opacity:.62}
1800
- .dsv-update-text[data-new="1"]{opacity:1;color:#7bd88f}
1801
- .dsv-update-text[data-err="1"]{opacity:.95;color:#e08888}
1807
+ .dsv-update-text[data-phase="latest"]{opacity:1;color:#7bd88f}
1808
+ .dsv-update-text[data-phase="done"]{opacity:1;color:#7bd88f}
1809
+ .dsv-update-text[data-phase="available"],.dsv-update-text[data-phase="available-manual"]{opacity:1;color:#e8c07a}
1810
+ .dsv-update-text[data-phase="error"]{opacity:.95;color:#e08888}
1802
1811
  .dsv-page-title-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
1803
1812
  .dsv-page-title{font-size:19px;font-weight:700;letter-spacing:.01em;margin:0}
1804
1813
  .dsv-badge{display:inline-flex;align-items:center;gap:5px;height:20px;padding:0 8px;border-radius:999px;font-size:11px;font-weight:600;border:1px solid transparent}
@@ -1875,7 +1884,11 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
1875
1884
  /* 第三个标签固定画「鼠标悬停在非焦点栏上」那一态:否则调「悬停时浓度」时预览毫无变化。 */
1876
1885
  .dsv-pv-tab[data-hover="1"]{opacity:.86;background:var(--dsv-tab-hover-bg,rgba(167,170,175,.08));border-color:var(--dsv-tab-hover-border,rgba(167,170,175,.22));box-shadow:inset 0 calc(-1 * var(--dsv-tab-w,2px)) 0 var(--dsv-tab-hover,rgba(167,170,175,.45))}
1877
1886
  .dsv-pv-tabs{overflow:hidden}
1878
- .dsv-pv-caret{flex:0 0 auto;width:2px;align-self:stretch;margin:4px 1px;border-radius:1px;background:var(--dsv-misc-c,#a7aaaf);opacity:var(--dsv-misc-caret,.45)}
1887
+ .dsv-pv-caret{flex:0 0 auto;width:2px;align-self:stretch;margin:4px 1px;border-radius:1px;background:var(--dsv-misc-c,#a7aaaf);opacity:0}
1888
+ /* 只在鼠标进入「重排插入线浓度」那一行时出现,并在预览里框出来 */
1889
+ .dsv-preview[data-hl="caret"] .dsv-pv-caret{opacity:var(--dsv-misc-caret,.45);outline:1px dashed rgba(255,255,255,.55);outline-offset:2px}
1890
+ /* 「悬停时浓度」同理:调它时把预览里的「悬停」标签框出来,否则变化太细看不出来 */
1891
+ .dsv-preview[data-hl="hovertab"] .dsv-pv-tab[data-hover="1"]{outline:1px dashed rgba(255,255,255,.55);outline-offset:2px}
1879
1892
  .dsv-pv-divider{flex:0 0 7px;position:relative}
1880
1893
  .dsv-pv-divider::after{content:"";position:absolute;top:5px;bottom:5px;left:2px;width:var(--dsv-div-w,2px);border-radius:calc(var(--dsv-div-w,2px) / 2);background:var(--dsv-div-soft,rgba(167,170,175,.85))}
1881
1894
  .dsv-pv-body{flex:1 1 auto;min-height:46px;display:flex;flex-direction:column;justify-content:center;gap:6px;padding:8px 10px;position:relative}
@@ -5518,9 +5531,20 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
5518
5531
  /** 一条 0–100 的滑杆(内部存 0–1)。 */
5519
5532
  function AppearanceSlider(props) {
5520
5533
  const pct = Math.round(props.value * 100);
5534
+ /* hl / onHl:鼠标移到这一行时让预览把「对应元素」框出来。
5535
+ 有些设置(悬停浓度、重排插入线)在静态预览里差异极细,
5536
+ 不指出「你正在调的是哪一块」,用户会以为设置没生效。 */
5521
5537
  return h(
5522
5538
  "div",
5523
- { className: "dsv-ctl" },
5539
+ {
5540
+ className: "dsv-ctl",
5541
+ onMouseEnter: () => {
5542
+ if (typeof props.onHl === "function" && typeof props.hl === "string") props.onHl(props.hl);
5543
+ },
5544
+ onMouseLeave: () => {
5545
+ if (typeof props.onHl === "function") props.onHl("");
5546
+ }
5547
+ },
5524
5548
  h(
5525
5549
  "div",
5526
5550
  { className: "dsv-ctl-head" },
@@ -6087,8 +6111,10 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
6087
6111
  h(AppearanceSlider, {
6088
6112
  key: "h",
6089
6113
  label: "悬停时浓度",
6090
- hint: "鼠标移到非焦点栏上时的过渡值",
6114
+ hint: "鼠标移到非焦点栏上时,那一栏当前标签的下划线与淡底有多浓(把鼠标移到这一行,预览里会框出「悬停」标签)",
6091
6115
  value: a.tabline.hover,
6116
+ hl: "hovertab",
6117
+ onHl: setHover,
6092
6118
  onChange: (value) => setGroup("tabline", { hover: value })
6093
6119
  })
6094
6120
  ]
@@ -6239,8 +6265,10 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
6239
6265
  h(AppearanceSlider, {
6240
6266
  key: "c2",
6241
6267
  label: "重排插入线浓度",
6242
- hint: "拖动标签换位时那条细竖线",
6268
+ hint: "拖动标签换位时,标出「将插到这里」的那条细竖线(平时不存在;把鼠标移到这一行才在预览里显示)",
6243
6269
  value: a.misc.caret,
6270
+ hl: "caret",
6271
+ onHl: setHover,
6244
6272
  onChange: (value) => setGroup("misc", { caret: value })
6245
6273
  })
6246
6274
  ],
@@ -6367,19 +6395,102 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
6367
6395
  const toggle = () => {
6368
6396
  prefs.update({ enabled: !p.enabled });
6369
6397
  };
6370
- /* 检查更新:只读 registry,不下载、不写盘、不改设置。失败也只显示一行红字。 */
6371
- const [update, setUpdate] = react.useState({ checking: false, latest: "", newer: false, error: "" });
6398
+ /* 检查更新 + 一键更新。
6399
+ 首选插件市场的公开更新 API(GET/POST /dsh-market/api/v1/updates):
6400
+ 它自己负责装包、校验版本、保留回滚点,并且明确返回 refreshRequired / restartRequired。
6401
+ 市场没装或接口不可用时,回退成「直接查 npm registry + 提示手动安装」。
6402
+ 注意:**不要自己跑 npm install** —— 会覆盖正在运行的插件文件,破坏市场的一致性校验。 */
6403
+ const [update, setUpdate] = react.useState({ phase: "idle", text: "", canUpdate: false, opId: "" });
6372
6404
  const checkUpdate = async () => {
6373
- setUpdate((prev) => ({ ...prev, checking: true, error: "" }));
6405
+ setUpdate({ phase: "checking", text: "正在检查…", canUpdate: false, opId: "" });
6374
6406
  try {
6407
+ const capsRes = await fetch(MARKET_CAPS_URL, { cache: "no-store" });
6408
+ if (capsRes.ok === true) {
6409
+ const caps = await capsRes.json();
6410
+ if ((caps && caps.features && caps.features.check) !== true) throw new Error("插件市场未启用更新检查");
6411
+ const res = await fetch(`${MARKET_UPDATES_URL}?name=${PKG_NAME}&force=1`, { cache: "no-store" });
6412
+ if (res.ok !== true) throw new Error(`HTTP ${res.status}`);
6413
+ const data = await res.json();
6414
+ const info = data === null || data === void 0 ? void 0 : data.package;
6415
+ if (info === void 0 || info === null) throw new Error("返回里没有版本信息");
6416
+ const installed = String(info.installedVersion ?? PLUGIN_VERSION);
6417
+ const latest = String(info.latestVersion ?? installed);
6418
+ setUpdate(
6419
+ info.updateAvailable === true
6420
+ ? { phase: "available", text: `发现新版本 ${latest}(当前 ${installed})`, canUpdate: true, opId: "" }
6421
+ : { phase: "latest", text: `已是最新版本(${installed})`, canUpdate: false, opId: "" }
6422
+ );
6423
+ return;
6424
+ }
6375
6425
  const res = await fetch(`${NPM_LATEST_URL}?t=${Date.now()}`, { cache: "no-store" });
6376
6426
  if (res.ok !== true) throw new Error(`HTTP ${res.status}`);
6377
6427
  const data = await res.json();
6378
6428
  const latest = String((data && data.version) || "");
6379
6429
  if (latest === "") throw new Error("返回里没有版本号");
6380
- setUpdate({ checking: false, latest, newer: compareVersion(latest, PLUGIN_VERSION) > 0, error: "" });
6430
+ const newer = compareVersion(latest, PLUGIN_VERSION) > 0;
6431
+ setUpdate({
6432
+ phase: newer ? "available-manual" : "latest",
6433
+ text: newer ? `发现新版本 ${latest}(当前 ${PLUGIN_VERSION}):到「插件」页填 ${PKG_NAME}@${latest} 安装` : `已是最新版本(${PLUGIN_VERSION})`,
6434
+ canUpdate: false,
6435
+ opId: ""
6436
+ });
6437
+ } catch (err) {
6438
+ setUpdate({ phase: "error", text: `检查失败:${String((err && err.message) || err)}`, canUpdate: false, opId: "" });
6439
+ }
6440
+ };
6441
+ const runUpdate = async () => {
6442
+ setUpdate({ phase: "updating", text: "正在更新…", canUpdate: false, opId: "" });
6443
+ try {
6444
+ const res = await fetch(MARKET_UPDATES_URL, {
6445
+ method: "POST",
6446
+ headers: { "Content-Type": "application/json" },
6447
+ body: JSON.stringify({ packageName: PKG_NAME })
6448
+ });
6449
+ if (res.status !== 202) {
6450
+ let detail = "";
6451
+ try {
6452
+ detail = String((await res.json()).message ?? "");
6453
+ } catch {
6454
+ /* 忽略 */
6455
+ }
6456
+ throw new Error(`HTTP ${res.status}${detail === "" ? "" : ":" + detail}`);
6457
+ }
6458
+ const created = await res.json();
6459
+ const opId = String((created && created.operationId) || "");
6460
+ if (opId === "") throw new Error("没有返回操作 id");
6461
+ setUpdate((prev) => ({ ...prev, opId }));
6462
+ for (let step = 0; step < 80; step += 1) {
6463
+ await new Promise((resolve) => setTimeout(resolve, 1500));
6464
+ const poll = await fetch(`${MARKET_OPS_URL}?operationId=${encodeURIComponent(opId)}`, { cache: "no-store" });
6465
+ if (poll.ok !== true) continue;
6466
+ const body = await poll.json();
6467
+ const op = body === null || body === void 0 ? void 0 : body.operation ?? body;
6468
+ if (op === null || op === void 0) continue;
6469
+ const state = String(op.state ?? "");
6470
+ if (state === "succeeded") {
6471
+ const got = String(op.installedVersion ?? "");
6472
+ /* restartRequired / refreshRequired 都在 outcome 里(实测 2026-11-10),不在顶层 */
6473
+ const outcome = op.outcome === null || op.outcome === void 0 ? {} : op.outcome;
6474
+ const needRestart = outcome.restartRequired === true;
6475
+ setUpdate({
6476
+ phase: "done",
6477
+ text: `已更新${got === "" ? "" : "到 " + got}${needRestart ? ",重启 App 后生效" : ",刷新页面即可生效"}`,
6478
+ canUpdate: false,
6479
+ opId
6480
+ });
6481
+ return;
6482
+ }
6483
+ if (state === "failed" || state === "cancelled" || state === "rolled-back") {
6484
+ /* 失败详情在 failure: {code, message, retryable}(实测 2026-11-10) */
6485
+ const fail = op.failure === null || op.failure === void 0 ? {} : op.failure;
6486
+ throw new Error(String(fail.message ?? fail.code ?? state));
6487
+ }
6488
+ const pct = op.progress === null || op.progress === void 0 ? void 0 : op.progress.percent;
6489
+ setUpdate((prev) => ({ ...prev, text: typeof pct === "number" ? `正在更新… ${Math.round(pct)}%` : "正在更新…" }));
6490
+ }
6491
+ throw new Error("等待超时,请到插件市场查看结果");
6381
6492
  } catch (err) {
6382
- setUpdate({ checking: false, latest: "", newer: false, error: String((err && err.message) || err) });
6493
+ setUpdate({ phase: "error", text: `更新失败:${String((err && err.message) || err)}`, canUpdate: false, opId: "" });
6383
6494
  }
6384
6495
  };
6385
6496
  return h(
@@ -6409,35 +6520,49 @@ const TAB_LABEL_CHROME_DOT_PX = 46;
6409
6520
  "把对话区变成可分栏的工作区:多个会话并排,各自有输入框、工具调用和插件面板。"
6410
6521
  )
6411
6522
  ),
6412
- /* 版本行:显示当前版本,点按钮去 npm 查最新版(纯前端,不改任何文件) */
6523
+ /* 版本行:当前版本 + 检查更新 + 有新版本时的一键更新(走插件市场 API) */
6413
6524
  h(
6414
6525
  "div",
6415
6526
  { className: "dsv-update-row" },
6416
6527
  h(
6417
6528
  "span",
6418
- {
6419
- className: "dsv-update-text",
6420
- "data-new": update.newer === true ? "1" : "0",
6421
- "data-err": update.error !== "" ? "1" : "0"
6422
- },
6423
- update.error !== ""
6424
- ? `检查更新失败:${update.error}`
6425
- : update.latest === ""
6426
- ? `当前版本 ${PLUGIN_VERSION}`
6427
- : update.newer === true
6428
- ? `有新版本 ${update.latest}(当前 ${PLUGIN_VERSION}):在「插件」页填 dsh-multipane@${update.latest} 安装,重启 App 生效`
6429
- : `已是最新版本(${PLUGIN_VERSION})`
6529
+ { className: "dsv-update-text", "data-phase": update.phase },
6530
+ update.text === "" ? `当前版本 ${PLUGIN_VERSION}` : update.text
6430
6531
  ),
6431
6532
  h(
6432
6533
  "button",
6433
6534
  {
6434
6535
  type: "button",
6435
6536
  className: "dsv-mini-btn",
6436
- disabled: update.checking === true,
6537
+ disabled: update.phase === "checking" || update.phase === "updating",
6437
6538
  onClick: checkUpdate
6438
6539
  },
6439
- update.checking === true ? "检查中…" : "检查更新"
6440
- )
6540
+ update.phase === "checking" ? "检查中…" : "检查更新"
6541
+ ),
6542
+ update.canUpdate === true
6543
+ ? h(
6544
+ "button",
6545
+ { type: "button", className: "dsv-mini-btn", "data-on": "1", onClick: runUpdate },
6546
+ "立即更新"
6547
+ )
6548
+ : null,
6549
+ update.phase === "done"
6550
+ ? h(
6551
+ "button",
6552
+ {
6553
+ type: "button",
6554
+ className: "dsv-mini-btn",
6555
+ onClick: () => {
6556
+ try {
6557
+ window.location.reload();
6558
+ } catch {
6559
+ /* 忽略 */
6560
+ }
6561
+ }
6562
+ },
6563
+ "刷新页面"
6564
+ )
6565
+ : null
6441
6566
  ),
6442
6567
  /* ── 区块一:基本 ── */
6443
6568
  h(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-multipane",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "Hermes-style tabbed workspace for the DSH main area: drag sessions in, split into up to four columns, close tabs.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",