优化架构K8s 副本和队列

This commit is contained in:
Azmat@qq.com
2026-09-03 16:38:02 +08:00
parent f53b6e1035
commit e7122b78fb
9 changed files with 80 additions and 10 deletions
+7 -1
View File
@@ -453,7 +453,13 @@ export function App() {
}
const active = detail.video_segments.filter((segment) => ["running", "queued"].includes(segment.status));
if (active.length === 0) return;
await Promise.all(active.map((segment) => api.pollVideo(activeProjectId, segment.id).catch(() => undefined)));
const polls = await Promise.all(active.map((segment) => api.pollVideo(activeProjectId, segment.id).catch(() => undefined)));
// 仍在 queued/running 就别拉整棵项目树(26KB);只有某段终态才回读详情。
const settled = polls.some((row) => {
const status = row && typeof row === "object" ? (row as { status?: string }).status : "";
return Boolean(status) && status !== "running" && status !== "queued";
}) || polls.some((row) => row && typeof row === "object" && "id" in (row as object));
if (!settled) return;
const next = await api.project(activeProjectId).catch(() => null);
// 晚到的旧项目轮询结果不要冲掉已切换的当前项目详情
if (next && next.id === activeProjectIdRef.current) {
+11 -2
View File
@@ -2668,8 +2668,17 @@ export function PipelinePage(props: {
const activeVideoCount = segments.filter((s) => ["running", "queued"].includes(s.status)).length;
useEffect(() => {
if (activeVideoCount === 0) return;
const timer = window.setInterval(() => { void onPollVideosQuiet(); }, 5000);
return () => window.clearInterval(timer);
const tick = () => {
if (document.hidden) return;
void onPollVideosQuiet();
};
const timer = window.setInterval(tick, 5000);
const onVis = () => { if (!document.hidden) void onPollVideosQuiet(); };
document.addEventListener("visibilitychange", onVis);
return () => {
window.clearInterval(timer);
document.removeEventListener("visibilitychange", onVis);
};
}, [activeVideoCount, onPollVideosQuiet]);
// 进入视频 / 拼接阶段时回填已有成片(此前合成过就直接给出播放/下载入口)