diff --git a/src/ui/(console)/projects/video-item.tsx b/src/ui/(console)/projects/video-item.tsx index 881a2af..fd80601 100644 --- a/src/ui/(console)/projects/video-item.tsx +++ b/src/ui/(console)/projects/video-item.tsx @@ -3,9 +3,19 @@ import { IoEllipsisHorizontal } from "react-icons/io5"; import { useTranslations } from "next-intl"; import useFetch from "@/hooks/useFetch"; import { useEffect } from "react"; +import { useToast } from "@/contexts/ToastContext"; export default function VideoItem({ item }) { const t = useTranslations("videoItem"); // 使用翻译 + const { addToast } = useToast(); + const { + fetchData: extendVideo, + loading: extendVideoLoading, + data: extendVideoData, + } = useFetch({ + url: "/api/extend-video/", + method: "POST", + }); const getStatusBadge = (status) => { switch (status) { @@ -23,15 +33,22 @@ export default function VideoItem({ item }) { } }; + const handleExtendVideo = async () => { + if (extendVideoLoading) return; + try { + await extendVideo({ task_id: item.pid, motion_score: null }); // 假设你要传递video的ID + addToast(t("extendSuccess"), "success"); + window.location.reload(); // 请求成功后刷新页面 + } catch (error) { + console.error("Failed to extend video", error); + } + }; + return ( <>