dsh-folia 2.4.2 → 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.
Files changed (2) hide show
  1. package/lib/client.js +45 -3
  2. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -16264,10 +16264,25 @@ window.__ModuleLoader__.load({
16264
16264
 
16265
16265
  React.useEffect(() => { load(false); }, [load]);
16266
16266
 
16267
+ /**
16268
+ * 执行一个动作(install / activate / remove)。
16269
+ *
16270
+ * ⚠️ **「使用」必须立刻有反馈**:切换皮肤只写 `skin-center-active.json`,host 端 6 ms 就应,
16271
+ * 而皮肤要重启才生效 —— 如果等一次 `?refresh=1`(约 600 ms)再改标记,用户看到的就是
16272
+ * "点了一下,半天没反应"。所以「使用」走**乐观更新**:先本地翻转 active 并把提示打出来,
16273
+ * 请求失败再回滚重拉。装 / 删仍然要重拉(已装标记与体积都变了)。
16274
+ */
16267
16275
  async function act(kind, id, label) {
16268
16276
  if (busy) return;
16269
16277
  setBusy(id);
16270
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
+ }
16271
16286
  try {
16272
16287
  // 同样是包装对象:`ok` 是 HTTP 2xx,业务结论在 `data.ok`(宿主回 `{ok:false,error}`)。
16273
16288
  const resp = await apiPostJson("/skins/" + kind, { id }, { parse: "always" });
@@ -16277,9 +16292,11 @@ window.__ModuleLoader__.load({
16277
16292
  setNote({ kind: "ok", text: weT("已安装:") + label });
16278
16293
  await load(true);
16279
16294
  } else if (kind === "activate") {
16280
- setActive(id);
16281
- setNote({ kind: "ok", text: weT("已切换到「") + label + weT("」,重启 DSH 后生效") });
16282
- await load(true);
16295
+ setNote({
16296
+ kind: "ok",
16297
+ text: weT("已切换到「") + label + weT("」 —— 重启 DSH 后生效"),
16298
+ });
16299
+ // 不再整表重拉:本地标记已经对了,省掉那 600 ms 的"没反应"窗口。
16283
16300
  } else if (kind === "remove") {
16284
16301
  setNote({ kind: "ok", text: weT("已删除:") + label });
16285
16302
  await load(true);
@@ -16288,9 +16305,18 @@ window.__ModuleLoader__.load({
16288
16305
  const code = (r && r.error) || "failed";
16289
16306
  const detail = (r && r.detail) ? "(" + r.detail + ")" : "";
16290
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
+ }
16291
16313
  }
16292
16314
  } catch (e) {
16293
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
+ }
16294
16320
  } finally {
16295
16321
  setBusy("");
16296
16322
  }
@@ -16327,6 +16353,22 @@ window.__ModuleLoader__.load({
16327
16353
  }
16328
16354
 
16329
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
+
16330
16372
  if (error) {
16331
16373
  children.push(React.createElement("div", {
16332
16374
  key: "err",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-folia",
3
- "version": "2.4.2",
3
+ "version": "2.4.3",
4
4
  "description": "Folia 壁纸引擎:把本机 Wallpaper Engine 壁纸搬进 DSH 界面(场景实时渲染 / 视频 / 网页),内置液态玻璃与 Folia 吉祥物,并可从自建站点拉取壁纸。单包形态(组件已合并)。",
5
5
  "type": "module",
6
6
  "engines": {