dsh-folia 3.6.0 → 3.8.0
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 +57 -43
- package/lib/routes/skins.js +1074 -1032
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -16274,35 +16274,61 @@ window.__ModuleLoader__.load({
|
|
|
16274
16274
|
|
|
16275
16275
|
React.useEffect(() => { load(false); }, [load]);
|
|
16276
16276
|
|
|
16277
|
-
//
|
|
16278
|
-
|
|
16279
|
-
|
|
16280
|
-
|
|
16281
|
-
|
|
16282
|
-
|
|
16283
|
-
|
|
16284
|
-
|
|
16285
|
-
|
|
16286
|
-
|
|
16287
|
-
|
|
16288
|
-
|
|
16289
|
-
|
|
16290
|
-
|
|
16291
|
-
|
|
16277
|
+
// 轮询验证的清理(组件卸载/重新选中时别留下定时器)。
|
|
16278
|
+
const pollRef = React.useRef(null);
|
|
16279
|
+
React.useEffect(() => () => {
|
|
16280
|
+
if (pollRef.current !== null) { clearInterval(pollRef.current); pollRef.current = null; }
|
|
16281
|
+
}, []);
|
|
16282
|
+
|
|
16283
|
+
/**
|
|
16284
|
+
* 写 active 之后**验证皮肤中心有没有真的应用**。
|
|
16285
|
+
*
|
|
16286
|
+
* 为什么不需要刷新页面:皮肤中心的客户端运行时自带轮询 ——
|
|
16287
|
+
*
|
|
16288
|
+
* const SELECTION_POLL_MS = 2e3;
|
|
16289
|
+
* function watchPersistedSelection(store, intervalMs = SELECTION_POLL_MS) {
|
|
16290
|
+
* const tick = async () => {
|
|
16291
|
+
* const next = await readPersistedSelection(store); // GET /api/skin-center/v2/active
|
|
16292
|
+
* if (next === undefined || next === applied) return;
|
|
16293
|
+
* applied = next;
|
|
16294
|
+
* await convergeOnSelection(store, next); // ← 自动应用
|
|
16295
|
+
* };
|
|
16296
|
+
* store.window.setInterval(tick, intervalMs); // 注意是 store.window.setInterval
|
|
16297
|
+
* }
|
|
16298
|
+
*
|
|
16299
|
+
* 那个 `/active` 读的就是我们刚写的 `skin-center-active.json`。所以写完之后它会在
|
|
16300
|
+
* 2 秒内自己收敛过去 —— 之前"必须刷新"的假象,是我们自己的热注入在覆盖它的结果。
|
|
16301
|
+
*
|
|
16302
|
+
* 它的收敛成功标志很明确:`<html data-dsh-skin="<id>">`。我们就盯这个属性:
|
|
16303
|
+
* 出现了 = 真的应用了;5 次(约 6 秒)还没出现 = 没应用,如实说。
|
|
16304
|
+
*/
|
|
16305
|
+
function verifyApplied(id, label) {
|
|
16306
|
+
if (pollRef.current !== null) { clearInterval(pollRef.current); pollRef.current = null; }
|
|
16307
|
+
let tries = 0;
|
|
16308
|
+
pollRef.current = setInterval(() => {
|
|
16309
|
+
tries += 1;
|
|
16310
|
+
let stamped = null;
|
|
16311
|
+
try { stamped = document.documentElement.getAttribute("data-dsh-skin"); } catch { stamped = null; }
|
|
16312
|
+
if (stamped === id) {
|
|
16313
|
+
clearInterval(pollRef.current); pollRef.current = null;
|
|
16314
|
+
setNote({ kind: "ok", text: weT("已应用:「") + label + weT("」—— 皮肤中心已收敛(无需刷新)") });
|
|
16315
|
+
return;
|
|
16316
|
+
}
|
|
16317
|
+
if (tries >= 9) { // 约 11 秒:host 会先写 null 再写目标 id(900ms),引擎每 2s 轮询一次
|
|
16318
|
+
clearInterval(pollRef.current); pollRef.current = null;
|
|
16292
16319
|
setNote({
|
|
16293
|
-
kind: "
|
|
16294
|
-
text: weT("
|
|
16295
|
-
+ weT("」应由皮肤中心应用。若仍无变化,请到「设置 → 皮肤」点「应用」。"),
|
|
16320
|
+
kind: "err",
|
|
16321
|
+
text: weT("已写入「") + label + weT("」,但皮肤中心没有应用。可能原因:壁纸仍在台(皮肤会被抑制)或这套皮肤校验未通过。可到「设置 → 皮肤」点「应用」确认。"),
|
|
16296
16322
|
});
|
|
16297
16323
|
}
|
|
16298
|
-
}
|
|
16299
|
-
}
|
|
16324
|
+
}, 1200);
|
|
16325
|
+
}
|
|
16300
16326
|
|
|
16301
16327
|
/**
|
|
16302
16328
|
* 执行一个动作。
|
|
16303
16329
|
* · install / remove:宿主真正干活(下载解压 / 删目录)。
|
|
16304
|
-
* · activate:**只写 active**(`skin-center-active.json
|
|
16305
|
-
*
|
|
16330
|
+
* · activate:**只写 active**(`skin-center-active.json`)—— 不注入任何样式,
|
|
16331
|
+
* 应用由皮肤中心自己轮询完成,我们只负责验证结果。
|
|
16306
16332
|
*/
|
|
16307
16333
|
async function act(kind, id, label) {
|
|
16308
16334
|
if (busy) return;
|
|
@@ -16318,31 +16344,19 @@ window.__ModuleLoader__.load({
|
|
|
16318
16344
|
} else if (kind === "activate") {
|
|
16319
16345
|
setActive(id);
|
|
16320
16346
|
setList((prev) => prev.map((x) => ({ ...x, active: x.id === id })));
|
|
16321
|
-
//
|
|
16347
|
+
// 皮肤与壁纸都在铺背景,必须互斥:皮肤中心在壁纸在台时会**主动抑制皮肤**,
|
|
16348
|
+
// 所以这一步不是"顺手",而是"应用能否成功"的前提。
|
|
16322
16349
|
try {
|
|
16323
16350
|
if (typeof onClearWallpaper === "function") await Promise.resolve(onClearWallpaper());
|
|
16324
16351
|
} catch { /* 清壁纸失败不影响选中本身 */ }
|
|
16325
|
-
setNote({
|
|
16326
|
-
kind: "ok",
|
|
16327
|
-
text: skinCenter
|
|
16328
|
-
? weT("已选中「") + label + weT("」,正在重新加载页面让皮肤生效…")
|
|
16329
|
-
: weT("已选中「") + label + weT("」—— 未检测到皮肤中心,无法渲染;请安装 @linxin666/dsh-client-ui-skin-center 后重启"),
|
|
16330
|
-
});
|
|
16331
|
-
// 只有皮肤中心在台时,刷新才有意义(boot 时它会应用 active)。
|
|
16332
16352
|
if (skinCenter) {
|
|
16333
|
-
|
|
16334
|
-
|
|
16335
|
-
|
|
16336
|
-
|
|
16337
|
-
|
|
16338
|
-
|
|
16339
|
-
|
|
16340
|
-
setTimeout(() => {
|
|
16341
|
-
setNote({
|
|
16342
|
-
kind: "err",
|
|
16343
|
-
text: weT("页面没有自动刷新 —— 桌面壳可能拦了刷新。请手动重启 DSH 让「") + label + weT("」生效。"),
|
|
16344
|
-
});
|
|
16345
|
-
}, 4000);
|
|
16353
|
+
setNote({ kind: "ok", text: weT("已选中「") + label + weT("」,等待皮肤中心应用(约 2 秒)…") });
|
|
16354
|
+
verifyApplied(id, label);
|
|
16355
|
+
} else {
|
|
16356
|
+
setNote({
|
|
16357
|
+
kind: "err",
|
|
16358
|
+
text: weT("已写入「") + label + weT("」,但本机没有皮肤中心,无法渲染。请安装 @linxin666/dsh-client-ui-skin-center 后重启。"),
|
|
16359
|
+
});
|
|
16346
16360
|
}
|
|
16347
16361
|
} else if (kind === "remove") {
|
|
16348
16362
|
setNote({ kind: "ok", text: weT("已删除:") + label });
|