优化架构K8s 副本和队列
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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]);
|
||||
|
||||
// 进入视频 / 拼接阶段时回填已有成片(此前合成过就直接给出播放/下载入口)
|
||||
|
||||
Reference in New Issue
Block a user