fix: route video agent to comfyui and ignore openspec

This commit is contained in:
boos
2026-05-21 16:44:30 +02:00
parent 9c84759498
commit d0912e44b4
31 changed files with 350 additions and 1932 deletions
+46 -2
View File
@@ -4,10 +4,11 @@ import { getSessionToken } from '../authSession.js';
export default function ComfyUI() {
const [isDark, setIsDark] = React.useState(true);
const [iframeSrc, setIframeSrc] = React.useState('');
const [starting, setStarting] = React.useState(true);
const location = useLocation();
const audience = location.pathname.startsWith('/user/') ? 'user' : 'admin';
const token = getSessionToken(audience, localStorage);
const iframeSrc = token ? `/comfy/?token=${encodeURIComponent(token)}` : '';
React.useEffect(() => {
const el = document.documentElement;
@@ -18,6 +19,49 @@ export default function ComfyUI() {
return () => mo.disconnect();
}, []);
React.useEffect(() => {
let cancelled = false;
const encodedToken = token ? encodeURIComponent(token) : '';
if (!token) {
setIframeSrc('');
setStarting(false);
return () => {
cancelled = true;
};
}
setStarting(true);
setIframeSrc('');
const start = async () => {
try {
const response = await fetch('/api/video-agent/start', {
method: 'POST',
headers: { Authorization: `Bearer ${token}` },
});
if (!cancelled && response.ok) {
setIframeSrc(`/comfy/?token=${encodedToken}`);
return;
}
} catch {
// Fall through to the legacy embedded ComfyUI proxy.
}
if (!cancelled) {
setIframeSrc('/api/comfyui/proxy/');
}
};
void start().finally(() => {
if (!cancelled) setStarting(false);
});
return () => {
cancelled = true;
};
}, [token]);
return (
<div
style={{
@@ -47,7 +91,7 @@ export default function ComfyUI() {
color: 'var(--color-text-muted)',
fontSize: 14,
}}>
登录状态已过期,请重新登录。
{starting ? '正在启动 ComfyUI...' : '登录状态已过期,请重新登录。'}
</div>
)}
</div>