dsh-folia 4.26.0-pre.37 → 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.
Files changed (2) hide show
  1. package/lib/client.js +37 -2
  2. package/package.json +1 -1
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 跟住最新值,操作进行中就不打扰用户。
@@ -35204,6 +35211,33 @@ window.__ModuleLoader__.load({
35204
35211
  const data = res.data;
35205
35212
  return (data && data.error) || weT("宿主返回 {status}", { status: res.status });
35206
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
+
35207
35241
  let inventorySeq = 0;
35208
35242
  async function loadInventory(opts) {
35209
35243
  const o = opts || {};
@@ -35235,6 +35269,7 @@ window.__ModuleLoader__.load({
35235
35269
  // 场景载荷的源(独立壁纸媒体源的 origin;空串 = 回落应用源,见 live-layer 的 liveRenderUrl)。
35236
35270
  sceneMediaBase: typeof data.sceneMediaBase === "string" ? data.sceneMediaBase : "",
35237
35271
  wallpapers: data.wallpapers || [],
35272
+ // 先按本地记忆补齐"已缓存",服务端这份才是权威(下面再写回记忆)
35238
35273
  total: data.total || 0,
35239
35274
  portableCount: data.portableCount || 0,
35240
35275
  playlists: Array.isArray(data.playlists) ? data.playlists : [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-folia",
3
- "version": "4.26.0-pre.37",
3
+ "version": "4.26.0-pre.38",
4
4
  "description": "DSH 壁纸引擎:本机 WE 壁纸实时渲染,视频/网页/开机动画/桌宠皮肤,一键拉取在线素材。",
5
5
  "type": "module",
6
6
  "engines": {