dsh-folia 4.26.0-pre.35 → 4.26.0-pre.37
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/boot/index.js +18 -1
- package/lib/client.js +82 -1
- package/lib/routes/boot.js +41 -1
- package/lib/routes/skins.js +3 -1
- package/package.json +1 -1
package/lib/boot/index.js
CHANGED
|
@@ -23,6 +23,14 @@ export function bootDir() {
|
|
|
23
23
|
try { if (!existsSync(d)) mkdirSync(d, { recursive: true }); } catch { /* 只读盘:后续写入会失败并如实报错 */ }
|
|
24
24
|
return d;
|
|
25
25
|
}
|
|
26
|
+
/** 第一幕图片(本地文件;存在且 act1.image=true 时注入脚本才用它)。 */
|
|
27
|
+
export function act1ImagePath() {
|
|
28
|
+
return join(bootDir(), 'act1-image.png');
|
|
29
|
+
}
|
|
30
|
+
export function act1ImageExists() {
|
|
31
|
+
try { return existsSync(act1ImagePath()) && statSync(act1ImagePath()).size > 0; } catch { return false; }
|
|
32
|
+
}
|
|
33
|
+
|
|
26
34
|
export function bootConfigPath() {
|
|
27
35
|
return join(bootHome(), 'config.json');
|
|
28
36
|
}
|
|
@@ -62,6 +70,8 @@ export function readBoot() {
|
|
|
62
70
|
enabled: a.enabled === true,
|
|
63
71
|
text: typeof a.text === 'string' ? a.text.slice(0, 60) : '',
|
|
64
72
|
durationMs: Number.isFinite(Number(a.durationMs)) ? Math.min(5000, Math.max(300, Number(a.durationMs))) : 1200,
|
|
73
|
+
// 有图片且开启时,第一幕用图(图存在 boot 目录,由 /boot/act1-image 提供)
|
|
74
|
+
image: a.image === true,
|
|
65
75
|
};
|
|
66
76
|
})(),
|
|
67
77
|
// 进入方式:tail = 播完再进(默认);ready = 应用就绪就进;click = 点一下才进。
|
|
@@ -260,6 +270,11 @@ export const BOOT_SCREEN_SOURCE = String.raw`
|
|
|
260
270
|
act1.setAttribute("style",
|
|
261
271
|
"position:absolute;inset:0;background:#000;display:flex;align-items:center;justify-content:center;" +
|
|
262
272
|
"color:#fff;font-size:28px;letter-spacing:2px;transition:opacity 500ms ease;opacity:1;");
|
|
273
|
+
if (cfg.act1.imageUrl) {
|
|
274
|
+
act1.style.backgroundImage = "url(" + cfg.act1.imageUrl + ")";
|
|
275
|
+
act1.style.backgroundSize = "cover";
|
|
276
|
+
act1.style.backgroundPosition = "center";
|
|
277
|
+
}
|
|
263
278
|
act1.textContent = cfg.act1.text || "";
|
|
264
279
|
root.appendChild(act1);
|
|
265
280
|
setTimeout(function () {
|
|
@@ -409,7 +424,9 @@ export function installBootInjection(ctx, note) {
|
|
|
409
424
|
enterMode: boot.enterMode,
|
|
410
425
|
sound: boot.sound,
|
|
411
426
|
transition: boot.transition,
|
|
412
|
-
act1: boot.act1
|
|
427
|
+
act1: (boot.act1 && boot.act1.image && act1ImageExists())
|
|
428
|
+
? { ...boot.act1, imageUrl: '/folia/boot/act1-image?v=' + Date.now() }
|
|
429
|
+
: boot.act1,
|
|
413
430
|
volume: boot.volume,
|
|
414
431
|
};
|
|
415
432
|
table.push({ kind: 'script', placement: 'head', text: 'globalThis.__FOLIA_BOOT__=' + JSON.stringify(cfg) });
|
package/lib/client.js
CHANGED
|
@@ -764,6 +764,15 @@ window.__ModuleLoader__.load({
|
|
|
764
764
|
"对话": "Chat",
|
|
765
765
|
"可选工作能力(已安装才可用)": "Optional work capabilities (installed only)",
|
|
766
766
|
"能力": "Capabilities",
|
|
767
|
+
"预览效果": "Preview",
|
|
768
|
+
"预览:第一幕 + 前 3 秒": "Preview: act 1 + first 3s",
|
|
769
|
+
"第一幕时长": "Act 1 length",
|
|
770
|
+
"第一幕用图片": "Act 1 uses an image",
|
|
771
|
+
"上传第一幕图片(PNG)": "Upload act 1 image (PNG)",
|
|
772
|
+
"已上传第一幕图片": "Act 1 image uploaded",
|
|
773
|
+
"上传失败": "Upload failed",
|
|
774
|
+
"图片太大(上限 4MB)": "Image too large (4MB max)",
|
|
775
|
+
"先选一条素材": "Pick a clip first",
|
|
767
776
|
"退场": "Exit",
|
|
768
777
|
"淡出": "Fade",
|
|
769
778
|
"放大淡出": "Scale + fade",
|
|
@@ -17920,6 +17929,8 @@ window.__ModuleLoader__.load({
|
|
|
17920
17929
|
const [state, setState] = React.useState(null);
|
|
17921
17930
|
const [busy, setBusy] = React.useState("");
|
|
17922
17931
|
const [note, setNote] = React.useState(null);
|
|
17932
|
+
// C1:面板内预览(不用重启就能看到素材本身)
|
|
17933
|
+
const [preview, setPreview] = React.useState(false);
|
|
17923
17934
|
// 4.23.3:卡片状态以 /folia/downloads/list 为唯一真源 —— 切页签重新挂载后,
|
|
17924
17935
|
// 这里拉回来的 job 会让「下载中… x%」直接出现,而不是回到「下载」。
|
|
17925
17936
|
const dl = useDownloadJobs();
|
|
@@ -18264,6 +18275,55 @@ window.__ModuleLoader__.load({
|
|
|
18264
18275
|
onBlur: (e) => act("settings", { act1: { enabled: true, text: e.target.value, durationMs: (state.act1 && state.act1.durationMs) || 1200 } }, ""),
|
|
18265
18276
|
style: { width: "220px", fontSize: "12px" },
|
|
18266
18277
|
}) : null,
|
|
18278
|
+
(state.act1 && state.act1.enabled) ? React.createElement("label", { style: { display: "flex", gap: "4px", alignItems: "center", fontSize: "12px" } },
|
|
18279
|
+
weT("第一幕时长"),
|
|
18280
|
+
React.createElement("select", {
|
|
18281
|
+
className: "we-picker__playlist-select",
|
|
18282
|
+
value: String((state.act1 && state.act1.durationMs) || 1200),
|
|
18283
|
+
disabled: Boolean(busy),
|
|
18284
|
+
onChange: (e) => act("settings", { act1: { enabled: true, text: (state.act1 && state.act1.text) || "", durationMs: Number(e.target.value), image: Boolean(state.act1 && state.act1.image) } }, ""),
|
|
18285
|
+
},
|
|
18286
|
+
React.createElement("option", { value: "600" }, "0.6s"),
|
|
18287
|
+
React.createElement("option", { value: "1200" }, "1.2s"),
|
|
18288
|
+
React.createElement("option", { value: "2000" }, "2.0s"),
|
|
18289
|
+
React.createElement("option", { value: "3000" }, "3.0s"),
|
|
18290
|
+
),
|
|
18291
|
+
) : null,
|
|
18292
|
+
(state.act1 && state.act1.enabled) ? React.createElement("label", { style: { display: "flex", gap: "6px", alignItems: "center", fontSize: "12px" } },
|
|
18293
|
+
React.createElement("input", {
|
|
18294
|
+
type: "checkbox",
|
|
18295
|
+
checked: Boolean(state.act1 && state.act1.image),
|
|
18296
|
+
disabled: Boolean(busy),
|
|
18297
|
+
onChange: (e) => act("settings", { act1: { enabled: true, text: (state.act1 && state.act1.text) || "", durationMs: (state.act1 && state.act1.durationMs) || 1200, image: e.target.checked } }, ""),
|
|
18298
|
+
}),
|
|
18299
|
+
weT("第一幕用图片"),
|
|
18300
|
+
) : null,
|
|
18301
|
+
(state.act1 && state.act1.enabled && state.act1.image) ? React.createElement("button", {
|
|
18302
|
+
type: "button", className: "we-picker__btn", disabled: Boolean(busy),
|
|
18303
|
+
onClick: () => {
|
|
18304
|
+
const input = document.createElement("input");
|
|
18305
|
+
input.type = "file";
|
|
18306
|
+
input.accept = "image/png";
|
|
18307
|
+
input.style.display = "none";
|
|
18308
|
+
input.addEventListener("change", () => {
|
|
18309
|
+
const file = input.files && input.files[0];
|
|
18310
|
+
if (!file) return;
|
|
18311
|
+
if (file.size > 4 * 1024 * 1024) { setNote({ ok: false, text: weT("图片太大(上限 4MB)") }); return; }
|
|
18312
|
+
const reader = new FileReader();
|
|
18313
|
+
reader.onload = () => {
|
|
18314
|
+
const raw = String(reader.result || "");
|
|
18315
|
+
const comma = raw.indexOf(",");
|
|
18316
|
+
const data = comma >= 0 ? raw.slice(comma + 1) : raw;
|
|
18317
|
+
void apiPostJson("/boot/act1-image", { data }, { parse: "always" }).then((resp) => {
|
|
18318
|
+
const doc = (resp && resp.data) || null;
|
|
18319
|
+
setNote(doc && doc.ok ? { ok: true, text: weT("已上传第一幕图片") } : { ok: false, text: weT("上传失败") });
|
|
18320
|
+
}).catch(() => setNote({ ok: false, text: weT("上传失败") }));
|
|
18321
|
+
};
|
|
18322
|
+
reader.readAsDataURL(file);
|
|
18323
|
+
});
|
|
18324
|
+
input.click();
|
|
18325
|
+
},
|
|
18326
|
+
}, weT("上传第一幕图片(PNG)")) : null,
|
|
18267
18327
|
opt(weT("最短显示"), "minShowMs", [[0, weT("不限制")], [600, weT("0.6 秒")], [1200, weT("1.2 秒")], [2000, weT("2 秒")]]),
|
|
18268
18328
|
opt(weT("最长停留"), "maxHoldMs", [[10000, weT("10 秒")], [20000, weT("20 秒(默认)")], [30000, weT("30 秒")], [60000, weT("60 秒")]]),
|
|
18269
18329
|
));
|
|
@@ -18301,6 +18361,10 @@ window.__ModuleLoader__.load({
|
|
|
18301
18361
|
}, weT("导入本地动画")),
|
|
18302
18362
|
React.createElement("span", { className: "we-picker__hint" },
|
|
18303
18363
|
weT("支持 mp4 / webm,≤64MB;导入后只在本地,不上传站点")),
|
|
18364
|
+
React.createElement("button", {
|
|
18365
|
+
type: "button", className: "we-picker__btn", disabled: Boolean(busy) || !activeId,
|
|
18366
|
+
onClick: () => setPreview((v) => !v),
|
|
18367
|
+
}, weT("预览效果")),
|
|
18304
18368
|
));
|
|
18305
18369
|
children.push(React.createElement("div", { key: "count", className: "we-picker__hint", style: { margin: "2px 0 4px" } },
|
|
18306
18370
|
weT("已下载 {done} / {total}", { done: installedCount, total: clips.length })));
|
|
@@ -18372,6 +18436,20 @@ window.__ModuleLoader__.load({
|
|
|
18372
18436
|
React.createElement("span", { className: "we-picker__hint" }, weT("素材来自站点;站点不可达时这里为空,但不影响启动"))));
|
|
18373
18437
|
}
|
|
18374
18438
|
|
|
18439
|
+
if (preview && activeId) {
|
|
18440
|
+
children.push(React.createElement("div", {
|
|
18441
|
+
key: "preview",
|
|
18442
|
+
style: { position: "fixed", inset: 0, zIndex: 9999, background: "rgba(0,0,0,.72)", display: "flex", alignItems: "center", justifyContent: "center" },
|
|
18443
|
+
onClick: () => setPreview(false),
|
|
18444
|
+
},
|
|
18445
|
+
React.createElement("video", {
|
|
18446
|
+
src: "/folia/boot/clip?v=" + encodeURIComponent(activeId),
|
|
18447
|
+
autoPlay: true, muted: true, playsInline: true,
|
|
18448
|
+
style: { width: "min(720px, 88vw)", aspectRatio: "16 / 9", borderRadius: "10px", background: "#000" },
|
|
18449
|
+
}),
|
|
18450
|
+
));
|
|
18451
|
+
}
|
|
18452
|
+
|
|
18375
18453
|
return React.createElement(React.Fragment, null, children);
|
|
18376
18454
|
}
|
|
18377
18455
|
|
|
@@ -20257,6 +20335,9 @@ window.__ModuleLoader__.load({
|
|
|
20257
20335
|
});
|
|
20258
20336
|
}
|
|
20259
20337
|
if (kind === "remove") setNote({ ok: true, text: weT("已卸载:{name}", { name: label || "" }) });
|
|
20338
|
+
// 卸载成功后必须把这张卡片的失败/安装中状态清掉:
|
|
20339
|
+
// 真实事故 —— 卸完了,卡片还挂着上一轮「下载已完成但安装未落地 · 重试」,看着像没删掉。
|
|
20340
|
+
if (kind === "remove" && cardId) cards.end(cardId);
|
|
20260
20341
|
if (kind === "repair") {
|
|
20261
20342
|
setNote({
|
|
20262
20343
|
ok: true,
|
|
@@ -24757,7 +24838,7 @@ window.__ModuleLoader__.load({
|
|
|
24757
24838
|
*/
|
|
24758
24839
|
|
|
24759
24840
|
/** 每条壁纸最多自愈几次。超过就只提示 —— 防"每次 error 都重下"的死循环。 */
|
|
24760
|
-
const LF_HEAL_MAX_TRIES =
|
|
24841
|
+
const LF_HEAL_MAX_TRIES = 4;
|
|
24761
24842
|
/** 轮询救援产物/重下的间隔与上限(转码是几十秒级的,给 3 分钟)。 */
|
|
24762
24843
|
const LF_HEAL_POLL_MS = 1500;
|
|
24763
24844
|
const LF_HEAL_POLL_MAX_MS = 3 * 60 * 1000;
|
package/lib/routes/boot.js
CHANGED
|
@@ -13,7 +13,7 @@ import { createReadStream, existsSync, readFileSync, rmSync, statSync, writeFile
|
|
|
13
13
|
import { sendJson } from '../json-response.js';
|
|
14
14
|
import { bodyReader } from '../http-body.js';
|
|
15
15
|
import { resolveModules } from './modules.js';
|
|
16
|
-
import { clipExists, clipFile, clipMetaFile, listLocalClips, readBoot, importLocalClip, removeClip, resolveClipFile, writeBoot } from '../boot/index.js';
|
|
16
|
+
import { clipExists, clipFile, clipMetaFile, listLocalClips, readBoot, importLocalClip, act1ImagePath, act1ImageExists, removeClip, resolveClipFile, writeBoot } from '../boot/index.js';
|
|
17
17
|
// 4.24.0:站点清单端点偏好(v1 优先 / v0 回退)的唯一实现 —— 四族共用。
|
|
18
18
|
import { siteListFetch } from '../site-list.js';
|
|
19
19
|
// 4.23.3:开机动画下载改走**下载队列**(Range 续传 / 自适应多连接 / 进度可读)。
|
|
@@ -415,6 +415,46 @@ disposers.push(webServer.register({
|
|
|
415
415
|
},
|
|
416
416
|
}));
|
|
417
417
|
|
|
418
|
+
/* ②c 第一幕图片:上传(base64 PNG,≤4MB)/ 读取 */
|
|
419
|
+
disposers.push(webServer.register({
|
|
420
|
+
kind: 'exact',
|
|
421
|
+
path: `${BASE}/boot/act1-image`,
|
|
422
|
+
handler: async (req, res) => {
|
|
423
|
+
if ((req.method || 'GET').toUpperCase() === 'GET') {
|
|
424
|
+
if (!act1ImageExists()) { sendJson(res, 404, { ok: false, error: 'not-found' }); return; }
|
|
425
|
+
try {
|
|
426
|
+
const buf = readFileSync(act1ImagePath());
|
|
427
|
+
res.statusCode = 200;
|
|
428
|
+
res.setHeader('Content-Type', 'image/png');
|
|
429
|
+
res.setHeader('Cache-Control', 'no-store');
|
|
430
|
+
res.end(buf);
|
|
431
|
+
} catch (error) {
|
|
432
|
+
sendJson(res, 500, { ok: false, error: String((error && error.message) || error) });
|
|
433
|
+
}
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
if ((req.method || 'GET').toUpperCase() !== 'POST') { sendJson(res, 405, { ok: false, error: 'method' }); return; }
|
|
437
|
+
let doc = null;
|
|
438
|
+
try {
|
|
439
|
+
const text = await readBodyText(req, 8 * 1024 * 1024);
|
|
440
|
+
doc = JSON.parse(text || '{}');
|
|
441
|
+
} catch { doc = null; }
|
|
442
|
+
if (!doc || typeof doc.data !== 'string' || !doc.data) { sendJson(res, 400, { ok: false, error: 'bad-request' }); return; }
|
|
443
|
+
let buf = null;
|
|
444
|
+
try { buf = Buffer.from(doc.data, 'base64'); } catch { buf = null; }
|
|
445
|
+
if (!buf || !buf.length) { sendJson(res, 400, { ok: false, error: 'bad-data' }); return; }
|
|
446
|
+
const isPng = buf.length > 8 && buf[0] === 0x89 && buf[1] === 0x50 && buf[2] === 0x4e && buf[3] === 0x47;
|
|
447
|
+
if (!isPng) { sendJson(res, 415, { ok: false, error: 'not-png' }); return; }
|
|
448
|
+
if (buf.length > 4 * 1024 * 1024) { sendJson(res, 413, { ok: false, error: 'too-large' }); return; }
|
|
449
|
+
try { writeFileSync(act1ImagePath(), buf); } catch (error) {
|
|
450
|
+
sendJson(res, 500, { ok: false, error: String((error && error.message) || error) });
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
if (typeof log === 'function') log(`[boot] act1 image saved bytes=${buf.length}`);
|
|
454
|
+
sendJson(res, 200, { ok: true, bytes: buf.length });
|
|
455
|
+
},
|
|
456
|
+
}));
|
|
457
|
+
|
|
418
458
|
/* ③ 选择(并顺手启用) */
|
|
419
459
|
disposers.push(webServer.register({
|
|
420
460
|
kind: 'exact',
|
package/lib/routes/skins.js
CHANGED
|
@@ -374,7 +374,9 @@ async function fetchSiteSkins(force) { const now = Date.now();
|
|
|
374
374
|
// 4.23.7:站点给的内容哈希(**可能为空**)。有它 ⇒ 下载完要验内容,
|
|
375
375
|
// 不只是验长度/区间(见 lib/download-queue.js 的 assertContentHash)。
|
|
376
376
|
sha256: it && it.sha256 ? String(it.sha256) : '',
|
|
377
|
-
|
|
377
|
+
// 封面:站点上「缩略图」和「首帧海报」是两个字段。
|
|
378
|
+
// 皮肤包没有首帧,后台补的是 poster ⇒ 这里必须回退,否则卡片永远是空白。
|
|
379
|
+
thumbUrl: it.thumbUrl ? String(it.thumbUrl) : (it.posterUrl ? String(it.posterUrl) : ''),
|
|
378
380
|
// 站点现在把 tags 直接给**数组**(旧版给的是字符串化 JSON)。两种都收:
|
|
379
381
|
// 只认字符串会让「动态」这类标记静默丢失(实测:线上返回 ["皮肤","catppuccin",…])。
|
|
380
382
|
tags: (() => {
|