fix(canvas): 创作工作台 - 恢复连续对话并完善附件、媒体占位与生成分辨率

Fixes #231

Fixes #233
This commit is contained in:
ddCat committed 2026-08-15 22:01:42 +08:00
1 parent 11d9d469f5
commit 7804574f9f
15 files changed
+753 -115

No files matched your search

+4 -7
View File
@@ -1,5 +1,5 @@
export const VIDEO_DURATION_OPTIONS = [6, 9, 10, 15] as const;
export const VIDEO_RESOLUTION_OPTIONS = [480, 720, 1080, 2160] as const;
export const VIDEO_RESOLUTION_OPTIONS = [480, 720, 1080, 1440, 2160] as const;
export const VIDEO_DURATION_MIN = 1;
export function normalizeVideoDuration(value: string | number | undefined) {
@@ -11,11 +11,8 @@ export function normalizeVideoResolution(value: string | number | undefined) {
const token = String(value || "").trim().toLowerCase();
if (token === "low") return "480";
if (token === "auto" || token === "medium" || token === "high") return "720";
if (token === "2k") return "1440";
if (token === "4k") return "2160";
const resolution = Number(token.replace(/p$/i, "")) || 720;
return String(nearestOption(resolution, VIDEO_RESOLUTION_OPTIONS));
}
function nearestOption(value: number, options: readonly number[]) {
return options.reduce((nearest, option) => Math.abs(option - value) < Math.abs(nearest - value) ? option : nearest, options[0]);
const resolution = Number(token.replace(/p$/i, ""));
return Number.isFinite(resolution) && resolution > 0 ? String(Math.floor(resolution)) : "720";
}