dsh-folia 4.26.0-pre.30 → 4.26.0-pre.32
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 +37 -2
- package/lib/client.js +57 -0
- package/lib/routes/boot.js +2 -0
- package/package.json +1 -1
package/lib/boot/index.js
CHANGED
|
@@ -53,6 +53,17 @@ export function readBoot() {
|
|
|
53
53
|
items,
|
|
54
54
|
// 素材池取片方式:first=固定第一条;random=随机;rotate=按启动次数轮换
|
|
55
55
|
poolMode: ['first', 'random', 'rotate'].includes(String(raw.poolMode)) ? String(raw.poolMode) : 'first',
|
|
56
|
+
// 退场转场:fade(默认,只透明度)/ scale(轻微放大)/ slide(上滑)
|
|
57
|
+
transition: ['fade', 'scale', 'slide'].includes(String(raw.transition)) ? String(raw.transition) : 'fade',
|
|
58
|
+
// 两幕冷启动:第一幕是纯色 + 一行字(固定标识),第二幕才是素材
|
|
59
|
+
act1: (() => {
|
|
60
|
+
const a = raw.act1 && typeof raw.act1 === 'object' ? raw.act1 : {};
|
|
61
|
+
return {
|
|
62
|
+
enabled: a.enabled === true,
|
|
63
|
+
text: typeof a.text === 'string' ? a.text.slice(0, 60) : '',
|
|
64
|
+
durationMs: Number.isFinite(Number(a.durationMs)) ? Math.min(5000, Math.max(300, Number(a.durationMs))) : 1200,
|
|
65
|
+
};
|
|
66
|
+
})(),
|
|
56
67
|
// 进入方式:tail = 播完再进(默认);ready = 应用就绪就进;click = 点一下才进。
|
|
57
68
|
// 之前没有这个字段,一律「就绪即进」,于是 8~15 秒的片子 1.2 秒就被掐掉。
|
|
58
69
|
enterMode: ['tail', 'ready', 'click'].includes(String(raw.enterMode)) ? String(raw.enterMode) : 'tail',
|
|
@@ -207,7 +218,14 @@ export const BOOT_SCREEN_SOURCE = String.raw`
|
|
|
207
218
|
function teardown() {
|
|
208
219
|
if (done) return;
|
|
209
220
|
done = true;
|
|
210
|
-
|
|
221
|
+
// 退场转场:CSS transition 已在 root 上声明;这里只改目标样式
|
|
222
|
+
try {
|
|
223
|
+
if (root) {
|
|
224
|
+
root.style.opacity = "0";
|
|
225
|
+
if (cfg.transition === "scale") root.style.transform = "scale(1.06)";
|
|
226
|
+
else if (cfg.transition === "slide") root.style.transform = "translateY(-8%)";
|
|
227
|
+
}
|
|
228
|
+
} catch (e) {}
|
|
211
229
|
setTimeout(function () {
|
|
212
230
|
try { if (video) { video.pause(); video.removeAttribute("src"); video.load && video.load(); } } catch (e) {}
|
|
213
231
|
try { if (root && root.parentNode) root.parentNode.removeChild(root); } catch (e) {}
|
|
@@ -220,7 +238,7 @@ export const BOOT_SCREEN_SOURCE = String.raw`
|
|
|
220
238
|
root.setAttribute("style",
|
|
221
239
|
"position:fixed;inset:0;z-index:2147483647;background:#000;" +
|
|
222
240
|
"display:flex;align-items:center;justify-content:center;" +
|
|
223
|
-
"transition:opacity " + (cfg.fadeMs || 900) + "ms ease;opacity:1;");
|
|
241
|
+
"transition:opacity " + (cfg.fadeMs || 900) + "ms ease,transform " + (cfg.fadeMs || 900) + "ms ease;opacity:1;transform:none;");
|
|
224
242
|
video = doc.createElement("video");
|
|
225
243
|
video.setAttribute("muted", "");
|
|
226
244
|
video.muted = true;
|
|
@@ -232,6 +250,21 @@ export const BOOT_SCREEN_SOURCE = String.raw`
|
|
|
232
250
|
video.addEventListener("error", teardown, { once: true });
|
|
233
251
|
root.appendChild(video);
|
|
234
252
|
(doc.body || doc.documentElement).appendChild(root);
|
|
253
|
+
// 两幕冷启动:第一幕是纯色 + 一行字,盖在素材上;到时淡出露出第二幕
|
|
254
|
+
try {
|
|
255
|
+
if (cfg.act1 && cfg.act1.enabled) {
|
|
256
|
+
var act1 = doc.createElement("div");
|
|
257
|
+
act1.setAttribute("style",
|
|
258
|
+
"position:absolute;inset:0;background:#000;display:flex;align-items:center;justify-content:center;" +
|
|
259
|
+
"color:#fff;font-size:28px;letter-spacing:2px;transition:opacity 500ms ease;opacity:1;");
|
|
260
|
+
act1.textContent = cfg.act1.text || "";
|
|
261
|
+
root.appendChild(act1);
|
|
262
|
+
setTimeout(function () {
|
|
263
|
+
try { act1.style.opacity = "0"; } catch (e) {}
|
|
264
|
+
setTimeout(function () { try { if (act1.parentNode) act1.parentNode.removeChild(act1); } catch (e) {} }, 520);
|
|
265
|
+
}, Math.max(300, (cfg.act1.durationMs || 1200)));
|
|
266
|
+
}
|
|
267
|
+
} catch (e) {}
|
|
235
268
|
// 声音:只有用户显式开启才带声;否则静音(否则 Chromium 直接拒绝自动播放)。
|
|
236
269
|
try {
|
|
237
270
|
if (cfg.sound) { video.muted = false; video.volume = (typeof cfg.volume === "number" ? cfg.volume : 1); }
|
|
@@ -372,6 +405,8 @@ export function installBootInjection(ctx, note) {
|
|
|
372
405
|
maxHoldMs: boot.maxHoldMs,
|
|
373
406
|
enterMode: boot.enterMode,
|
|
374
407
|
sound: boot.sound,
|
|
408
|
+
transition: boot.transition,
|
|
409
|
+
act1: boot.act1,
|
|
375
410
|
volume: boot.volume,
|
|
376
411
|
};
|
|
377
412
|
table.push({ kind: 'script', placement: 'head', text: 'globalThis.__FOLIA_BOOT__=' + JSON.stringify(cfg) });
|
package/lib/client.js
CHANGED
|
@@ -764,6 +764,12 @@ window.__ModuleLoader__.load({
|
|
|
764
764
|
"对话": "Chat",
|
|
765
765
|
"可选工作能力(已安装才可用)": "Optional work capabilities (installed only)",
|
|
766
766
|
"能力": "Capabilities",
|
|
767
|
+
"退场": "Exit",
|
|
768
|
+
"淡出": "Fade",
|
|
769
|
+
"放大淡出": "Scale + fade",
|
|
770
|
+
"上滑淡出": "Slide up + fade",
|
|
771
|
+
"两幕(先显示一行字)": "Two acts (text first)",
|
|
772
|
+
"第一幕显示的文字(如店名/品牌)": "Text shown in act 1 (brand/title)",
|
|
767
773
|
"导入本地动画": "Import local clip",
|
|
768
774
|
"支持 mp4 / webm,≤64MB;导入后只在本地,不上传站点": "mp4 / webm, up to 64MB; kept locally, never uploaded",
|
|
769
775
|
"文件太大(上限 64MB)": "File too large (64MB max)",
|
|
@@ -17920,6 +17926,15 @@ window.__ModuleLoader__.load({
|
|
|
17920
17926
|
const resp = await apiJson("/boot/list" + (force ? "?refresh=1" : ""), { parse: "always" });
|
|
17921
17927
|
const r = (resp && resp.data) || null;
|
|
17922
17928
|
setState(r || { ok: false, clips: [], error: "network" });
|
|
17929
|
+
// 过期失败提示自愈:提示说"未落地",但列表里该条已经 installed ⇒ 清掉提示
|
|
17930
|
+
try {
|
|
17931
|
+
setNote((prev) => {
|
|
17932
|
+
if (!prev || prev.ok !== false) return prev;
|
|
17933
|
+
if (!/未落地/.test(String(prev.text || ""))) return prev;
|
|
17934
|
+
const target = (r && Array.isArray(r.clips)) ? r.clips.find((c) => c && c.installed) : null;
|
|
17935
|
+
return target ? null : prev;
|
|
17936
|
+
});
|
|
17937
|
+
} catch { /* ignore */ }
|
|
17923
17938
|
} catch (e) {
|
|
17924
17939
|
setState({ ok: false, clips: [], error: "network" });
|
|
17925
17940
|
}
|
|
@@ -18027,6 +18042,15 @@ window.__ModuleLoader__.load({
|
|
|
18027
18042
|
const code = done.status === "lost" ? "job-lost" : "download-timeout";
|
|
18028
18043
|
cards.fail(cardId, code);
|
|
18029
18044
|
setNote({ ok: false, text: dlFailReason(code) });
|
|
18045
|
+
// 失败提示 12 秒后自动消失:真实事故里"下完但没落地"的提示会一直挂着,误导用户
|
|
18046
|
+
try {
|
|
18047
|
+
if (typeof window !== "undefined" && window.setTimeout) {
|
|
18048
|
+
const tone = String(dlFailReason(code) || "");
|
|
18049
|
+
window.setTimeout(() => {
|
|
18050
|
+
setNote((prev) => (prev && prev.ok === false && prev.text === tone ? null : prev));
|
|
18051
|
+
}, 12000);
|
|
18052
|
+
}
|
|
18053
|
+
} catch { /* ignore */ }
|
|
18030
18054
|
}
|
|
18031
18055
|
} else if (done) {
|
|
18032
18056
|
cards.fail(cardId, done.error || done.status);
|
|
@@ -18176,6 +18200,39 @@ window.__ModuleLoader__.load({
|
|
|
18176
18200
|
React.createElement("option", { value: "rotate" }, weT("轮换")),
|
|
18177
18201
|
),
|
|
18178
18202
|
),
|
|
18203
|
+
// 退场转场:默认淡出;放大/上滑让"片尾进界面"更有收束感
|
|
18204
|
+
React.createElement("label", { style: { display: "flex", gap: "4px", alignItems: "center", fontSize: "12px" } },
|
|
18205
|
+
weT("退场"),
|
|
18206
|
+
React.createElement("select", {
|
|
18207
|
+
className: "we-picker__playlist-select",
|
|
18208
|
+
value: String(state.transition || "fade"),
|
|
18209
|
+
disabled: Boolean(busy),
|
|
18210
|
+
onChange: (e) => act("settings", { transition: e.target.value }, ""),
|
|
18211
|
+
},
|
|
18212
|
+
React.createElement("option", { value: "fade" }, weT("淡出")),
|
|
18213
|
+
React.createElement("option", { value: "scale" }, weT("放大淡出")),
|
|
18214
|
+
React.createElement("option", { value: "slide" }, weT("上滑淡出")),
|
|
18215
|
+
),
|
|
18216
|
+
),
|
|
18217
|
+
// 两幕冷启动:第一幕纯色 + 一行字
|
|
18218
|
+
React.createElement("label", { style: { display: "flex", gap: "6px", alignItems: "center", fontSize: "12px" } },
|
|
18219
|
+
React.createElement("input", {
|
|
18220
|
+
type: "checkbox",
|
|
18221
|
+
checked: Boolean(state.act1 && state.act1.enabled),
|
|
18222
|
+
disabled: Boolean(busy),
|
|
18223
|
+
onChange: (e) => act("settings", { act1: { enabled: e.target.checked, text: (state.act1 && state.act1.text) || "", durationMs: (state.act1 && state.act1.durationMs) || 1200 } }, ""),
|
|
18224
|
+
}),
|
|
18225
|
+
weT("两幕(先显示一行字)"),
|
|
18226
|
+
),
|
|
18227
|
+
(state.act1 && state.act1.enabled) ? React.createElement("input", {
|
|
18228
|
+
type: "text",
|
|
18229
|
+
className: "we-picker__input",
|
|
18230
|
+
placeholder: weT("第一幕显示的文字(如店名/品牌)"),
|
|
18231
|
+
defaultValue: (state.act1 && state.act1.text) || "",
|
|
18232
|
+
disabled: Boolean(busy),
|
|
18233
|
+
onBlur: (e) => act("settings", { act1: { enabled: true, text: e.target.value, durationMs: (state.act1 && state.act1.durationMs) || 1200 } }, ""),
|
|
18234
|
+
style: { width: "220px", fontSize: "12px" },
|
|
18235
|
+
}) : null,
|
|
18179
18236
|
opt(weT("最短显示"), "minShowMs", [[0, weT("不限制")], [600, weT("0.6 秒")], [1200, weT("1.2 秒")], [2000, weT("2 秒")]]),
|
|
18180
18237
|
opt(weT("最长停留"), "maxHoldMs", [[10000, weT("10 秒")], [20000, weT("20 秒(默认)")], [30000, weT("30 秒")], [60000, weT("60 秒")]]),
|
|
18181
18238
|
));
|
package/lib/routes/boot.js
CHANGED
|
@@ -465,6 +465,8 @@ disposers.push(webServer.register({
|
|
|
465
465
|
...(patch.fadeMs !== undefined ? { fadeMs: Number(patch.fadeMs) } : {}),
|
|
466
466
|
...(patch.minShowMs !== undefined ? { minShowMs: Number(patch.minShowMs) } : {}),
|
|
467
467
|
...(patch.maxHoldMs !== undefined ? { maxHoldMs: Number(patch.maxHoldMs) } : {}),
|
|
468
|
+
...(patch.transition !== undefined ? { transition: String(patch.transition) } : {}),
|
|
469
|
+
...(patch.act1 !== undefined && patch.act1 && typeof patch.act1 === 'object' ? { act1: patch.act1 } : {}),
|
|
468
470
|
...(patch.poolMode !== undefined ? { poolMode: String(patch.poolMode) } : {}),
|
|
469
471
|
});
|
|
470
472
|
sendJson(res, 200, { ok: true, ...boot });
|