dsh-folia 2.4.1 → 2.4.3
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 +74 -13
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -16244,10 +16244,15 @@ window.__ModuleLoader__.load({
|
|
|
16244
16244
|
setLoading(true);
|
|
16245
16245
|
setError(null);
|
|
16246
16246
|
try {
|
|
16247
|
-
|
|
16247
|
+
// ⚠️ `apiJson` 返回的是 **`{ ok, status, data, error }` 包装对象**,不是响应体本身
|
|
16248
|
+
//(见 src/api-client.js 的 apiFetch)。最初按裸体取值 ⇒ `list=[] 且 error=null`,
|
|
16249
|
+
// 界面显示"没有匹配的皮肤包"却没有任何错误提示 —— 静默空列表比报错难查得多。
|
|
16250
|
+
// `parse: "always"` 让非 2xx 的 `{error}` 也能被读到。
|
|
16251
|
+
const resp = await apiJson("/skins" + (force ? "?refresh=1" : ""), { parse: "always" });
|
|
16252
|
+
const r = (resp && resp.data) || null;
|
|
16248
16253
|
setList((r && r.skins) || []);
|
|
16249
16254
|
setActive((r && r.active) || null);
|
|
16250
|
-
setError((r && r.error) || null);
|
|
16255
|
+
setError((r && r.error) || (resp && resp.error) || null);
|
|
16251
16256
|
setHarnessFound(!r || r.harnessFound !== false);
|
|
16252
16257
|
} catch (e) {
|
|
16253
16258
|
setError("network");
|
|
@@ -16259,20 +16264,39 @@ window.__ModuleLoader__.load({
|
|
|
16259
16264
|
|
|
16260
16265
|
React.useEffect(() => { load(false); }, [load]);
|
|
16261
16266
|
|
|
16267
|
+
/**
|
|
16268
|
+
* 执行一个动作(install / activate / remove)。
|
|
16269
|
+
*
|
|
16270
|
+
* ⚠️ **「使用」必须立刻有反馈**:切换皮肤只写 `skin-center-active.json`,host 端 6 ms 就应,
|
|
16271
|
+
* 而皮肤要重启才生效 —— 如果等一次 `?refresh=1`(约 600 ms)再改标记,用户看到的就是
|
|
16272
|
+
* "点了一下,半天没反应"。所以「使用」走**乐观更新**:先本地翻转 active 并把提示打出来,
|
|
16273
|
+
* 请求失败再回滚重拉。装 / 删仍然要重拉(已装标记与体积都变了)。
|
|
16274
|
+
*/
|
|
16262
16275
|
async function act(kind, id, label) {
|
|
16263
16276
|
if (busy) return;
|
|
16264
16277
|
setBusy(id);
|
|
16265
16278
|
setNote(null);
|
|
16279
|
+
const prevActive = active;
|
|
16280
|
+
if (kind === "activate") {
|
|
16281
|
+
// 乐观:先给反馈,再等网络
|
|
16282
|
+
setActive(id);
|
|
16283
|
+
setList((prev) => prev.map((x) => ({ ...x, active: x.id === id })));
|
|
16284
|
+
setNote({ kind: "ok", text: weT("正在切换到「") + label + weT("」…") });
|
|
16285
|
+
}
|
|
16266
16286
|
try {
|
|
16267
|
-
|
|
16268
|
-
|
|
16287
|
+
// 同样是包装对象:`ok` 是 HTTP 2xx,业务结论在 `data.ok`(宿主回 `{ok:false,error}`)。
|
|
16288
|
+
const resp = await apiPostJson("/skins/" + kind, { id }, { parse: "always" });
|
|
16289
|
+
const r = (resp && resp.data) || null;
|
|
16290
|
+
if (resp && resp.ok && r && r.ok) {
|
|
16269
16291
|
if (kind === "install") {
|
|
16270
16292
|
setNote({ kind: "ok", text: weT("已安装:") + label });
|
|
16271
16293
|
await load(true);
|
|
16272
16294
|
} else if (kind === "activate") {
|
|
16273
|
-
|
|
16274
|
-
|
|
16275
|
-
|
|
16295
|
+
setNote({
|
|
16296
|
+
kind: "ok",
|
|
16297
|
+
text: weT("已切换到「") + label + weT("」 —— 重启 DSH 后生效"),
|
|
16298
|
+
});
|
|
16299
|
+
// 不再整表重拉:本地标记已经对了,省掉那 600 ms 的"没反应"窗口。
|
|
16276
16300
|
} else if (kind === "remove") {
|
|
16277
16301
|
setNote({ kind: "ok", text: weT("已删除:") + label });
|
|
16278
16302
|
await load(true);
|
|
@@ -16281,9 +16305,18 @@ window.__ModuleLoader__.load({
|
|
|
16281
16305
|
const code = (r && r.error) || "failed";
|
|
16282
16306
|
const detail = (r && r.detail) ? "(" + r.detail + ")" : "";
|
|
16283
16307
|
setNote({ kind: "err", text: weT("操作失败:") + code + detail });
|
|
16308
|
+
if (kind === "activate") {
|
|
16309
|
+
// 回滚乐观更新
|
|
16310
|
+
setActive(prevActive);
|
|
16311
|
+
setList((prev) => prev.map((x) => ({ ...x, active: x.id === prevActive })));
|
|
16312
|
+
}
|
|
16284
16313
|
}
|
|
16285
16314
|
} catch (e) {
|
|
16286
16315
|
setNote({ kind: "err", text: weT("请求失败:") + (e && e.message ? e.message : weT("网络错误")) });
|
|
16316
|
+
if (kind === "activate") {
|
|
16317
|
+
setActive(prevActive);
|
|
16318
|
+
setList((prev) => prev.map((x) => ({ ...x, active: x.id === prevActive })));
|
|
16319
|
+
}
|
|
16287
16320
|
} finally {
|
|
16288
16321
|
setBusy("");
|
|
16289
16322
|
}
|
|
@@ -16320,6 +16353,22 @@ window.__ModuleLoader__.load({
|
|
|
16320
16353
|
}
|
|
16321
16354
|
|
|
16322
16355
|
const children = [React.createElement("div", { className: "we-picker__section", key: "sec" }, header)];
|
|
16356
|
+
// 常驻一行「当前皮肤」:切换只写文件、皮肤要重启才生效,不给这一行用户就无从判断
|
|
16357
|
+
// 刚才那次点击到底成没成(这是"点了没反应"的一半原因)。
|
|
16358
|
+
if (active) {
|
|
16359
|
+
const activeName = (list.find((x) => x.id === active) || {}).name || active;
|
|
16360
|
+
children.push(React.createElement("div", {
|
|
16361
|
+
key: "active",
|
|
16362
|
+
className: "we-picker__hint",
|
|
16363
|
+
style: { margin: "4px 0 8px", display: "flex", gap: "8px", alignItems: "center", flexWrap: "wrap" },
|
|
16364
|
+
},
|
|
16365
|
+
React.createElement("span", null, weT("当前皮肤:") + activeName),
|
|
16366
|
+
React.createElement("span", {
|
|
16367
|
+
style: { fontSize: "11px", padding: "1px 6px", borderRadius: "999px", background: "rgba(142,230,168,0.16)", color: "#8ee6a8" },
|
|
16368
|
+
}, weT("重启 DSH 生效")),
|
|
16369
|
+
));
|
|
16370
|
+
}
|
|
16371
|
+
|
|
16323
16372
|
if (error) {
|
|
16324
16373
|
children.push(React.createElement("div", {
|
|
16325
16374
|
key: "err",
|
|
@@ -17332,6 +17381,9 @@ window.__ModuleLoader__.load({
|
|
|
17332
17381
|
// 两页,外加壁纸页。
|
|
17333
17382
|
const QP_TABS = [
|
|
17334
17383
|
{ id: "wallpaper", get label() { return weT("壁纸"); } },
|
|
17384
|
+
// 「皮肤包」与设置页那个页签是**同一个组件**(SkinsTabPanel):首页这里只是把它挂进抽屉,
|
|
17385
|
+
// 不另写一份列表逻辑 —— 两份实现迟早会漂移。
|
|
17386
|
+
{ id: "skins", get label() { return weT("皮肤包"); } },
|
|
17335
17387
|
{ id: "appearance", get label() { return weT("外观"); } },
|
|
17336
17388
|
{ id: "playback", get label() { return weT("播放"); } },
|
|
17337
17389
|
];
|
|
@@ -17977,11 +18029,17 @@ window.__ModuleLoader__.load({
|
|
|
17977
18029
|
target: "playback",
|
|
17978
18030
|
title: weT("在设置页打开「播放」页签 —— 出图来源 / 实时帧 / 帧率上限在那里"),
|
|
17979
18031
|
}
|
|
17980
|
-
:
|
|
17981
|
-
|
|
17982
|
-
|
|
17983
|
-
|
|
17984
|
-
|
|
18032
|
+
: qpTab === "skins"
|
|
18033
|
+
? {
|
|
18034
|
+
label: weT("皮肤包设置 ›"),
|
|
18035
|
+
target: "skins",
|
|
18036
|
+
title: weT("在设置页打开「皮肤包」页签 —— 下载 / 切换 / 删除皮肤包"),
|
|
18037
|
+
}
|
|
18038
|
+
: {
|
|
18039
|
+
label: weT("壁纸引擎设置 ›"),
|
|
18040
|
+
target: "",
|
|
18041
|
+
title: weT("打开设置对话框的「壁纸引擎」分区(外观 / 播放 / 系统与全部配置)"),
|
|
18042
|
+
};
|
|
17985
18043
|
|
|
17986
18044
|
return React.createElement("div", { className: "we-qp we-qp--" + dock },
|
|
17987
18045
|
qpRenderCurrent(sel, current, playbackLive),
|
|
@@ -18011,7 +18069,10 @@ window.__ModuleLoader__.load({
|
|
|
18011
18069
|
})
|
|
18012
18070
|
: qpTab === "playback"
|
|
18013
18071
|
? qpRenderPlaybackPane(sel, switchQpTab)
|
|
18014
|
-
|
|
18072
|
+
// 皮肤包:直接挂设置页那个同一个组件(它自己管列表/下载/激活状态)。
|
|
18073
|
+
: qpTab === "skins"
|
|
18074
|
+
? React.createElement(SkinsTabPanel, null)
|
|
18075
|
+
: null),
|
|
18015
18076
|
!(qpTab === "wallpaper" && userPropsPanelOpen() && propsAvailable) && qpTab === "wallpaper" && React.createElement(React.Fragment, null,
|
|
18016
18077
|
// ── 壁纸列表(搜索 + 视图切换 + 快切)──
|
|
18017
18078
|
// 库还没回来 / 扫描失败:**只有这一页**给一句话 —— 外观 / 播放两页不依赖库,
|