dsh-folia 4.26.0-pre.37 → 4.26.0-pre.39

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 +59 -3
  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 跟住最新值,操作进行中就不打扰用户。
@@ -20337,7 +20344,18 @@ window.__ModuleLoader__.load({
20337
20344
  if (kind === "remove") setNote({ ok: true, text: weT("已卸载:{name}", { name: label || "" }) });
20338
20345
  // 卸载成功后必须把这张卡片的失败/安装中状态清掉:
20339
20346
  // 真实事故 —— 卸完了,卡片还挂着上一轮「下载已完成但安装未落地 · 重试」,看着像没删掉。
20340
- if (kind === "remove" && cardId) cards.end(cardId);
20347
+ if (kind === "remove" && cardId) {
20348
+ cards.end(cardId);
20349
+ // 卸载成功 = 这台机器上已经没有它了:把"曾经装好"的记忆也清掉,
20350
+ // 否则站点卡片会继续渲染「已安装」(真实反馈:卸了两次,徽标还挂着)。
20351
+ if (typeof cards.clearOk === "function") cards.clearOk(cardId);
20352
+ // 卸载后立刻就地改状态:
20353
+ // 否则等 load(true) 回来之前,卡片仍按旧的 installed=true 渲染 ⇒ "点了卸载,卡片闪一下又回来"。
20354
+ setState((prev) => {
20355
+ if (!prev || !Array.isArray(prev.site)) return prev;
20356
+ return { ...prev, site: prev.site.map((x) => (x && x.id === cardId ? { ...x, installed: false } : x)) };
20357
+ });
20358
+ }
20341
20359
  if (kind === "repair") {
20342
20360
  setNote({
20343
20361
  ok: true,
@@ -25394,6 +25412,16 @@ window.__ModuleLoader__.load({
25394
25412
  * 而不是静默回到「安装」——那正是"点了没反应"的另一种样子。
25395
25413
  */
25396
25414
  markOk: (id) => { setOkIds((m) => (m[key(id)] ? m : { ...m, [key(id)]: true })); },
25415
+ // 卸载成功后必须把它忘掉:否则卡片会一直按"已安装"渲染(站点已删、徽标还在)。
25416
+ clearOk: (id) => {
25417
+ const k = key(id);
25418
+ setOkIds((m) => {
25419
+ if (!m[k]) return m;
25420
+ const n = { ...m };
25421
+ delete n[k];
25422
+ return n;
25423
+ });
25424
+ },
25397
25425
  okOf: (id) => Boolean(okIds[key(id)]),
25398
25426
  subOf: (id) => (sub && key(sub.id) === key(id) ? sub : null),
25399
25427
  errOf: (id) => errs[key(id)] || null,
@@ -35204,6 +35232,33 @@ window.__ModuleLoader__.load({
35204
35232
  const data = res.data;
35205
35233
  return (data && data.error) || weT("宿主返回 {status}", { status: res.status });
35206
35234
  }
35235
+ /* 已缓存角标的本地记忆:清单一到手先按上次的结论渲染,等服务端对账回来再校正。
35236
+ * 为什么需要:重启后第一次进面板,服务端清单里的 localReady 还没算完,角标会集体消失;
35237
+ * 用户点一下才恢复。记一份 id 集合就能"看起来一直是对的"。 */
35238
+ const FOLIA_LOCAL_READY_KEY = 'folia.localReady.v1';
35239
+ function foliaLocalReadyRead() {
35240
+ try {
35241
+ const raw = window.localStorage.getItem(FOLIA_LOCAL_READY_KEY);
35242
+ const arr = raw ? JSON.parse(raw) : [];
35243
+ return new Set(Array.isArray(arr) ? arr.map(String) : []);
35244
+ } catch { return new Set(); }
35245
+ }
35246
+ function foliaLocalReadyWrite(set) {
35247
+ try { window.localStorage.setItem(FOLIA_LOCAL_READY_KEY, JSON.stringify([...set].slice(-500))); } catch { /* 只读环境 */ }
35248
+ }
35249
+ function foliaHydrateLocalReady(list) {
35250
+ const known = foliaLocalReadyRead();
35251
+ if (!known.size) return;
35252
+ for (const w of list || []) {
35253
+ if (w && !w.localReady && known.has(String(w.id))) w.localReady = true;
35254
+ }
35255
+ }
35256
+ function foliaPersistLocalReady(list) {
35257
+ const next = foliaLocalReadyRead();
35258
+ for (const w of list || []) if (w && w.localReady === true) next.add(String(w.id));
35259
+ foliaLocalReadyWrite(next);
35260
+ }
35261
+
35207
35262
  let inventorySeq = 0;
35208
35263
  async function loadInventory(opts) {
35209
35264
  const o = opts || {};
@@ -35235,6 +35290,7 @@ window.__ModuleLoader__.load({
35235
35290
  // 场景载荷的源(独立壁纸媒体源的 origin;空串 = 回落应用源,见 live-layer 的 liveRenderUrl)。
35236
35291
  sceneMediaBase: typeof data.sceneMediaBase === "string" ? data.sceneMediaBase : "",
35237
35292
  wallpapers: data.wallpapers || [],
35293
+ // 先按本地记忆补齐"已缓存",服务端这份才是权威(下面再写回记忆)
35238
35294
  total: data.total || 0,
35239
35295
  portableCount: data.portableCount || 0,
35240
35296
  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.39",
4
4
  "description": "DSH 壁纸引擎:本机 WE 壁纸实时渲染,视频/网页/开机动画/桌宠皮肤,一键拉取在线素材。",
5
5
  "type": "module",
6
6
  "engines": {