dsh-folia 4.26.0-pre.36 → 4.26.0-pre.38

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
@@ -17925,8 +17925,11 @@ window.__ModuleLoader__.load({
17925
17925
  row: { display: "flex", gap: "6px", alignItems: "center" },
17926
17926
  };
17927
17927
 
17928
+ /** 页签级缓存:切走再切回来直接用上一份清单渲染,网络在后台刷新("首次点击要等一会"的解药)。 */
17929
+ let BOOT_TAB_CACHE = null;
17930
+
17928
17931
  function BootTabPanel() {
17929
- const [state, setState] = React.useState(null);
17932
+ const [state, setState] = React.useState(BOOT_TAB_CACHE);
17930
17933
  const [busy, setBusy] = React.useState("");
17931
17934
  const [note, setNote] = React.useState(null);
17932
17935
  // C1:面板内预览(不用重启就能看到素材本身)
@@ -17950,6 +17953,7 @@ window.__ModuleLoader__.load({
17950
17953
  const resp = await apiJson("/boot/list" + (force ? "?refresh=1" : ""), { parse: "always" });
17951
17954
  const r = (resp && resp.data) || null;
17952
17955
  setState(r || { ok: false, clips: [], error: "network" });
17956
+ if (r) BOOT_TAB_CACHE = r;
17953
17957
  // 过期失败提示自愈:提示说"未落地",但列表里该条已经 installed ⇒ 清掉提示
17954
17958
  try {
17955
17959
  setNote((prev) => {
@@ -19885,8 +19889,11 @@ window.__ModuleLoader__.load({
19885
19889
  } catch { return false; }
19886
19890
  }
19887
19891
 
19892
+ /** 页签级缓存:切回来先渲染上一份清单,再后台刷新。 */
19893
+ let SKINS_TAB_CACHE = null;
19894
+
19888
19895
  function SkinsTabPanel() {
19889
- const [state, setState] = React.useState(null);
19896
+ const [state, setState] = React.useState(SKINS_TAB_CACHE);
19890
19897
  const [busy, setBusy] = React.useState("");
19891
19898
  // 给"静默对账"用的只读镜像:定时器/可见性回调里不能读闭包里的旧 `busy`(会一直看到 ""),
19892
19899
  // 用一个 ref 跟住最新值,操作进行中就不打扰用户。
@@ -20335,6 +20342,9 @@ window.__ModuleLoader__.load({
20335
20342
  });
20336
20343
  }
20337
20344
  if (kind === "remove") setNote({ ok: true, text: weT("已卸载:{name}", { name: label || "" }) });
20345
+ // 卸载成功后必须把这张卡片的失败/安装中状态清掉:
20346
+ // 真实事故 —— 卸完了,卡片还挂着上一轮「下载已完成但安装未落地 · 重试」,看着像没删掉。
20347
+ if (kind === "remove" && cardId) cards.end(cardId);
20338
20348
  if (kind === "repair") {
20339
20349
  setNote({
20340
20350
  ok: true,
@@ -24835,7 +24845,7 @@ window.__ModuleLoader__.load({
24835
24845
  */
24836
24846
 
24837
24847
  /** 每条壁纸最多自愈几次。超过就只提示 —— 防"每次 error 都重下"的死循环。 */
24838
- const LF_HEAL_MAX_TRIES = 2;
24848
+ const LF_HEAL_MAX_TRIES = 4;
24839
24849
  /** 轮询救援产物/重下的间隔与上限(转码是几十秒级的,给 3 分钟)。 */
24840
24850
  const LF_HEAL_POLL_MS = 1500;
24841
24851
  const LF_HEAL_POLL_MAX_MS = 3 * 60 * 1000;
@@ -35201,6 +35211,33 @@ window.__ModuleLoader__.load({
35201
35211
  const data = res.data;
35202
35212
  return (data && data.error) || weT("宿主返回 {status}", { status: res.status });
35203
35213
  }
35214
+ /* 已缓存角标的本地记忆:清单一到手先按上次的结论渲染,等服务端对账回来再校正。
35215
+ * 为什么需要:重启后第一次进面板,服务端清单里的 localReady 还没算完,角标会集体消失;
35216
+ * 用户点一下才恢复。记一份 id 集合就能"看起来一直是对的"。 */
35217
+ const FOLIA_LOCAL_READY_KEY = 'folia.localReady.v1';
35218
+ function foliaLocalReadyRead() {
35219
+ try {
35220
+ const raw = window.localStorage.getItem(FOLIA_LOCAL_READY_KEY);
35221
+ const arr = raw ? JSON.parse(raw) : [];
35222
+ return new Set(Array.isArray(arr) ? arr.map(String) : []);
35223
+ } catch { return new Set(); }
35224
+ }
35225
+ function foliaLocalReadyWrite(set) {
35226
+ try { window.localStorage.setItem(FOLIA_LOCAL_READY_KEY, JSON.stringify([...set].slice(-500))); } catch { /* 只读环境 */ }
35227
+ }
35228
+ function foliaHydrateLocalReady(list) {
35229
+ const known = foliaLocalReadyRead();
35230
+ if (!known.size) return;
35231
+ for (const w of list || []) {
35232
+ if (w && !w.localReady && known.has(String(w.id))) w.localReady = true;
35233
+ }
35234
+ }
35235
+ function foliaPersistLocalReady(list) {
35236
+ const next = foliaLocalReadyRead();
35237
+ for (const w of list || []) if (w && w.localReady === true) next.add(String(w.id));
35238
+ foliaLocalReadyWrite(next);
35239
+ }
35240
+
35204
35241
  let inventorySeq = 0;
35205
35242
  async function loadInventory(opts) {
35206
35243
  const o = opts || {};
@@ -35232,6 +35269,7 @@ window.__ModuleLoader__.load({
35232
35269
  // 场景载荷的源(独立壁纸媒体源的 origin;空串 = 回落应用源,见 live-layer 的 liveRenderUrl)。
35233
35270
  sceneMediaBase: typeof data.sceneMediaBase === "string" ? data.sceneMediaBase : "",
35234
35271
  wallpapers: data.wallpapers || [],
35272
+ // 先按本地记忆补齐"已缓存",服务端这份才是权威(下面再写回记忆)
35235
35273
  total: data.total || 0,
35236
35274
  portableCount: data.portableCount || 0,
35237
35275
  playlists: Array.isArray(data.playlists) ? data.playlists : [],
@@ -374,7 +374,9 @@ async function fetchSiteSkins(force) { const now = Date.now();
374
374
  // 4.23.7:站点给的内容哈希(**可能为空**)。有它 ⇒ 下载完要验内容,
375
375
  // 不只是验长度/区间(见 lib/download-queue.js 的 assertContentHash)。
376
376
  sha256: it && it.sha256 ? String(it.sha256) : '',
377
- thumbUrl: it.thumbUrl ? String(it.thumbUrl) : '',
377
+ // 封面:站点上「缩略图」和「首帧海报」是两个字段。
378
+ // 皮肤包没有首帧,后台补的是 poster ⇒ 这里必须回退,否则卡片永远是空白。
379
+ thumbUrl: it.thumbUrl ? String(it.thumbUrl) : (it.posterUrl ? String(it.posterUrl) : ''),
378
380
  // 站点现在把 tags 直接给**数组**(旧版给的是字符串化 JSON)。两种都收:
379
381
  // 只认字符串会让「动态」这类标记静默丢失(实测:线上返回 ["皮肤","catppuccin",…])。
380
382
  tags: (() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-folia",
3
- "version": "4.26.0-pre.36",
3
+ "version": "4.26.0-pre.38",
4
4
  "description": "DSH 壁纸引擎:本机 WE 壁纸实时渲染,视频/网页/开机动画/桌宠皮肤,一键拉取在线素材。",
5
5
  "type": "module",
6
6
  "engines": {