dsh-folia 4.10.0 → 4.12.2

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/cordis.patch.yml CHANGED
@@ -1,16 +1,23 @@
1
- # dsh-plugin-folia bundle patch — single-row form.
1
+ # dsh-plugin-folia bundle patch.
2
2
  #
3
- # This bundle used to contribute EIGHT host rows (the plugin itself plus seven
4
- # subpackage rows: about-notice / mascot-avatar / media-bridge / fonts / fx /
5
- # parallax / pet-link). Those seven now live in this package under
6
- # `lib/components/` and are mounted from `apply()` in `lib/index.js`, so the row
7
- # set is exactly one row: this bundle.
3
+ # Row set: this bundle + the skin centre it brings along.
8
4
  #
9
- # Why the merge (see lib/index.js "BUNDLE-MERGE"): each subpackage browser half
10
- # used to reach the host half through `require('<main package name>')`, which is
11
- # the most fragile edge in the plugin — it broke every time the main package was
12
- # renamed, and an id mismatch silently blanked the font / effect panels. One
13
- # package means no cross-package module id at all.
5
+ # ── 为什么这里有第二条 row ──────────────────────────────────────────────────
6
+ # 我们不再自己实现皮肤渲染:皮肤包(`skin.json` + `skin.css` + 可选 `hooks.mjs`)由
7
+ # `@linxin666/dsh-client-ui-skin-center` 加载与启用,我们的「助手皮肤」页签只负责把站点 zip
8
+ # 解到它读的那个目录(`$DSH_HOME/skins`)。所以它必须是**装得上的**:本包把它列为
9
+ # `dependencies`,并在下面插一条 row —— 用户装 dsh-folia 就同时得到两件套,不用再单独装。
10
+ #
11
+ # ── 重复 row 为什么不会打起来(实测依据,不是猜测)────────────────────────
12
+ # 1) 宿主半边:它的 `apply` 走 `mountOnce('@linxin666/dsh-client-ui-skin-center', …)`,
13
+ # 以 `globalThis[Symbol.for('dsh-web.mounted-plugins')]` 记账 ⇒ 第二次挂载是空操作,
14
+ # 不会重复注册 webserver 路由。
15
+ # 2) 客户端半边:它的设置分区注册包在 `try { ctx.slots.register(...) } catch { return () => {} }`,
16
+ # 重复注册被吞掉 ⇒ 不会出现两张「皮肤」设置页。
17
+ # 于是「用户已有 dsh-web-all(它也插了一条 row)」与「只用我们」两种情形都成立。
18
+ #
19
+ # 版本:依赖写 `^0.4.8`(本仓实测过的版本线);它若大改 v1alpha1 契约,我们跟着升级即可。
20
+ # 判据:test/verify-skin-center-bundle.mjs 会同时钉住「声明了依赖」与「插了唯一 id 的 row」。
14
21
  #
15
22
  # A patch replaces the targeted row's whole `config`, so only additive `insert`
16
23
  # rows appear here (we never override an existing shipped row).
@@ -18,3 +25,13 @@
18
25
  - insert:
19
26
  - id: folia
20
27
  name: 'dsh-folia'
28
+ # 皮肤中心:独立 npm 包(BSD-3-Clause),本包作为依赖携带。
29
+ #
30
+ # ⚠️ row id **不能**以 `folia-` 开头:`lib/subpackage-boot.js#subpackageSpecifiers` 把
31
+ # 「id 以 `folia-` 开头的行」当作**我们自己的子包行**做启动自检(解析不到就抛,因为宿主
32
+ # 对行级失败是静默的)。给第三方行起 `folia-skin-center` 这种 id 会被误判成"我们的子包"
33
+ # ⇒ 自检去仓库 node_modules 里解析它,开发树里没有这个依赖就直接抛,整个 apply 失败。
34
+ # 所以这里用不撞前缀的 `skin-center`(也与 web-all 的 `web-ui-skin-center`、
35
+ # 官方包的 `ui-skin-center` 都不同名)。
36
+ - id: skin-center
37
+ name: '@linxin666/dsh-client-ui-skin-center'
package/lib/client.js CHANGED
@@ -801,6 +801,31 @@ window.__ModuleLoader__.load({
801
801
  "下载地址不在白名单里": "The download host is not allow-listed",
802
802
  "站点被关闭了(DSH_FOLIA_SITE=off)": "The site is disabled (DSH_FOLIA_SITE=off)",
803
803
  "这个文件不是 zip": "This file is not a zip",
804
+
805
+ // ── 助手皮肤:皮肤中心缺失时的引导(4.10.1)──────────────────────────
806
+ "皮肤中心没装:它是**独立插件** @linxin666/dsh-client-ui-skin-center(不在 dsh-web-all 里,那个只是聚合包)。装它才能启用皮肤:": "The skin centre is not installed: it is its own plugin, @linxin666/dsh-client-ui-skin-center (dsh-web-all is only an aggregate). Install it to enable skins:",
807
+ "已复制安装命令": "Install command copied",
808
+ "复制失败,请手动选中上面的命令": "Copy failed — select the command above manually",
809
+ "复制命令": "Copy command",
810
+ "先装皮肤中心,否则皮肤装好也没法启用": "Install the skin centre first, or the skin cannot be enabled",
811
+
812
+ // ── 助手皮肤:页签内直接切换(4.12.0)────────────────────────────────
813
+ " · 使用中:{name}": " · active: {name}",
814
+ "✓ ": "✓ ",
815
+ "正在恢复…": "Restoring…",
816
+ "恢复默认外观": "Restore default look",
817
+ "应用": "Apply",
818
+ "切换中…": "Switching…",
819
+ "使用中": "Active",
820
+ "正在使用,先切到别的再卸": "Currently active — switch to another skin before removing",
821
+ "已切换到:{name}": "Switched to: {name}",
822
+ "已恢复官方默认外观": "Restored the default look",
823
+ "这个皮肤不在本机(先安装)": "This skin is not installed locally — install it first",
824
+ "装皮肤中心后才能切换皮肤(见下面的安装命令)": "The skin centre is required to switch skins (install command below)",
825
+ "皮肤 id 不合法": "Invalid skin id",
826
+ "已安装:{name} —— 点「应用」就能切换": "Installed: {name} — press Apply to switch",
827
+ "本页签可以直接切换皮肤:装完点「应用」即可,无需打开设置页。皮肤包落在皮肤中心目录,两边读同一份。":
828
+ "This tab switches skins directly: install, then press Apply — no need to open the settings page. Packs land in the skin centre's folder and both sides read the same files.",
804
829
  };
805
830
 
806
831
  // ── 内联模块:src/i18n-copy-picker.js —— 英文词表域:壁纸选择器与快捷面板(picker-* · quick-panel · sidebar-right · theme-follow)(构建期注入;勿手改本段)──
@@ -18272,6 +18297,16 @@ window.__ModuleLoader__.load({
18272
18297
  return (v / 1048576).toFixed(1) + " MB";
18273
18298
  }
18274
18299
 
18300
+ /**
18301
+ * 皮肤 id 的归一键:站点上的 slug 是**全站唯一**的,撞名时上传工具会加 `skin-` 前缀
18302
+ * (实测:blue-throated-bee-eater 同时是桌宠 id ⇒ 站上叫 skin-blue-throated-bee-eater),
18303
+ * 而本机目录名用的是 skin.json 里的原始 id。两边比对必须先归一,否则"已安装"会显示成未安装。
18304
+ */
18305
+ function normSkinId(raw) {
18306
+ const s = String(raw || "").trim().toLowerCase();
18307
+ return s.startsWith("skin-") ? s.slice(5) : s;
18308
+ }
18309
+
18275
18310
  function SkinsTabPanel() {
18276
18311
  const [state, setState] = React.useState(null);
18277
18312
  const [busy, setBusy] = React.useState("");
@@ -18282,6 +18317,17 @@ window.__ModuleLoader__.load({
18282
18317
  const resp = await apiJson("/skins/list" + (force ? "?refresh=1" : ""), { parse: "always" });
18283
18318
  const doc = (resp && resp.data) || null;
18284
18319
  if (resp && resp.ok && doc && doc.ok) {
18320
+ // 读"当前在用哪套皮肤"必须**由浏览器发**,不能走宿主代理:
18321
+ // `/api/skin-center/v2/*` 的读写被 DSH 自己的会话鉴权挡着,宿主 fetch 没有 cookie
18322
+ // ⇒ 代理拿到 401(实测报错「操作失败:skin-center-401」)。
18323
+ // 但**不许裸 fetch**(src/api-client.js 的不变量:业务代码零裸 fetch)——
18324
+ // apiUrl() 对带 scheme 的地址原样放行,而 location.origin 是同源 ⇒ 照旧带会话。
18325
+ if (doc.skinCenter === "present") {
18326
+ try {
18327
+ const a = await apiJson(location.origin + "/api/skin-center/v2/active", { parse: "always" });
18328
+ if (a && a.ok) doc.active = (a.data && a.data.active) || "";
18329
+ } catch { /* 读不到就显示"无使用中" */ }
18330
+ }
18285
18331
  setState(doc);
18286
18332
  if (doc.siteError && doc.siteError !== "site-off") {
18287
18333
  setNote({ ok: false, text: weT("站点清单读不到:{msg}", { msg: String(doc.siteError) }) });
@@ -18297,10 +18343,45 @@ window.__ModuleLoader__.load({
18297
18343
  React.useEffect(() => { load(false); }, [load]);
18298
18344
 
18299
18345
  const act = async (kind, payload, label) => {
18346
+ // 结构性操作才锁整块 UI;`activate` 是幂等的、而且要让人能连点换皮肤,所以不锁。
18300
18347
  const structural = kind === "install" || kind === "remove";
18301
18348
  if (structural) setBusy(kind + ":" + ((payload && payload.id) || ""));
18349
+ if (kind === "activate") setBusy("activate:" + ((payload && payload.id) || ""));
18302
18350
  setNote(null);
18303
18351
  try {
18352
+ // 切换皮肤**由浏览器直接写**皮肤中心自己的端点(同源请求自带会话);
18353
+ // 走宿主代理会 401 —— DSH 对 `/api/skin-center/v2/*` 的读写都做会话鉴权,宿主 fetch 没有 cookie。
18354
+ if (kind === "activate") {
18355
+ const wantId = (payload && payload.id) || null;
18356
+ // 只允许切到本机已装的那几套(state.installed 是权威清单)
18357
+ if (wantId) {
18358
+ const known = ((state && state.installed) || []).some((s) => normSkinId(s.id) === normSkinId(wantId));
18359
+ if (!known) {
18360
+ setNote({ ok: false, text: weT("这个皮肤不在本机(先安装)") });
18361
+ return;
18362
+ }
18363
+ }
18364
+ // 切换皮肤**由浏览器直接写**皮肤中心自己的端点(同源、自带会话);
18365
+ // 走宿主代理会 401 —— DSH 对 `/api/skin-center/v2/*` 的读写都做会话鉴权,宿主 fetch 没有 cookie。
18366
+ // 统一走 api-client(不裸 fetch):绝对 URL 原样放行,`location.origin` 是同源 ⇒ 会话照旧带上。
18367
+ const resp = await apiPostJson(location.origin + "/api/skin-center/v2/active", { active: wantId }, { parse: "always" });
18368
+ if (!(resp && resp.ok)) {
18369
+ setNote({ ok: false, text: weT("操作失败:{code}", { code: "skin-center-" + ((resp && resp.status) || 0) }) });
18370
+ return;
18371
+ }
18372
+ // 两条收敛路径:① 广播皮肤中心自己监听的 `dsh-skin-applied`(立即就地切换);
18373
+ // ② 它另外每 2 秒轮询 /api/skin-center/v2/active(事件丢了也会在 2 秒内跟上)。
18374
+ try {
18375
+ window.dispatchEvent(new CustomEvent("dsh-skin-applied", { detail: { id: wantId } }));
18376
+ } catch { /* 老环境没有 CustomEvent 也无所谓,②会兜住 */ }
18377
+ setNote({
18378
+ ok: true,
18379
+ text: wantId ? weT("已切换到:{name}", { name: label || "" }) : weT("已恢复官方默认外观"),
18380
+ });
18381
+ await load(true);
18382
+ return;
18383
+ }
18384
+
18304
18385
  const resp = await apiPostJson("/skins/" + kind, payload || {}, { parse: "always" });
18305
18386
  const r = (resp && resp.data) || null;
18306
18387
  if (resp && resp.ok && r && r.ok) {
@@ -18309,7 +18390,7 @@ window.__ModuleLoader__.load({
18309
18390
  ok: true,
18310
18391
  text: r.exists
18311
18392
  ? weT("已安装过:{name}", { name: label || "" })
18312
- : weT("已安装:{name} —— 到「设置 → 皮肤中心」点它即可启用", { name: label || "" }),
18393
+ : weT("已安装:{name} —— 点「应用」就能切换", { name: label || "" }),
18313
18394
  });
18314
18395
  }
18315
18396
  if (kind === "remove") setNote({ ok: true, text: weT("已卸载:{name}", { name: label || "" }) });
@@ -18323,6 +18404,9 @@ window.__ModuleLoader__.load({
18323
18404
  'host-not-allowed': weT("下载地址不在白名单里"),
18324
18405
  'site-off': weT("站点被关闭了(DSH_FOLIA_SITE=off)"),
18325
18406
  'not-a-zip': weT("这个文件不是 zip"),
18407
+ 'not-installed': weT("这个皮肤不在本机(先安装)"),
18408
+ 'skin-center-missing': weT("装皮肤中心后才能切换皮肤(见下面的安装命令)"),
18409
+ 'bad-id': weT("皮肤 id 不合法"),
18326
18410
  };
18327
18411
  setNote({ ok: false, text: map[code] || weT("操作失败:{code}", { code }) });
18328
18412
  }
@@ -18343,11 +18427,33 @@ window.__ModuleLoader__.load({
18343
18427
  }, weT("刷新")),
18344
18428
  ));
18345
18429
 
18346
- children.push(React.createElement("div", {
18347
- key: "hint",
18348
- className: "we-picker__hint",
18349
- style: { margin: "6px 0 4px", opacity: 0.8 },
18350
- }, weT("皮肤包安装到皮肤中心目录;装完到「设置 → 皮肤中心」里点选即可启用。皮肤中心与本插件读同一个目录,无需重启。")));
18430
+ // 皮肤中心在不在,决定这段提示说什么:
18431
+ // 在 → "装完去皮肤中心点它"(本页签只负责落盘)
18432
+ // 不在 → 明说它是个**独立插件**(不在 dsh-web-all 里),给一条可复制的安装命令
18433
+ // unknown(探测失败)→ 保守地按"在"讲,不吓唬用户
18434
+ const skinCenter = (state && state.skinCenter) || "unknown";
18435
+ if (skinCenter === "absent") {
18436
+ children.push(React.createElement("div", {
18437
+ key: "hint-absent",
18438
+ className: "we-picker__hint",
18439
+ style: { margin: "6px 0 4px", color: "#ffd08a", lineHeight: "1.6" },
18440
+ }, weT("皮肤中心没装:它是**独立插件** @linxin666/dsh-client-ui-skin-center(不在 dsh-web-all 里,那个只是聚合包)。装它才能启用皮肤:")));
18441
+ children.push(React.createElement("div", { key: "cmd", style: { display: "flex", gap: "8px", alignItems: "center", margin: "0 0 6px" } },
18442
+ React.createElement("code", {
18443
+ style: { fontSize: "11px", padding: "3px 8px", borderRadius: "6px", background: "rgba(255,255,255,0.08)" },
18444
+ }, "dsh plugin --profile web add @linxin666/dsh-client-ui-skin-center"),
18445
+ React.createElement("button", {
18446
+ className: "we-picker__btn", type: "button",
18447
+ onClick: () => { try { navigator.clipboard.writeText("dsh plugin --profile web add @linxin666/dsh-client-ui-skin-center"); setNote({ ok: true, text: weT("已复制安装命令") }); } catch { setNote({ ok: false, text: weT("复制失败,请手动选中上面的命令") }); } },
18448
+ }, weT("复制命令")),
18449
+ ));
18450
+ } else {
18451
+ children.push(React.createElement("div", {
18452
+ key: "hint",
18453
+ className: "we-picker__hint",
18454
+ style: { margin: "6px 0 4px", opacity: 0.8 },
18455
+ }, weT("本页签可以直接切换皮肤:装完点「应用」即可,无需打开设置页。皮肤包落在皮肤中心目录,两边读同一份。")));
18456
+ }
18351
18457
 
18352
18458
  // 提示行常驻占位(与开机动画/桌宠页签同一条纪律:不因 note 出现/消失让面板跳高度)
18353
18459
  children.push(React.createElement("div", {
@@ -18361,25 +18467,56 @@ window.__ModuleLoader__.load({
18361
18467
  }, note ? note.text : "\u00a0"));
18362
18468
 
18363
18469
  const installed = (state && state.installed) || [];
18470
+ const activeId = (state && state.active) || "";
18471
+ /** 这个 id 是不是"正在用"的那套(两边都归一后比,站点 slug 可能带 skin- 前缀)。 */
18472
+ const isActiveSkin = (id) => Boolean(activeId) && normSkinId(activeId) === normSkinId(id);
18364
18473
  if (state) {
18365
18474
  children.push(React.createElement("div", { key: "installed-head", className: "we-picker__hint" },
18366
- weT("本机已装({n})", { n: installed.length })));
18475
+ weT("本机已装({n})", { n: installed.length }),
18476
+ activeId ? weT(" · 使用中:{name}", { name: activeId }) : ""));
18477
+ // 「恢复默认」:清空选择、回到官方外观。只有确实有皮肤在用的时候才有意义。
18478
+ if (activeId) {
18479
+ children.push(React.createElement("button", {
18480
+ key: "clear",
18481
+ className: "we-picker__btn", type: "button",
18482
+ style: { alignSelf: "flex-start", margin: "0 0 6px" },
18483
+ disabled: Boolean(busy),
18484
+ onClick: () => act("activate", { id: "" }, ""),
18485
+ }, busy === "activate:" ? weT("正在恢复…") : weT("恢复默认外观")));
18486
+ }
18367
18487
  children.push(React.createElement("div", { key: "installed", style: SKIN_STYLE.grid },
18368
18488
  installed.length === 0
18369
18489
  ? [React.createElement("span", { key: "none", className: "we-picker__hint" }, weT("还没有安装任何皮肤 —— 从下面的站点清单里挑一个。"))]
18370
- : installed.map((s) => React.createElement("div", { key: s.id, style: SKIN_STYLE.card },
18371
- React.createElement("div", { style: { ...SKIN_STYLE.title, color: s.accent || undefined } }, s.name || s.id),
18490
+ : installed.map((s) => {
18491
+ const isActive = isActiveSkin(s.id);
18492
+ const busyThis = busy === "activate:" + s.id;
18493
+ return React.createElement("div", {
18494
+ key: s.id,
18495
+ style: isActive ? { ...SKIN_STYLE.card, borderColor: "rgba(120,220,150,0.75)" } : SKIN_STYLE.card,
18496
+ },
18497
+ React.createElement("div", { style: { ...SKIN_STYLE.title, color: s.accent || undefined } },
18498
+ (isActive ? weT("✓ ") : "") + (s.name || s.id)),
18372
18499
  React.createElement("div", { style: SKIN_STYLE.meta },
18373
18500
  [s.version ? "v" + s.version : "", skinFmtBytes(s.bytes), s.hasHooks ? weT("含动效钩子") : ""]
18374
18501
  .filter(Boolean).join(" · ")),
18375
18502
  React.createElement("div", { style: { display: "flex", gap: "6px", alignItems: "center" } },
18503
+ // 「应用」= 写皮肤中心的 active + 广播 `dsh-skin-applied`,就地切换(不刷新页面)。
18504
+ isActive
18505
+ ? React.createElement("span", { style: { ...SKIN_STYLE.badge, background: "rgba(60,160,90,0.55)" } }, weT("使用中"))
18506
+ : React.createElement("button", {
18507
+ className: "we-picker__btn", type: "button",
18508
+ disabled: Boolean(busy),
18509
+ onClick: () => act("activate", { id: s.id }, s.name),
18510
+ }, busyThis ? weT("切换中…") : weT("应用")),
18376
18511
  React.createElement("button", {
18377
18512
  className: "we-picker__btn", type: "button",
18378
- disabled: Boolean(busy),
18513
+ disabled: Boolean(busy) || isActive,
18514
+ title: isActive ? weT("正在使用,先切到别的再卸") : undefined,
18379
18515
  onClick: () => act("remove", { id: s.id }, s.name),
18380
18516
  }, busy === "remove:" + s.id ? weT("卸载中…") : weT("卸载")),
18381
18517
  ),
18382
- )),
18518
+ );
18519
+ }),
18383
18520
  ));
18384
18521
  }
18385
18522
 
@@ -18400,13 +18537,29 @@ window.__ModuleLoader__.load({
18400
18537
  React.createElement("div", { style: SKIN_STYLE.title, title: s.title }, s.title),
18401
18538
  React.createElement("div", { style: SKIN_STYLE.meta },
18402
18539
  [skinFmtBytes(s.bytes), (s.tags || []).includes("动态") ? weT("动态") : ""].filter(Boolean).join(" · ")),
18403
- s.installed
18404
- ? React.createElement("div", { style: SKIN_STYLE.badge }, weT("已安装"))
18405
- : React.createElement("button", {
18406
- className: "we-picker__btn", type: "button",
18407
- disabled: Boolean(busy),
18408
- onClick: () => act("install", { id: s.id, url: s.url }, s.title),
18409
- }, busyThis ? weT("安装中…") : weT("安装")),
18540
+ React.createElement("div", { style: { display: "flex", gap: "6px", alignItems: "center", flexWrap: "wrap" } },
18541
+ s.installed
18542
+ // 已装的站点卡片也要能**直接应用**:用户是照着站点缩略图挑的,
18543
+ // 让他再滚回上面的「本机已装」区去点一次是多余的一步(实测反馈)。
18544
+ // 站点 slug 与本机目录名可能差一个 `skin-` 前缀 ⇒ 用归一后的比较。
18545
+ ? [
18546
+ isActiveSkin(s.id)
18547
+ ? React.createElement("span", { key: "on", style: { ...SKIN_STYLE.badge, background: "rgba(60,160,90,0.55)" } }, weT("使用中"))
18548
+ : React.createElement("button", {
18549
+ key: "apply",
18550
+ className: "we-picker__btn", type: "button",
18551
+ disabled: Boolean(busy),
18552
+ onClick: () => act("activate", { id: normSkinId(s.id) }, s.title),
18553
+ }, busy === "activate:" + normSkinId(s.id) ? weT("切换中…") : weT("应用")),
18554
+ React.createElement("span", { key: "done", style: SKIN_STYLE.badge }, weT("已安装")),
18555
+ ]
18556
+ : React.createElement("button", {
18557
+ className: "we-picker__btn", type: "button",
18558
+ disabled: Boolean(busy),
18559
+ title: skinCenter === "absent" ? weT("先装皮肤中心,否则皮肤装好也没法启用") : undefined,
18560
+ onClick: () => act("install", { id: s.id, url: s.url }, s.title),
18561
+ }, busyThis ? weT("安装中…") : weT("安装")),
18562
+ ),
18410
18563
  );
18411
18564
  }),
18412
18565
  ));
@@ -49,6 +49,30 @@ function siteBase() {
49
49
  return base.replace(/\/+$/, '');
50
50
  }
51
51
 
52
+ /**
53
+ * 皮肤中心是否在线。
54
+ *
55
+ * 为什么由宿主探而不是前端探:两个插件跑在同一个 webServer 上,用请求自带的 Host 就能问到自己 ——
56
+ * 前端也能问,但宿主这一侧拿到的结果与"装没装"一一对应,而且不受浏览器缓存/跨源策略影响。
57
+ * 判据用**它自己的 catalog 路由**:该路由不需要鉴权(实测 200),404 就是没装。
58
+ */
59
+ const skinCenterProbe = { at: 0, state: 'unknown' };
60
+ async function probeSkinCenter(hostHeader, force) {
61
+ const now = Date.now();
62
+ if (!force && skinCenterProbe.at && now - skinCenterProbe.at < 30000) return skinCenterProbe.state;
63
+ let state = 'unknown';
64
+ if (hostHeader) {
65
+ try {
66
+ const r = await fetch('http://' + hostHeader + '/api/skin-center/v2/catalog', { signal: AbortSignal.timeout(4000) });
67
+ state = r.status === 404 ? 'absent' : (r.ok ? 'present' : 'present');
68
+ // 401/403 也说明插件在(只是该路由被别的版本加了鉴权);只有 404 才代表没装。
69
+ } catch { state = 'unknown'; }
70
+ }
71
+ skinCenterProbe.at = now;
72
+ skinCenterProbe.state = state;
73
+ return state;
74
+ }
75
+
52
76
  /** 站点列表缓存(30 秒):面板打开与"刷新"共用,避免每次都打站点。 */
53
77
  const siteCache = { at: 0, items: [], error: null };
54
78
  const SITE_TTL_MS = 30000;
@@ -238,6 +262,7 @@ export function registerSkinsRoutes(webServer, c) {
238
262
  const force = /[?&]refresh=1/.test(req.url || '');
239
263
  const site = await fetchSiteSkins(force);
240
264
  const installed = listInstalled();
265
+ const skinCenter = await probeSkinCenter(req.headers && req.headers.host, force);
241
266
  // ⚠️ 站点 slug 与本机皮肤 id **不总是同一个字符串**:站点上 slug 是全站唯一的,
242
267
  // 撞名时上传工具会加 `skin-` 前缀(实测 blue-throated-bee-eater 同时是桌宠 id)。
243
268
  // 所以比对要归一:两边都去掉可选的 `skin-` 前缀再比,否则会显示成"未安装"。
@@ -248,6 +273,7 @@ export function registerSkinsRoutes(webServer, c) {
248
273
  }
249
274
  sendJson(res, 200, {
250
275
  ok: true,
276
+ skinCenter,
251
277
  siteBase: siteBase(),
252
278
  siteError: site.error,
253
279
  installed,
@@ -365,4 +391,7 @@ export function registerSkinsRoutes(webServer, c) {
365
391
  sendJson(res, 200, { ok: true, id });
366
392
  },
367
393
  }));
394
+
395
+ // 切换皮肤与"当前皮肤"都由**浏览器**直接读写皮肤中心的 /api/skin-center/v2/active:
396
+ // DSH 对该路径的读写做会话鉴权(cookie),宿主 fetch 没有会话 ⇒ 代理只会得到 401(实测)。
368
397
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-folia",
3
- "version": "4.10.0",
3
+ "version": "4.12.2",
4
4
  "description": "Folia 壁纸引擎:把本机 Wallpaper Engine 壁纸搬进 DSH 界面(场景实时渲染 / 视频 / 网页),内置液态玻璃与 Folia 吉祥物,并可从自建站点拉取壁纸。单包形态(组件已合并)。",
5
5
  "type": "module",
6
6
  "engines": {
@@ -193,6 +193,7 @@
193
193
  }
194
194
  },
195
195
  "dependencies": {
196
+ "@linxin666/dsh-client-ui-skin-center": "^0.4.8",
196
197
  "webwallgl": "^3.0.0",
197
198
  "x11": "^4.3.1"
198
199
  },