video-shuoshan/web/src/components/VideoGenerationPage.tsx
zyc 566c3a476f
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 2m17s
add 存储桶
2026-03-13 15:38:08 +08:00

53 lines
1.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { useRef, useEffect } from 'react';
import { Sidebar } from './Sidebar';
import { InputBar } from './InputBar';
import { GenerationCard } from './GenerationCard';
import { Toast } from './Toast';
import { UserInfoBar } from './UserInfoBar';
import { useGenerationStore } from '../store/generation';
import styles from './VideoGenerationPage.module.css';
export function VideoGenerationPage() {
const tasks = useGenerationStore((s) => s.tasks);
const loadTasks = useGenerationStore((s) => s.loadTasks);
const scrollRef = useRef<HTMLDivElement>(null);
const prevCountRef = useRef(tasks.length);
// Load tasks from backend on mount (persist across page refresh)
useEffect(() => {
loadTasks();
}, [loadTasks]);
// Auto-scroll to top when new task is added
useEffect(() => {
if (tasks.length > prevCountRef.current && scrollRef.current) {
scrollRef.current.scrollTo({ top: 0, behavior: 'smooth' });
}
prevCountRef.current = tasks.length;
}, [tasks.length]);
return (
<div className={styles.layout}>
<Sidebar />
<main className={styles.main}>
<UserInfoBar />
<div className={styles.contentArea} ref={scrollRef}>
{tasks.length === 0 ? (
<div className={styles.emptyArea}>
<p className={styles.emptyHint}> AI </p>
</div>
) : (
<div className={styles.taskList}>
{tasks.map((task) => (
<GenerationCard key={task.id} task={task} />
))}
</div>
)}
</div>
<InputBar />
</main>
<Toast />
</div>
);
}