dsh-folia 4.23.14 → 4.23.16

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
@@ -947,6 +947,38 @@ window.__ModuleLoader__.load({
947
947
  "清理失败:{error}": "Cleanup failed: {error}",
948
948
  "已清理 {name}:释放 {size}({n} 个文件)": "Cleared {name}: released {size} ({n} files)",
949
949
  "已清理 {name}:释放 {size}({n} 个文件);{failed} 个文件被占用,重启 DSH 后彻底生效": "Cleared {name}: released {size} ({n} files); {failed} file(s) in use will be removed after restarting DSH",
950
+
951
+ // ── 4.23.15「本地副本自愈」(播放失败 → 验内容 → 重下 / 换档 / 转码)───────────────
952
+ // 这三句是**给用户看的结论**,不是日志:它们回答"我刚点的那张为什么没出来、现在在干什么"。
953
+ "文件已损坏,已重新下载": "The local file was corrupted — re-downloading it now",
954
+ "已切换到 1080p(原画超出本机解码上限)": "Switched to 1080p (the original exceeds this machine's decode limit)",
955
+ "已切换到 30fps 副本(原画 60fps 超出本机解码能力,分辨率不变)": "Switched to a 30fps copy (the 60fps original exceeds this machine's decode capability; resolution unchanged)",
956
+ "正在生成可播放副本…": "Preparing a playable copy…",
957
+ "本机不支持该编码(可换一张跳过此壁纸)": "This machine cannot decode that codec (pick another wallpaper to skip it)",
958
+ "该壁纸分辨率/编码超出本机解码能力(可换一张跳过此壁纸)": "This wallpaper's resolution/codec exceeds this machine's decoding capability (pick another one to skip it)",
959
+ "重新获取失败(可稍后再点一次这张)": "Re-fetch failed (click this wallpaper again in a moment)",
960
+ "转码超时(可稍后再点一次这张,宿主会接着上次的进度)": "Transcoding timed out (click this wallpaper again later; the host resumes from its last progress)",
961
+ "{text} · {label}": "{text} · {label}",
962
+ // ── 4.23.15「本地媒体自检」读数与按钮(系统 → 缓存管理)────────────────────────
963
+ "损坏文件": "Corrupted files",
964
+ "个(已清理 {cleaned} / 待重下 {pending})": "(cleaned {cleaned} / pending re-download {pending})",
965
+ "未校验(进本页签时自动读一次)": "Not checked yet (read automatically when you open this tab)",
966
+ "重新读取校验账本(只读,不触发校验)": "Re-read the verification ledger (read-only, does not start a check)",
967
+ "校验中…": "Checking…",
968
+ "校验并修复本地媒体": "Verify and repair local media",
969
+ "逐个校验已下载的媒体文件(≤20MB 比 sha256,大文件比长度与 mp4 结构);发现坏文件就删掉并排回下载队列": "Verify every downloaded media file one by one (sha256 for files ≤20MB, length + MP4 structure for larger ones); corrupted files are deleted and queued for re-download",
970
+ "已校验 {n} 个文件:发现 {bad} 个损坏,已清理并排回下载队列": "Checked {n} file(s): found {bad} corrupted, cleaned up and re-queued for download",
971
+ "已校验 {n} 个文件:没有发现损坏": "Checked {n} file(s): nothing corrupted",
972
+ "校验失败:{error}": "Verification failed: {error}",
973
+ // ── 4.23.15「已按解码上限选 1080p」(卡片小标)──────────────────────────────
974
+ "已按解码上限选 1080p": "1080p chosen for decode limit",
975
+ "解码上限 · 1080p": "Decode limit · 1080p",
976
+ "已按解码上限选 1080p:原画 {w}×{h} 超出本机解码能力(播放器解不出来),改播 1080p 变体": "1080p chosen because of the decode limit: the original is {w}×{h}, beyond this machine's decoding capability (the player cannot decode it), so the 1080p variant is used",
977
+ // ── 4.23.15「转码进度 / 静态帧兜底」(用户最终目标:最终必须能上屏)───────────────
978
+ "正在生成本机可播放副本 {percent}%": "Preparing a playable copy on this machine… {percent}%",
979
+ "正在生成本机可播放副本 {percent}%(约剩 {eta} 秒)": "Preparing a playable copy on this machine… {percent}% (about {eta}s left)",
980
+ "已降级为静态壁纸(本机无法解码该视频)": "Fell back to a static wallpaper (this machine cannot decode the video)",
981
+ "无法显示这张壁纸(本机无法解码该视频,且没有可用的静态帧)": "Cannot display this wallpaper (this machine cannot decode the video and no static frame is available)",
950
982
  };
951
983
 
952
984
  // ── 内联模块:src/i18n-copy-picker.js —— 英文词表域:壁纸选择器与快捷面板(picker-* · quick-panel · sidebar-right · theme-follow)(构建期注入;勿手改本段)──
@@ -14402,6 +14434,9 @@ window.__ModuleLoader__.load({
14402
14434
  // 播放失败原因(#84): 浏览器解不了的编码 / 解码失败等 —— 给出可读原因,
14403
14435
  // 配合下面的「播放」按钮重试(不是静默空白)。
14404
14436
  sel.videoError && React.createElement("div", { className: "we-picker__current-error" }, sel.videoError),
14437
+ // 4.23.15:**自愈/本地优先**的信息类提示("已自动切换 1080p""正在下载到本地 45%"…)。
14438
+ // 与上面那条分开:那条是"红了",这条是"正在处理/已经换好了"。
14439
+ sel.mediaNote && React.createElement("div", { className: "we-picker__hint" }, sel.mediaNote),
14405
14440
  // 选择被过滤条件排除(#84): 明确指出是哪一项过滤挡住了、怎么恢复
14406
14441
  sel.blockedNote && React.createElement("div", { className: "we-picker__current-error" }, sel.blockedNote),
14407
14442
  // 实时渲染失败原因(自动回退到旧链时显示):让「为什么黑」可见 ——
@@ -16062,6 +16097,7 @@ window.__ModuleLoader__.load({
16062
16097
  */
16063
16098
  function renderCacheManagerBlock(ctx) {
16064
16099
  const { sel, onClearCache, onClearCacheSkins, onRefreshCacheUsage, armedConfirm, onDisarmConfirm } = ctx;
16100
+ const { onVerifyMedia, onRefreshMediaHealth } = ctx;
16065
16101
  const usage = sel && sel.cacheUsage;
16066
16102
  const items = (usage && Array.isArray(usage.items)) ? usage.items : [];
16067
16103
  const rowOf = (t) => items.find((x) => x && x.target === t) || null;
@@ -16088,6 +16124,14 @@ window.__ModuleLoader__.load({
16088
16124
  );
16089
16125
  };
16090
16126
  const pendingSkins = String(armedConfirm || "") === "cache:skins";
16127
+ // ── 4.23.15「本地媒体自检」读数:**损坏文件 N 个(已清理/待重下)** ──
16128
+ // 为什么放在缓存区而不新开一节:用户是在"我的缓存怎么了"这个问题下看到它的;
16129
+ // 而「系统」页签的节序列是 `verify-scene-live` 的硬锚,不能为一行统计新开一节。
16130
+ const health = sel && sel.mediaHealth;
16131
+ const bad = health ? Number(health.damaged) || 0 : 0;
16132
+ const cleaned = health ? Number(health.cleaned) || 0 : 0;
16133
+ const pending = health ? Number(health.pending) || 0 : 0;
16134
+ const verifying = Boolean(sel && sel.mediaVerifyBusy);
16091
16135
  return React.createElement(React.Fragment, null,
16092
16136
  // ⚠️ 这一行**故意不用** `we-picker__section-label`:那会把「缓存管理」算成第八个"节",
16093
16137
  // 改掉 `verify-scene-live` 的节序列锚(见上面"为什么放在同一个节里")。
@@ -16111,6 +16155,22 @@ window.__ModuleLoader__.load({
16111
16155
  line("skins-zip", weT("皮肤包")),
16112
16156
  line("skins", weT("已装皮肤")),
16113
16157
  line("electron", weT("Electron 缓存"), weT("需重启 DSH")),
16158
+ // ── 本地媒体自检(4.23.15)──────────────────────────────────────────────
16159
+ // 读数口径与宿主 `/folia/local-check` 逐字一致:`damaged` 是**累计发现**的坏文件,
16160
+ // `cleaned` 是其中已删并排回下载队列的,`pending` 是还没修好的(还在队列里等重下)。
16161
+ React.createElement("div", { className: "we-picker__row", key: "media-health" },
16162
+ React.createElement("span", { className: "we-picker__hint we-picker__label" }, weT("损坏文件")),
16163
+ React.createElement("span", { className: "we-picker__uploads-path" },
16164
+ health
16165
+ ? String(bad) + " " + weT("个(已清理 {cleaned} / 待重下 {pending})", { cleaned, pending })
16166
+ : weT("未校验(进本页签时自动读一次)")),
16167
+ React.createElement("button", {
16168
+ key: "media-health-refresh", type: "button", className: "we-picker__btn",
16169
+ disabled: verifying,
16170
+ title: weT("重新读取校验账本(只读,不触发校验)"),
16171
+ onClick: () => { try { onRefreshMediaHealth(); } catch { /* ignore */ } },
16172
+ }, weT("刷新")),
16173
+ ),
16114
16174
  React.createElement("div", { className: "we-picker__row", key: "cache-mgr-actions" },
16115
16175
  btn("clear-library", weT("清空媒体"), ["library"], weT("删除已下载的壁纸 / 开机动画 / 桌宠(可重新下载)")),
16116
16176
  btn("clear-site-media", weT("清空站点媒体"), ["site-media"]),
@@ -16136,7 +16196,17 @@ window.__ModuleLoader__.load({
16136
16196
  btn("clear-electron", weT("清空 Electron 缓存"), ["electron"], weT("清的是 Electron 自己的 Cache / GPUCache;占用中的文件请重启 DSH 后彻底生效")),
16137
16197
  btn("clear-all-but-skins", weT("一键清理(不含皮肤)"),
16138
16198
  ["library", "site-media", "skins-zip", "electron"], weT("清掉除「已装皮肤」以外的全部缓存")),
16199
+ // 「校验并修复本地媒体」(4.23.15)= **启动自检的全量版**:逐条比 size / sha256 /
16200
+ // mp4 结构,坏的删掉并排回下载队列。它不是"清理"(不清好文件),所以单独一颗。
16201
+ React.createElement("button", {
16202
+ key: "verify-media", type: "button", className: "we-picker__btn",
16203
+ disabled: verifying,
16204
+ title: weT("逐个校验已下载的媒体文件(≤20MB 比 sha256,大文件比长度与 mp4 结构);发现坏文件就删掉并排回下载队列"),
16205
+ onClick: () => { try { onVerifyMedia(); } catch { /* ignore */ } },
16206
+ }, verifying ? weT("校验中…") : weT("校验并修复本地媒体")),
16139
16207
  ),
16208
+ sel && sel.mediaVerifyNote
16209
+ && React.createElement("div", { className: "we-picker__hint", key: "media-verify-note" }, sel.mediaVerifyNote),
16140
16210
  sel && sel.cacheNote
16141
16211
  && React.createElement("div", { className: "we-picker__hint", key: "cache-mgr-note" }, sel.cacheNote),
16142
16212
  sel && sel.cacheError
@@ -16951,6 +17021,14 @@ window.__ModuleLoader__.load({
16951
17021
  !sel.batchMode && !draft && CARD_TYPE_LABELS[w.type]
16952
17022
  && React.createElement("span", { className: "we-picker__card-type" }, CARD_TYPE_LABELS[w.type]),
16953
17023
  React.createElement("span", { className: "we-picker__card-title" }, w.title),
17024
+ // 4.23.15:**已按解码上限选 1080p**。真实案例「原神 绫华」原画 5916×2530 ——
17025
+ // Chromium 根本解不出来。选档阶段避开它之后必须让用户**看得见**为什么下的是 1080p,
17026
+ // 否则他只会以为"画质被偷偷降了"。
17027
+ w.variantReason === "decode-limit"
17028
+ && React.createElement("span", {
17029
+ className: "we-picker__card-badge",
17030
+ title: weT("已按解码上限选 1080p:原画 {w}×{h} 超出本机解码能力(播放器解不出来),改播 1080p 变体", { w: w.width || "?", h: w.height || "?" }),
17031
+ }, weT("已按解码上限选 1080p")),
16954
17032
  w.type === "scene" && React.createElement("span", { className: "we-picker__card-badge" }, w.sceneLive ? weT("实时渲染") : weT("静态帧")),
16955
17033
  w.type === "web" && React.createElement("span", { className: "we-picker__card-badge" }, w.webLive ? weT("实时渲染") : weT("兼容模式")),
16956
17034
  (draft || sel.batchMode)
@@ -20297,6 +20375,13 @@ window.__ModuleLoader__.load({
20297
20375
  title: weT("已在本地缓存(原画或 1080p 任一档已落地),点它不必等网络"),
20298
20376
  }, weT("已缓存"))
20299
20377
  : null,
20378
+ // 4.23.15:**已按解码上限选 1080p**(与库视图同一句话、同一个判据源 `variantReason`)。
20379
+ w.variantReason === "decode-limit"
20380
+ ? React.createElement("span", {
20381
+ className: "we-qp__item-cached",
20382
+ title: weT("已按解码上限选 1080p:原画 {w}×{h} 超出本机解码能力(播放器解不出来),改播 1080p 变体", { w: w.width || "?", h: w.height || "?" }),
20383
+ }, weT("解码上限 · 1080p"))
20384
+ : null,
20300
20385
  w.id === sel.id
20301
20386
  ? React.createElement("span", { className: "we-qp__item-badge" }, weT("当前"))
20302
20387
  : React.createElement("span", { className: "we-qp__item-type" }, CARD_TYPE_LABELS[w.type] || weT("壁纸")),
@@ -22063,6 +22148,11 @@ window.__ModuleLoader__.load({
22063
22148
  screenHeight: lfScreenHeight(),
22064
22149
  };
22065
22150
  if (Array.isArray(it.variants) && it.variants.length) entry.variants = it.variants;
22151
+ // 4.23.15:原画的宽/高/帧率也带上 —— 宿主选档要按**解码上限**判(4K@60 与 5916×2530
22152
+ // 都是"链路再快也解不出来"的那一类)。缺就不发,宿主按兜底口径判。
22153
+ if (Number(it.width) > 0) entry.width = Number(it.width);
22154
+ if (Number(it.height) > 0) entry.height = Number(it.height);
22155
+ if (Number(it.fps) > 0) entry.fps = Number(it.fps);
22066
22156
  // 4.23.7:站点清单给的 sha256(部分条目为空)随条目带给队列 —— 下载完成后按它验内容。
22067
22157
  // 空串不发(宿主侧同样只认 64 位十六进制),免得把"没给"写成"给了个空的"。
22068
22158
  const sha = String(it.sha256 || "").trim().toLowerCase();
@@ -22947,6 +23037,283 @@ window.__ModuleLoader__.load({
22947
23037
  }
22948
23038
  }
22949
23039
 
23040
+ /* ── 播放失败自愈(4.23.15):本地副本坏了吗?还是本机解不了? ──────────────────
23041
+ *
23042
+ * 真实故障(另一台机器):壁纸显示「视频解码失败(文件可能已损坏)」/「浏览器无法解码这段
23043
+ * 视频」,而面板同时说"缓存命中 4/5"。播放路径直接读本地文件、**没有任何自检** ——
23044
+ * 4.23.6 之前 ranged 静默损坏遗留的坏成品会永久留在 library 里,每次点都是那句错误。
23045
+ *
23046
+ * 这一族只做客户端这一半:**判"要不要惊动宿主"** + **把宿主结论翻成人话**。
23047
+ * 真正的取证(sha256 / 结构 / 重下 / 换档 / 转码)在宿主 `lib/media-selfheal.js`,
23048
+ * 因为浏览器没有磁盘、也没有站点清单。
23049
+ *
23050
+ * 为什么客户端能判断"要不要惊动宿主":只有**本地副本**才值得验。远端字节我们既不能证明
23051
+ * 坏、也不能替站点重下(那只会让用户白等一次同样的解码失败)。
23052
+ */
23053
+
23054
+ /** 每条壁纸最多自愈几次。超过就只提示 —— 防"每次 error 都重下"的死循环。 */
23055
+ const LF_HEAL_MAX_TRIES = 2;
23056
+ /** 轮询救援产物/重下的间隔与上限(转码是几十秒级的,给 3 分钟)。 */
23057
+ const LF_HEAL_POLL_MS = 1500;
23058
+ const LF_HEAL_POLL_MAX_MS = 3 * 60 * 1000;
23059
+
23060
+ /** 每个壁纸 id 已经自愈过几次(会话内;刷新页面重新计数是合理的)。 */
23061
+ const LF_HEAL_TRIES = new Map();
23062
+
23063
+ /** 自愈要用到的两个宿主动作:提示位(面板那一行)与"重挂播放"(把新地址装回 <video>)。 */
23064
+ const LF_HEAL_HOOKS = { note: null, mount: null };
23065
+
23066
+ /**
23067
+ * client.js 注入:`note(text, ok)` 写面板提示;`mount(url)` 把播放器重挂到新地址(返回是否成功)。
23068
+ *
23069
+ * 为什么是注入而不是直接调:`local-first.js` 是**内联进同一个工厂作用域**的片段,
23070
+ * 但"提示位"与"哪个 <video> 在屏上"都只有 `src/client.js` 的正文知道;
23071
+ * 硬编码调用会把这条依赖变成隐式的循环(client.js ← local-first.js ← client.js)。
23072
+ */
23073
+ function setSelfHealHooks(note, mount) {
23074
+ LF_HEAL_HOOKS.note = typeof note === "function" ? note : null;
23075
+ LF_HEAL_HOOKS.mount = typeof mount === "function" ? mount : null;
23076
+ }
23077
+
23078
+ function lfHealSay(text, ok) {
23079
+ try { if (LF_HEAL_HOOKS.note) LF_HEAL_HOOKS.note(text, ok !== false); } catch { /* 提示失败不影响自愈 */ }
23080
+ }
23081
+
23082
+ /**
23083
+ * 这个播放地址是不是**本地副本**(`/folia/local-media/<id>` 或 library 目录直出)。
23084
+ *
23085
+ * 只认本地:远端 URL 的自愈没有意义(见上面那段"为什么客户端能判断")。
23086
+ */
23087
+ function lfIsLocalMediaUrl(url) {
23088
+ const s = String(url || "");
23089
+ if (!s) return false;
23090
+ if (/\/folia\/local-media\//.test(s)) return true;
23091
+ // 直出形态(旧宿主 / 排障时手工拼的地址):`.../library/<kind>/<hash>.mp4`
23092
+ return /\/library\/[^/]+\/[0-9a-f]{16,}\./i.test(s);
23093
+ }
23094
+
23095
+ /**
23096
+ * **要不要惊动宿主**(纯函数;判据见 `test/verify-media-selfheal.mjs`)。
23097
+ *
23098
+ * 只处理两件事都成立的那一格:① 播的是**本地副本**;② 错误码是**解码/源不支持**
23099
+ * (3 = DECODE,4 = SRC_NOT_SUPPORTED)。网络类(2 NETWORK)与中断类(1 ABORTED)
23100
+ * **不走自愈** —— 它们是"这一下没传完",重下只会把一份好文件换掉。
23101
+ *
23102
+ * 返回 `'heal'`(去验)/ `'skip'`(不动)。
23103
+ * @param {{ isVideo?: boolean, url?: string, code?: number, tries?: number, maxTries?: number }} [inp]
23104
+ * @returns {'heal' | 'skip'}
23105
+ */
23106
+ function dlHealPlan(inp) {
23107
+ const o = inp || {};
23108
+ if (o.isVideo === false) return "skip";
23109
+ if (!lfIsLocalMediaUrl(o.url)) return "skip";
23110
+ const code = Number(o.code) || 0;
23111
+ if (code !== 3 && code !== 4) return "skip";
23112
+ const max = Number(o.maxTries) > 0 ? Number(o.maxTries) : LF_HEAL_MAX_TRIES;
23113
+ if ((Number(o.tries) || 0) >= max) return "skip";
23114
+ return "heal";
23115
+ }
23116
+
23117
+ /**
23118
+ * 宿主的处置结论 → 一句**具体**的人话(纯函数)。
23119
+ *
23120
+ * 为什么每个结论一句不同的话:用户看到的三种情况看起来一模一样(都停在首帧/报错),
23121
+ * 但该做的事完全不同 —— 「已重新下载」是等它,「已切换 1080p」是等它,「本机不支持该编码」
23122
+ * 是**换一张**。用同一句"视频无法播放"会让用户反复点同一张。
23123
+ *
23124
+ * @param {string} verdict
23125
+ * @returns {string}
23126
+ */
23127
+ function dlHealNote(verdict) {
23128
+ const v = String(verdict || "");
23129
+ if (v === "corrupt") return weT("文件已损坏,已重新下载");
23130
+ if (v === "variant") return weT("已切换到 1080p(原画超出本机解码上限)");
23131
+ if (v === "transcoded") return weT("已切换到 1080p(原画超出本机解码上限)");
23132
+ if (v === "transcoding") return weT("正在生成可播放副本…");
23133
+ if (v === "undecodable") return weT("本机不支持该编码(可换一张跳过此壁纸)");
23134
+ if (v === "undecodable-no-variant") return weT("该壁纸分辨率/编码超出本机解码能力(可换一张跳过此壁纸)");
23135
+ return "";
23136
+ }
23137
+
23138
+ /** 这个结论是不是"还在路上"(要轮询),还是已经到达终态。 */
23139
+ function dlHealPending(verdict) {
23140
+ const v = String(verdict || "");
23141
+ return v === "corrupt" || v === "variant" || v === "transcoding";
23142
+ }
23143
+
23144
+ /**
23145
+ * 转码进度 → 一句**带数字**的话(用户明确要求:「转码期间必须有可见进度,不许静默」)。
23146
+ *
23147
+ * 为什么必须有 percent:整片重编码是几十秒到几分钟级,而此刻屏上是黑的 ——
23148
+ * **没有数字的等待与卡死没有区别**。eta 拿不到就只说百分比(不编数字)。
23149
+ * 也绝不报 100%:最后那一下是 rename + 校验,说满了却还没出画会让人更不信。
23150
+ *
23151
+ * @param {{ percent?: number, eta?: number | null } | null} [progress]
23152
+ * @returns {string}
23153
+ */
23154
+ function dlHealProgressNote(progress) {
23155
+ const pct = Math.max(0, Math.min(99, Math.round(Number(progress && progress.percent) || 0)));
23156
+ const eta = Number(progress && progress.eta);
23157
+ if (eta > 0 && isFinite(eta)) {
23158
+ return weT("正在生成本机可播放副本 {percent}%(约剩 {eta} 秒)", { percent: pct, eta: Math.max(1, Math.round(eta)) });
23159
+ }
23160
+ return weT("正在生成本机可播放副本 {percent}%", { percent: pct });
23161
+ }
23162
+
23163
+ /**
23164
+ * **"这张壁纸最终怎么上屏"的最后一级**(纯函数):转码也救不回来时,静态帧兜底。
23165
+ *
23166
+ * 需求原文(用户最终目标):**任何一张壁纸,只要站点上有可用文件,最终都必须能上屏** ——
23167
+ * 「只有连静态帧都没有,才允许显示无法显示」。所以这里是两级,不是一级:
23168
+ * `static-frame` —— 有缩略图/首帧 ⇒ 拿它当静态壁纸(画面是那张图,能看见)
23169
+ * `cannot-display` —— 连图都没有 ⇒ 这时才允许说"无法显示"
23170
+ * `''` —— 这个结论不归它管(corrupt/variant/transcoded 都还有得救)
23171
+ *
23172
+ * @param {{ verdict?: string, hasPreview?: boolean }} [inp]
23173
+ * @returns {'' | 'static-frame' | 'cannot-display'}
23174
+ */
23175
+ function dlHealFallbackPlan(inp) {
23176
+ const o = inp || {};
23177
+ const v = String(o.verdict || "");
23178
+ if (v !== "undecodable" && v !== "undecodable-no-variant") return "";
23179
+ return o.hasPreview === true ? "static-frame" : "cannot-display";
23180
+ }
23181
+
23182
+ /**
23183
+ * 等一条 job 落地(**只回答"盘上有这份成品了吗"**)。
23184
+ * 复用 `dlAwaitJob` 的轮询口径:done ⇒ true;failed/cancelled/消失 ⇒ false。
23185
+ * @param {string} jobId
23186
+ * @param {(n: number) => void} [onTick] 每次轮询回调(界面显示进度用)
23187
+ * @returns {Promise<boolean>}
23188
+ */
23189
+ async function lfAwaitHealJobP(jobId, onTick) {
23190
+ const id = String(jobId || "");
23191
+ if (!id) return false;
23192
+ const startedAt = Date.now();
23193
+ for (;;) {
23194
+ if (Date.now() - startedAt > LF_HEAL_POLL_MAX_MS) return false;
23195
+ let job = null;
23196
+ try {
23197
+ const resp = await apiJson("/downloads/list");
23198
+ const jobs = (resp && resp.data && Array.isArray(resp.data.jobs)) ? resp.data.jobs
23199
+ : (Array.isArray(resp && resp.jobs) ? resp.jobs : []);
23200
+ job = jobs.find((j) => j && j.id === id) || null;
23201
+ } catch { /* 网络抖动:下一拍再试 */ }
23202
+ if (job) {
23203
+ if (job.status === "done") return true;
23204
+ if (job.status === "failed" || job.status === "cancelled") return false;
23205
+ if (typeof onTick === "function") { try { onTick(Number(job.percent) || 0); } catch { /* ignore */ } }
23206
+ }
23207
+ await new Promise((r) => { const t = setTimeout(r, LF_HEAL_POLL_MS); try { if (t && t.unref) t.unref(); } catch { /* ignore */ } });
23208
+ }
23209
+ }
23210
+
23211
+ /**
23212
+ * **播放失败自愈的客户端入口**(`<video>` 报 error → 这里)。
23213
+ *
23214
+ * 流程:判要不要去 → `POST /folia/local-heal` → 按结论:
23215
+ * corrupt / variant ⇒ 拿新 jobId 等它落地 ⇒ 重挂播放(同一张壁纸的下一次播就是好的)
23216
+ * transcoding ⇒ 轮询同一个接口直到出片(宿主在后台转,重复调用会命中同一份在途任务)
23217
+ * transcoded ⇒ 立刻重挂到 `?playable=1`
23218
+ * undecodable* ⇒ 只提示(+ 建议换一张),不再重试
23219
+ *
23220
+ * 返回最终结论(供调用点写 `selection.videoError`)。**不抛**:自愈失败也只是一句提示,
23221
+ * 绝不把"播放已经坏了"的现场升级成"连界面都炸了"。
23222
+ *
23223
+ * @param {{ id?: string, url?: string, code?: number, isVideo?: boolean,
23224
+ * originUrl?: string, sha256?: string, variants?: any[], base?: string,
23225
+ * title?: string, playing1080p?: boolean }} [fail]
23226
+ * @returns {Promise<{ verdict: string, message: string, mounted: boolean }>}
23227
+ */
23228
+ async function lfHealPlayback(fail) {
23229
+ const f = fail || {};
23230
+ const key = String(f.id || f.url || "");
23231
+ const tried = Number(LF_HEAL_TRIES.get(key) || 0);
23232
+ const plan = dlHealPlan({ isVideo: f.isVideo !== false, url: f.url, code: f.code, tries: tried });
23233
+ if (plan === "skip") return { verdict: "skip", message: "", mounted: false };
23234
+ LF_HEAL_TRIES.set(key, tried + 1);
23235
+ const label = String(f.title || f.id || "");
23236
+ const mount = LF_HEAL_HOOKS.mount;
23237
+ /**
23238
+ * 结论 + 这张壁纸的标题(一句整话,交给词表插值)。
23239
+ * ⚠️ 不能写成 `text + ":" + label`:那会被 i18n 门禁判成"半句话"(模板/拼接),
23240
+ * 而且英文语序里那个全角冒号本来就是错的。
23241
+ */
23242
+ const withLabel = (text) => (label ? weT("{text} · {label}", { text: String(text || ""), label }) : String(text || ""));
23243
+ /** 把本体结论写成人话并试着重挂。 */
23244
+ const finish = async (res) => {
23245
+ const verdict = String((res && res.verdict) || "");
23246
+ if (verdict === "transcoding") {
23247
+ // 带数字的那一句(percent/eta 由宿主的 `transcodePlayableProgress` 给)。
23248
+ lfHealSay(withLabel(dlHealProgressNote(res && res.progress)), true);
23249
+ return { verdict, message: dlHealNote(verdict), mounted: false };
23250
+ }
23251
+ const message = dlHealNote(verdict);
23252
+ if (verdict === "corrupt" || verdict === "variant") {
23253
+ // 等它(单流重下 / 1080p 变体)落地,再重挂播放。
23254
+ const ok = await lfAwaitHealJobP(res.jobId);
23255
+ if (!ok) {
23256
+ const t = weT("重新获取失败(可稍后再点一次这张)");
23257
+ lfHealSay(t, false);
23258
+ return { verdict: "failed", message: t, mounted: false };
23259
+ }
23260
+ const url = res.url || (res.jobId ? "/folia/local-media/" + encodeURIComponent(String(res.jobId)) : "");
23261
+ const done = Boolean(url && mount && mount(url));
23262
+ lfHealSay(withLabel(message), true);
23263
+ return { verdict, message: (res && res.mode === "fps") ? weT("已切换到 30fps 副本(原画 60fps 超出本机解码能力,分辨率不变)") : message, mounted: done };
23264
+ }
23265
+ if (verdict === "transcoded") {
23266
+ // 降帧档与缩分辨率档的文案不同(用户要能看懂"为什么降")。
23267
+ const msg = (res && res.mode === "fps")
23268
+ ? weT("已切换到 30fps 副本(原画 60fps 超出本机解码能力,分辨率不变)")
23269
+ : message;
23270
+ const done = Boolean(res.url && mount && mount(res.url));
23271
+ lfHealSay(withLabel(msg), true);
23272
+ return { verdict, message: (res && res.mode === "fps") ? weT("已切换到 30fps 副本(原画 60fps 超出本机解码能力,分辨率不变)") : message, mounted: done };
23273
+ }
23274
+ lfHealSay(withLabel(message), false);
23275
+ return { verdict: verdict || "error", message, mounted: false };
23276
+ };
23277
+ try {
23278
+ let res = await apiPostJson("/local-heal", {
23279
+ id: String(f.id || ""),
23280
+ localUrl: String(f.url || ""),
23281
+ originUrl: String(f.originUrl || ""),
23282
+ sha256: String(f.sha256 || ""),
23283
+ variants: Array.isArray(f.variants) ? f.variants : [],
23284
+ base: String(f.base || ""),
23285
+ title: label,
23286
+ playing1080p: f.playing1080p === true,
23287
+ }, { parse: "always" });
23288
+ let doc = (res && res.data) || res || {};
23289
+ let out = await finish(doc);
23290
+ // 转码是几十秒级的:宿主先回 `transcoding`,这里按它给的间隔继续问同一个接口,
23291
+ // 直到出片或超过上限。每次调用都命中宿主那份**在途**任务,不会重复起 ffmpeg。
23292
+ let waited = 0;
23293
+ while (out.verdict === "transcoding" && waited < LF_HEAL_POLL_MAX_MS) {
23294
+ const step = Math.max(500, Number(doc && doc.retryAfterMs) || LF_HEAL_POLL_MS);
23295
+ await new Promise((r) => { const t = setTimeout(r, step); try { if (t && t.unref) t.unref(); } catch { /* ignore */ } });
23296
+ waited += step;
23297
+ res = await apiPostJson("/local-heal", {
23298
+ id: String(f.id || ""), localUrl: String(f.url || ""), sha256: String(f.sha256 || ""),
23299
+ variants: Array.isArray(f.variants) ? f.variants : [], base: String(f.base || ""),
23300
+ title: label, playing1080p: f.playing1080p === true,
23301
+ }, { parse: "always" });
23302
+ doc = (res && res.data) || res || {};
23303
+ out = await finish(doc);
23304
+ }
23305
+ if (out.verdict === "transcoding") {
23306
+ const t = weT("转码超时(可稍后再点一次这张,宿主会接着上次的进度)");
23307
+ lfHealSay(t, false);
23308
+ return { verdict: "timeout", message: t, mounted: false };
23309
+ }
23310
+ return out;
23311
+ } catch (err) {
23312
+ // 老宿主没有这条路由 / 网络问题:只说一句,播放器照旧留着那句原始错误。
23313
+ return { verdict: "error", message: String((err && err.message) || err || ""), mounted: false };
23314
+ }
23315
+ }
23316
+
22950
23317
  /**
22951
23318
  * React:订阅下载队列(三个页签共用)。
22952
23319
  * 挂载先拉一次;有未结束 job 才每 1.5s 拉;**卸载即清定时器**(切页签不泄漏)。
@@ -31042,6 +31409,14 @@ window.__ModuleLoader__.load({
31042
31409
  cacheBusy: "",
31043
31410
  cacheNote: "",
31044
31411
  cacheError: "",
31412
+ // 「本地媒体自检」(4.23.15,transient):`GET /folia/local-check` 的账本
31413
+ // (损坏 / 已清理 / 待重下 / 最近发现清单)、全量校验的在途标记、一次校验的结果一句话。
31414
+ // 与 cacheUsage 同款:不落盘 —— 它是"这台机器此刻的体检读数",重启后重测即可。
31415
+ mediaHealth: null,
31416
+ mediaVerifyBusy: "",
31417
+ mediaVerifyNote: "",
31418
+ // 本地优先/自愈的一句提示(信息类;失败类走 videoError 的红色行)。
31419
+ mediaNote: "",
31045
31420
  // WE 官方资源路径编辑器(transient):开态 + 草稿路径 + 上次错误。
31046
31421
  // 生效状态(目录/可用性)由 inventory 携带(host 是唯一真相)。
31047
31422
  editingWeAssetsDir: false,
@@ -32310,6 +32685,54 @@ window.__ModuleLoader__.load({
32310
32685
  clearCacheTargets(["skins"]);
32311
32686
  }
32312
32687
 
32688
+ /* ── 本地媒体自检(4.23.15)─────────────────────────────────────────────────
32689
+ *
32690
+ * 面板只做两件事:**把账本画出来**、**把"校验并修复"发过去**。判据与动作全在宿主
32691
+ * (`lib/media-selfheal.js`):客户端既没有磁盘也没有站点清单,任何"自己判一下"的写法
32692
+ * 都会变成第二份会漂的实现。
32693
+ */
32694
+ const MEDIA_HEALTH_URL = "/folia/local-check";
32695
+ const MEDIA_VERIFY_URL = "/folia/local-verify";
32696
+
32697
+ /** 拉一次体检账本(只读:宿主不建目录、不改盘、不触发校验)。 */
32698
+ async function loadMediaHealth() {
32699
+ try {
32700
+ const res = await apiJson(MEDIA_HEALTH_URL);
32701
+ const doc = (res && res.data) || res || null;
32702
+ const health = doc && doc.health ? doc.health : null;
32703
+ if (health) setTransient("mediaHealth", health);
32704
+ } catch { /* 老宿主没有这条路由:面板就显示"未校验",不报错 */ }
32705
+ }
32706
+
32707
+ /**
32708
+ * 「校验并修复本地媒体」= 第 2 步的**全量版**(同一条判据、同一段代码路径)。
32709
+ * 完成后刷新账本与清单:坏文件已被删掉并排回下载队列 ⇒ 卡片上的「已缓存」角标会跟着变。
32710
+ */
32711
+ async function verifyLocalMedia() {
32712
+ if (selection.mediaVerifyBusy) return;
32713
+ setTransient("mediaVerifyBusy", "verify");
32714
+ setTransient("mediaVerifyNote", "");
32715
+ emit();
32716
+ try {
32717
+ const res = await apiPostJson(MEDIA_VERIFY_URL, {}, { parse: "always" });
32718
+ const d = (res && res.data) || {};
32719
+ const checked = Number(d.checked) || 0;
32720
+ const damaged = Number(d.damaged) || 0;
32721
+ if (d && d.health) setTransient("mediaHealth", d.health);
32722
+ setTransient("mediaVerifyNote", damaged
32723
+ ? weT("已校验 {n} 个文件:发现 {bad} 个损坏,已清理并排回下载队列", { n: checked, bad: damaged })
32724
+ : weT("已校验 {n} 个文件:没有发现损坏", { n: checked }));
32725
+ // 坏文件被删 ⇒ inventory 的 localReady/local 会变,清单必须重拉(同一份结论处处一致)。
32726
+ if (damaged) { try { await loadInventory(); } catch { /* 清单刷新失败不影响"已清理"这个事实 */ } }
32727
+ } catch (err) {
32728
+ setTransient("mediaVerifyNote", weT("校验失败:{error}", {
32729
+ error: String((err && err.message) || err || ""),
32730
+ }));
32731
+ }
32732
+ setTransient("mediaVerifyBusy", "");
32733
+ emit();
32734
+ }
32735
+
32313
32736
  const WE_ASSETS_DIR_URL = "/folia/we-assets-dir";
32314
32737
 
32315
32738
  // Set / clear the WE official-assets directory (host-persisted). Scene live
@@ -32596,6 +33019,197 @@ window.__ModuleLoader__.load({
32596
33019
  setTransient("videoError", reason);
32597
33020
  emit();
32598
33021
  }
33022
+ /* ── 播放失败自愈(4.23.15)────────────────────────────────────────────────────
33023
+ *
33024
+ * 用户实测(另一台机器):「视频解码失败(文件可能已损坏)」/「浏览器无法解码这段视频」,
33025
+ * 而面板同时说"缓存命中 4/5"。播放路径直接读本地文件、**没有任何自检** —— 4.23.6 之前
33026
+ * ranged 静默损坏遗留的坏成品会永久留在 library 里,每次点都是同一句错误。
33027
+ *
33028
+ * 这一层的职责只有三件(判据与动作都在宿主与 local-first.js,这里只接线):
33029
+ * ① 认出"**在屏那个** <video> 报了**解码/源不支持**错误"(预热元素/探测元素不参与);
33030
+ * ② 把当前壁纸的证据(id / 本地地址 / 站点 sha256 / 变体 / 是否 1080p)交给 `lfHealPlayback`;
33031
+ * ③ 提供 `mount(url)`:把修好的地址重挂到**在屏元素**上(同一张壁纸、同一个元素,
33032
+ * 不重建解码器之外的任何东西 —— 换 src 就是一次新的资源选择)。
33033
+ *
33034
+ * 为什么必须"同一个元素重挂"而不是重新 applySelection:重建层会把整条切换四段式再跑一遍
33035
+ *(淡入淡出、首帧预算、池领养),代价是数秒的黑屏;而此刻用户要的是"这张图赶紧出来"。
33036
+ */
33037
+ /** 同一张壁纸只允许一条自愈在飞(`error` 事件会连发好几颗)。 */
33038
+ let selfHealInflightKey = "";
33039
+
33040
+ /** 当前选择对应的 inventory 条目(站点条目带 sha256 / variants;本机条目没有也能用)。 */
33041
+ function selfHealItemOf(id) {
33042
+ try {
33043
+ const pools = [
33044
+ selection.inventory && selection.inventory.wallpapers,
33045
+ selection.inventory && selection.inventory.items,
33046
+ ];
33047
+ for (const pool of pools) {
33048
+ if (!Array.isArray(pool)) continue;
33049
+ const hit = pool.find((w) => w && w.id === id);
33050
+ if (hit) return hit;
33051
+ }
33052
+ } catch { /* 清单形状意外:当作没有条目(宿主仍能按 job 自己判) */ }
33053
+ return null;
33054
+ }
33055
+
33056
+ /** 在屏的那一个 `<video>`(层内或池的可见元素);都不是就 null。 */
33057
+ function onScreenVideo(node) {
33058
+ const v = node || null;
33059
+ if (!v) return null;
33060
+ try {
33061
+ const layer = document.getElementById(LAYER_ID);
33062
+ if (layer && typeof layer.contains === "function" && layer.contains(v)) return v;
33063
+ } catch { /* ignore */ }
33064
+ try { if (typeof weSwitchVisibleEl !== "undefined" && weSwitchVisibleEl && weSwitchVisibleEl === v) return v; } catch { /* ignore */ }
33065
+ return null;
33066
+ }
33067
+
33068
+ /**
33069
+ * `<video>` 报错 → 要不要自愈(并把证据交给 `lfHealPlayback`)。
33070
+ * 幂等:同一 (id, 地址) 同时只有一条在飞;连续 error 不会连开多条重下。
33071
+ */
33072
+ function maybeSelfHealVideo(video) {
33073
+ const el = onScreenVideo(video);
33074
+ if (!el) return;
33075
+ const code = Number((el.error && el.error.code) || 0);
33076
+ const srcUrl = String(el.currentSrc || el.src || selection.url || "");
33077
+ const selUrl = String(selection.url || "");
33078
+ // 只认**当前这张**的地址:池里可能留着上一张的 src(预热对手),那不是本次的故障。
33079
+ const url = srcUrl || selUrl;
33080
+ if (!url) return;
33081
+ if (selUrl && srcUrl && srcUrl.indexOf(selUrl.split("?")[0]) < 0 && srcUrl.indexOf("/local-media/") < 0) return;
33082
+ const id = String(selection.id || "");
33083
+ const key = id + "|" + url;
33084
+ if (selfHealInflightKey === key) return;
33085
+ if (dlHealPlan({ isVideo: selection.type === "video", url, code, tries: 0 }) !== "heal") return;
33086
+ const item = selfHealItemOf(id);
33087
+ const variants = item && Array.isArray(item.variants) ? item.variants : [];
33088
+ const sha256 = String((item && item.sha256) || "");
33089
+ const playing1080p = Boolean(item && item.chosenVariant === "1080p");
33090
+ selfHealInflightKey = key;
33091
+ liveLog("media-selfheal", "code=" + code + " url=" + url + " ⇒ 交给宿主取证");
33092
+ Promise.resolve()
33093
+ .then(() => lfHealPlayback({
33094
+ id, url, code, isVideo: selection.type === "video",
33095
+ originUrl: String((item && item.media) || selection.originUrl || ""),
33096
+ sha256, variants, title: String(selection.title || id),
33097
+ playing1080p,
33098
+ }))
33099
+ .then((res) => {
33100
+ if (res && res.mounted) { liveLog("media-selfheal", "已重挂播放:" + res.message); return; }
33101
+ // 没挂上 ⇒ 走**最后一级**:静态帧兜底。需求原文是"只要站点上有可用文件,最终都必须能上屏",
33102
+ // 所以只有连一张静态图都没有时,才允许说"无法显示"。
33103
+ const still = staticFallbackUrlOf();
33104
+ const plan = dlHealFallbackPlan({ verdict: res && res.verdict, hasPreview: Boolean(still) });
33105
+ if (plan === "static-frame" && mountStaticFrameFallback(still)) {
33106
+ liveLog("media-selfheal", "静态帧兜底:" + still);
33107
+ try {
33108
+ setTransient("videoError", "");
33109
+ setTransient("mediaNote", weT("已降级为静态壁纸(本机无法解码该视频)"));
33110
+ emit();
33111
+ } catch { /* ignore */ }
33112
+ return;
33113
+ }
33114
+ if (plan === "cannot-display" || (plan === "static-frame" && !still)) {
33115
+ try {
33116
+ setTransient("videoError", weT("无法显示这张壁纸(本机无法解码该视频,且没有可用的静态帧)"));
33117
+ emit();
33118
+ } catch { /* ignore */ }
33119
+ return;
33120
+ }
33121
+ if (res && res.message) { try { setTransient("videoError", res.message); emit(); } catch { /* ignore */ } }
33122
+ })
33123
+ .catch(() => { /* 自愈失败不改写原始错误 */ })
33124
+ .then(() => { if (selfHealInflightKey === key) selfHealInflightKey = ""; });
33125
+ }
33126
+
33127
+ /**
33128
+ * **静态帧兜底**(4.23.15 的最后一级):视频解不了时,把这张壁纸的缩略图/首帧当静态壁纸铺上去。
33129
+ *
33130
+ * 为什么必须有这一级(用户的最终目标:"任何一张壁纸,只要站点上有可用文件,最终都必须能上屏"):
33131
+ * 站点的视频条目几乎都带 `thumbUrl` / 宿主抽的首帧(`/video-preview/…`)。一张能看的静态图
33132
+ * 远好过一句"无法显示" —— 用户要的是**有壁纸**,不是"播放器没报错"。
33133
+ *
33134
+ * 实现:**不拆 `<video>`、不重建层**,只在同一层里追加一个 `.we-media` 的 `<img>`
33135
+ *(绝对定位、与视频同一套 fit 规则,后插入的兄弟节点画在上面)。坏掉的视频元素本来就不出像素,
33136
+ * 留着不碍事;拆它反而会把池的"谁在屏上"弄乱(那是 4.23.8 的账)。
33137
+ *
33138
+ * @param {string} url 静态帧地址(缩略图 / 首帧)
33139
+ * @returns {boolean} true = 已经铺上去
33140
+ */
33141
+ function mountStaticFrameFallback(url) {
33142
+ const u = String(url || "");
33143
+ if (!u) return false;
33144
+ let layer;
33145
+ try { layer = document.getElementById(LAYER_ID); } catch { layer = null; }
33146
+ if (!layer) return false;
33147
+ try {
33148
+ const found = (typeof layer.querySelector === "function") ? layer.querySelector("img.we-media--static") : null;
33149
+ let img = found;
33150
+ if (!img) {
33151
+ img = document.createElement("img");
33152
+ img.className = "we-media we-media--static";
33153
+ img.setAttribute("alt", "");
33154
+ img.setAttribute("aria-hidden", "true");
33155
+ layer.appendChild(img);
33156
+ }
33157
+ img.src = u;
33158
+ img.dataset.weStatic = "1";
33159
+ return true;
33160
+ } catch { return false; }
33161
+ }
33162
+
33163
+ /** 这张壁纸能用来兜底的静态图(首帧优先,其次站点缩略图)。取不到 ⇒ ""。 */
33164
+ function staticFallbackUrlOf() {
33165
+ const item = selfHealItemOf(String(selection.id || ""));
33166
+ const cands = [
33167
+ selection.previewUrl,
33168
+ item && item.preview,
33169
+ item && item.thumbUrl,
33170
+ selection.frameUrl,
33171
+ ];
33172
+ for (const c of cands) {
33173
+ const s = String(c || "");
33174
+ if (s) return s;
33175
+ }
33176
+ return "";
33177
+ }
33178
+
33179
+ /**
33180
+ * 把某个地址**重挂到在屏元素**上(自愈成功后调用)。返回 true = 已开始加载。
33181
+ *
33182
+ * 不变量:
33183
+ * · 只用**已确认可播**的地址(宿主回的 `?playable=1` 或新 job 的 `/local-media/<id>`);
33184
+ * · 清掉上一轮的 `weTranscoded` 标记 —— 否则 `maybeUpgradeToTranscoded` 会以为"已经在抽帧版上";
33185
+ * · 重挂前把面板那句错误清掉:新一轮要么成功(syncVideoState 自己会清),要么再报一次。
33186
+ */
33187
+ function remountLayerVideo(url) {
33188
+ const u = String(url || "");
33189
+ if (!u) return false;
33190
+ let el;
33191
+ try { el = onScreenVideo(null) || (typeof weSwitchVisibleEl !== "undefined" ? weSwitchVisibleEl : null); } catch { el = null; }
33192
+ if (!el) {
33193
+ try {
33194
+ const layer = document.getElementById(LAYER_ID);
33195
+ el = layer && typeof layer.querySelector === "function" ? layer.querySelector("video") : null;
33196
+ } catch { el = null; }
33197
+ }
33198
+ if (!el) return false;
33199
+ try {
33200
+ delete el.dataset.weTranscoded;
33201
+ el.src = u;
33202
+ if (typeof el.load === "function") el.load();
33203
+ const p = el.play();
33204
+ if (p && typeof p.catch === "function") p.catch(() => { /* 静音自动播放被拒:loadeddata 会再试 */ });
33205
+ } catch { return false; }
33206
+ try { el.__weUrl = u; } catch { /* ignore */ }
33207
+ try { setTransient("videoError", ""); emit(); } catch { /* ignore */ }
33208
+ // 新一轮允许再自愈一次(坏文件被换掉之后再失败,是"另一个问题")。
33209
+ selfHealInflightKey = "";
33210
+ return true;
33211
+ }
33212
+
32599
33213
  // 每个元素只挂一次状态监听(切壁纸会新建 <video>,故标记挂在元素上)。
32600
33214
  function watchVideoState(video) {
32601
33215
  if (!video || !video.dataset || video.dataset.weStateWatched === "1") return;
@@ -32603,6 +33217,9 @@ window.__ModuleLoader__.load({
32603
33217
  for (const t of ["play", "playing", "pause", "ended", "error", "emptied"]) {
32604
33218
  try { video.addEventListener(t, () => syncVideoState(video)); } catch { /* ignore */ }
32605
33219
  }
33220
+ // 4.23.15:**播放失败自愈**(本地副本坏了 / 原画超出本机解码上限)。
33221
+ // 与 syncVideoState 并行挂:那一颗负责"把错误显示出来",这一颗负责"把它修好"。
33222
+ try { video.addEventListener("error", () => { maybeSelfHealVideo(video); }); } catch { /* ignore */ }
32606
33223
  // 「当前视频播完就换下一张」(issue #230 后续诉求):轮播组选了 `trigger: 'videoEnd'`
32607
33224
  // 时,壁纸视频的 ended 就是轮换信号 —— 与计时器二选一(syncRotationTimer 在该档不计时)。
32608
33225
  // 只认**当前层**那个 <video>:预热 / 探测元素也走 watchVideoState,它们播完不代表壁纸播完。
@@ -35110,7 +35727,12 @@ window.__ModuleLoader__.load({
35110
35727
  // 4.23.7「缓存管理」:进「系统」页签时拉一次用量(宿主那条路由**只读**,不建目录不改盘)。
35111
35728
  // 只在切到这个页签时拉 —— 不跟着轮询走,免得为一份"几分钟都不变"的读数每分钟多发请求;
35112
35729
  // 用户在面板里按「刷新」或清完一轮时会各自再拉一次(`loadCacheUsage` / `clearCacheTargets`)。
35113
- React.useEffect(() => { if (activeTab === "system") loadCacheUsage(); }, [activeTab]);
35730
+ // 4.23.15:同一次进页签也拉一次**本地媒体体检账本**(`/folia/local-check`,同样只读)。
35731
+ React.useEffect(() => {
35732
+ if (activeTab !== "system") return;
35733
+ loadCacheUsage();
35734
+ loadMediaHealth();
35735
+ }, [activeTab]);
35114
35736
 
35115
35737
  // 页签安全(ADR-0013 D3①):可见页签表变了(组件行状态随 inventory 轮询回到本地)而当前
35116
35738
  // 页签不在表里 ⇒ 回落到第一个可见页签,自愈、不用用户自己点走。表为空(今天不可能,空表
@@ -35169,6 +35791,21 @@ window.__ModuleLoader__.load({
35169
35791
  if (activeTab === "appearance" && pickerFontOpen && sel.fontCustom) ensureSystemFonts(false);
35170
35792
  }, [activeTab, pickerFontOpen, sel.fontCustom]);
35171
35793
 
35794
+ // 4.23.15:**播放失败自愈**的两处接线(`src/local-first.js` 的两个注入位)。
35795
+ //
35796
+ // 为什么必须有这一个 effect(而不是让 local-first 直接调):那个文件是内联片段,
35797
+ // 它不知道"往哪写提示、哪个 <video> 在屏上"。在此之前 `setLocalFirstNote` **从来没有
35798
+ // 被调用过** —— 于是 `lfSay()` 全部静默("正在下载到本地 45%"这类话一句都没显示过)。
35799
+ // 顺手把它接上:信息类进 `mediaNote`(面板提示行),失败类进 `videoError`(红色错误行)。
35800
+ React.useEffect(() => {
35801
+ const say = (text, ok) => {
35802
+ const t = String(text || "");
35803
+ try { setTransient(ok === false ? "videoError" : "mediaNote", t); emit(); } catch { /* ignore */ }
35804
+ };
35805
+ try { if (typeof setLocalFirstNote === "function") setLocalFirstNote(say); } catch { /* ignore */ }
35806
+ try { if (typeof setSelfHealHooks === "function") setSelfHealHooks(say, remountLayerVideo); } catch { /* ignore */ }
35807
+ }, []);
35808
+
35172
35809
  // 侧栏深链(快捷播放面板底栏的「更多外观设置 ›」/「更多播放设置 ›」):请求"打开
35173
35810
  // 设置页后停在哪一页"。打开对话框由 src/sidebar-right.js 的 DOM 路径负责,这里只管
35174
35811
  // 落地 —— 走**同一个 switchTab**(清待确认 / 退出下钻 / 写 localStorage 这些副作用
@@ -35374,6 +36011,8 @@ window.__ModuleLoader__.load({
35374
36011
  // 4.23.7「缓存管理」:用量 / 刷新 / 五目标清理(`skins` 走两段式确认,令牌 "cache:skins")。
35375
36012
  onClearCache: clearCacheTargets, onClearCacheSkins: onCacheClearSkins,
35376
36013
  onRefreshCacheUsage: loadCacheUsage, armedConfirm: sel.armedConfirm, onDisarmConfirm: disarmConfirm,
36014
+ // 4.23.15「本地媒体自检」:账本刷新 / 全量校验并修复(= 启动采样那套判据的全量版)。
36015
+ onVerifyMedia: verifyLocalMedia, onRefreshMediaHealth: loadMediaHealth,
35377
36016
  }),
35378
36017
  );
35379
36018
  return renderWallpaperTab({