dsh-folia 4.19.0 → 4.19.1
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 +46 -0
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -19409,6 +19409,49 @@ window.__ModuleLoader__.load({
|
|
|
19409
19409
|
}
|
|
19410
19410
|
}
|
|
19411
19411
|
|
|
19412
|
+
/**
|
|
19413
|
+
* 缓存与速度自述(④)。
|
|
19414
|
+
*
|
|
19415
|
+
* 目的:用户问"为什么慢"时,答案应该在界面上,而不是让他开 F12 或来问作者。
|
|
19416
|
+
* 读宿主 `/folia/site-media-stats`(4.15.3 起存在):命中/未命中/平均吞吐/缓存是否可写。
|
|
19417
|
+
* 三条纪律:拿不到就**什么都不显示**;每 15 秒最多取一次;任何异常都吞掉(不许影响面板)。
|
|
19418
|
+
*/
|
|
19419
|
+
function QpCacheHint() {
|
|
19420
|
+
const [info, setInfo] = React.useState(null);
|
|
19421
|
+
React.useEffect(() => {
|
|
19422
|
+
let alive = true;
|
|
19423
|
+
let timer = null;
|
|
19424
|
+
const pull = () => {
|
|
19425
|
+
(async () => {
|
|
19426
|
+
try {
|
|
19427
|
+
const r = typeof apiJson === "function" ? await apiJson("/site-media-stats") : null;
|
|
19428
|
+
const d = (r && r.data) || r || null;
|
|
19429
|
+
if (alive && d && typeof d === "object") setInfo(d);
|
|
19430
|
+
} catch { /* 端点不存在(老宿主)⇒ 保持不显示 */ }
|
|
19431
|
+
})();
|
|
19432
|
+
};
|
|
19433
|
+
pull();
|
|
19434
|
+
try { timer = window.setInterval(pull, 15000); } catch { timer = null; }
|
|
19435
|
+
return () => {
|
|
19436
|
+
alive = false;
|
|
19437
|
+
if (timer !== null) { try { window.clearInterval(timer); } catch { /* ignore */ } }
|
|
19438
|
+
};
|
|
19439
|
+
}, []);
|
|
19440
|
+
if (!info) return null;
|
|
19441
|
+
const hits = Number(info.hits) || 0;
|
|
19442
|
+
const misses = Number(info.misses) || 0;
|
|
19443
|
+
const mbps = Number(info.avgMBps) || 0;
|
|
19444
|
+
const writable = info.writable !== false;
|
|
19445
|
+
const parts = [
|
|
19446
|
+
weT("缓存命中 {h} · 首次下载 {m}", { h: hits, m: misses }),
|
|
19447
|
+
mbps > 0 ? weT("平均 {v} MB/s", { v: mbps.toFixed(1) }) : "",
|
|
19448
|
+
writable ? "" : weT("⚠ 缓存目录不可写(每次都会重下)"),
|
|
19449
|
+
].filter(Boolean);
|
|
19450
|
+
return React.createElement("div", {
|
|
19451
|
+
className: "we-picker__hint",
|
|
19452
|
+
style: { marginTop: "2px", opacity: 0.75, fontSize: "11px" },
|
|
19453
|
+
}, parts.join(" · "));
|
|
19454
|
+
}
|
|
19412
19455
|
function qpRenderCard(w, sel) {
|
|
19413
19456
|
// ── 卡:缩略图网格形态(视图切换的「卡片」档;点击语义与列表行一致)──
|
|
19414
19457
|
return React.createElement("div", {
|
|
@@ -19479,6 +19522,9 @@ window.__ModuleLoader__.load({
|
|
|
19479
19522
|
? qpTypeLabel(current, sel) + weT(playbackLive ? " · 播放中" : " · 已暂停")
|
|
19480
19523
|
: weT("从下面列表挑一张")),
|
|
19481
19524
|
sel.videoError && React.createElement("div", { className: "we-picker__current-error" }, sel.videoError),
|
|
19525
|
+
// 缓存与速度的**自述**(④):用户不用开 F12 也能知道"这次是首次下载还是命中缓存"。
|
|
19526
|
+
// 数据来自宿主 `/folia/site-media-stats`;拿不到就**什么都不显示**(绝不因此报错)。
|
|
19527
|
+
React.createElement(QpCacheHint, null),
|
|
19482
19528
|
),
|
|
19483
19529
|
React.createElement("div", { className: "we-qp__current-actions" },
|
|
19484
19530
|
// ⚠️ **不变量:这一行只放日常操作**(暂停 / 播放 · 刷新 · 清除;场景与网页壁纸再加
|