auto-save 2026-05-12 15:57 (~5)

This commit is contained in:
2026-05-12 15:57:18 +08:00
parent 2e45ad9d16
commit 064083ef0a
5 changed files with 166 additions and 33 deletions

View File

@@ -5,7 +5,7 @@ import { UrlInput } from "@/components/url-input"
import { JobStatusBar } from "@/components/job-status"
import { KeyframeGallery } from "@/components/keyframe-gallery"
import { TranscriptPanel } from "@/components/transcript-panel"
import { createJob, getJob, triggerTranscribe, videoUrl, type Job } from "@/lib/api"
import { createJob, getJob, triggerTranscribe, uploadJob, videoUrl, type Job } from "@/lib/api"
export default function Home() {
const [job, setJob] = useState<Job | null>(null)
@@ -30,6 +30,22 @@ export default function Home() {
}
}, [])
const handleUpload = useCallback(async (file: File) => {
setSubmitting(true)
setSelected(new Set())
transcribeTriggeredRef.current = null
try {
toast.info(`正在上传 ${file.name} (${(file.size / 1024 / 1024).toFixed(1)} MB)`)
const created = await uploadJob(file)
setJob(created)
toast.success(`已上传,任务 ${created.id.slice(0, 8)}`)
} catch (e) {
toast.error("上传失败:" + (e instanceof Error ? e.message : String(e)))
} finally {
setSubmitting(false)
}
}, [])
// 轮询 job 状态
useEffect(() => {
if (!job) return
@@ -93,7 +109,11 @@ export default function Home() {
{/* URL 输入 */}
<section>
<UrlInput loading={submitting || (job !== null && job.status !== "transcribed" && job.status !== "failed")} onSubmit={handleSubmit} />
<UrlInput
loading={submitting || (job !== null && job.status !== "transcribed" && job.status !== "failed")}
onSubmitUrl={handleSubmit}
onUploadFile={handleUpload}
/>
</section>
{job && (
@@ -146,7 +166,7 @@ export default function Home() {
{!job && (
<section className="text-center py-16">
<div className="font-serif text-2xl text-white/30"> TikTok </div>
<div className="font-serif text-2xl text-white/30"> TikTok / </div>
</section>
)}