dsh-folia 4.12.2 → 4.12.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/client.js +29 -7
  2. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -18353,10 +18353,12 @@ window.__ModuleLoader__.load({
18353
18353
  // 走宿主代理会 401 —— DSH 对 `/api/skin-center/v2/*` 的读写都做会话鉴权,宿主 fetch 没有 cookie。
18354
18354
  if (kind === "activate") {
18355
18355
  const wantId = (payload && payload.id) || null;
18356
- // 只允许切到本机已装的那几套(state.installed 是权威清单)
18356
+ // ⚠️ 这里写入的必须是**皮肤中心自己认识的 id**(= skin.json 里的原始 id),
18357
+ // 不能用归一键:归一只是用来"比对",拿去当写值会变成另一个名字 ——
18358
+ // 皮肤中心的 activePostHandler 对解析不到的 id 回 404 skin-not-found(实测报错 skin-center-404)。
18357
18359
  if (wantId) {
18358
- const known = ((state && state.installed) || []).some((s) => normSkinId(s.id) === normSkinId(wantId));
18359
- if (!known) {
18360
+ const local = ((state && state.installed) || []).find((s) => s.id === wantId);
18361
+ if (!local) {
18360
18362
  setNote({ ok: false, text: weT("这个皮肤不在本机(先安装)") });
18361
18363
  return;
18362
18364
  }
@@ -18470,6 +18472,23 @@ window.__ModuleLoader__.load({
18470
18472
  const activeId = (state && state.active) || "";
18471
18473
  /** 这个 id 是不是"正在用"的那套(两边都归一后比,站点 slug 可能带 skin- 前缀)。 */
18472
18474
  const isActiveSkin = (id) => Boolean(activeId) && normSkinId(activeId) === normSkinId(id);
18475
+
18476
+ /**
18477
+ * 站点条目 → 本机已装皮肤的真实 id(皮肤中心只认这个)。
18478
+ *
18479
+ * 站点 slug 由标题生成、并为"全站唯一"可能被加 `skin-` 前缀;本机目录/皮肤中心用的是
18480
+ * skin.json 里的 id。两者可能不同(实测:站点 windows-xp-luna ↔ 本机 xp)。
18481
+ * 先按归一的 id 比,再按标题兜底;都没有就返回空串(表示"本机没有这一套")。
18482
+ */
18483
+ const localIdOf = (siteItem) => {
18484
+ const list = (state && state.installed) || [];
18485
+ const byId = list.find((x) => normSkinId(x.id) === normSkinId(siteItem.id));
18486
+ if (byId) return byId.id;
18487
+ const wantTitle = String((siteItem && siteItem.title) || "").trim();
18488
+ if (!wantTitle) return "";
18489
+ const byTitle = list.find((x) => String(x.name || "").trim() === wantTitle);
18490
+ return byTitle ? byTitle.id : "";
18491
+ };
18473
18492
  if (state) {
18474
18493
  children.push(React.createElement("div", { key: "installed-head", className: "we-picker__hint" },
18475
18494
  weT("本机已装({n})", { n: installed.length }),
@@ -18528,6 +18547,10 @@ window.__ModuleLoader__.load({
18528
18547
  ? [React.createElement("span", { key: "none", className: "we-picker__hint" }, weT("站点上还没有皮肤。"))]
18529
18548
  : site.map((s) => {
18530
18549
  const busyThis = busy === "install:" + s.id;
18550
+ // 站点条目的 slug 与本机皮肤 id **不一定相同**(站点 slug 由标题生成/为避撞名会加 skin- 前缀),
18551
+ // 而皮肤中心只认 skin.json 里的原始 id ⇒ 写之前必须换成**本机那个 id**,
18552
+ // 否则它的 activePostHandler 会回 404 skin-not-found(实测报错 skin-center-404)。
18553
+ const localId = localIdOf(s);
18531
18554
  return React.createElement("div", { key: s.id, style: SKIN_STYLE.card },
18532
18555
  s.thumbUrl
18533
18556
  ? React.createElement("div", {
@@ -18541,16 +18564,15 @@ window.__ModuleLoader__.load({
18541
18564
  s.installed
18542
18565
  // 已装的站点卡片也要能**直接应用**:用户是照着站点缩略图挑的,
18543
18566
  // 让他再滚回上面的「本机已装」区去点一次是多余的一步(实测反馈)。
18544
- // 站点 slug 与本机目录名可能差一个 `skin-` 前缀 ⇒ 用归一后的比较。
18545
18567
  ? [
18546
- isActiveSkin(s.id)
18568
+ localId && isActiveSkin(localId)
18547
18569
  ? React.createElement("span", { key: "on", style: { ...SKIN_STYLE.badge, background: "rgba(60,160,90,0.55)" } }, weT("使用中"))
18548
18570
  : React.createElement("button", {
18549
18571
  key: "apply",
18550
18572
  className: "we-picker__btn", type: "button",
18551
18573
  disabled: Boolean(busy),
18552
- onClick: () => act("activate", { id: normSkinId(s.id) }, s.title),
18553
- }, busy === "activate:" + normSkinId(s.id) ? weT("切换中…") : weT("应用")),
18574
+ onClick: () => act("activate", { id: localId }, s.title),
18575
+ }, busy === "activate:" + localId ? weT("切换中…") : weT("应用")),
18554
18576
  React.createElement("span", { key: "done", style: SKIN_STYLE.badge }, weT("已安装")),
18555
18577
  ]
18556
18578
  : React.createElement("button", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-folia",
3
- "version": "4.12.2",
3
+ "version": "4.12.3",
4
4
  "description": "Folia 壁纸引擎:把本机 Wallpaper Engine 壁纸搬进 DSH 界面(场景实时渲染 / 视频 / 网页),内置液态玻璃与 Folia 吉祥物,并可从自建站点拉取壁纸。单包形态(组件已合并)。",
5
5
  "type": "module",
6
6
  "engines": {