延长视频

This commit is contained in:
liangzai 2024-09-21 22:30:45 +08:00
parent 308ed895a0
commit cb769fa2ed
2 changed files with 39 additions and 5 deletions

View File

@ -3,9 +3,19 @@ import { IoEllipsisHorizontal } from "react-icons/io5";
import { useTranslations } from "next-intl"; import { useTranslations } from "next-intl";
import useFetch from "@/hooks/useFetch"; import useFetch from "@/hooks/useFetch";
import { useEffect } from "react"; import { useEffect } from "react";
import { useToast } from "@/contexts/ToastContext";
export default function VideoItem({ item }) { export default function VideoItem({ item }) {
const t = useTranslations("videoItem"); // 使用翻译 const t = useTranslations("videoItem"); // 使用翻译
const { addToast } = useToast();
const {
fetchData: extendVideo,
loading: extendVideoLoading,
data: extendVideoData,
} = useFetch({
url: "/api/extend-video/",
method: "POST",
});
const getStatusBadge = (status) => { const getStatusBadge = (status) => {
switch (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 ( return (
<> <>
<div className="group flex flex-col gap-4 items-stretch bg-base-100 rounded-lg cursor-pointer bg-opacity-0 hover:bg-opacity-100 transition-all"> <div className="group flex flex-col gap-4 items-stretch bg-base-100 rounded-lg cursor-pointer bg-opacity-0 hover:bg-opacity-100 transition-all">
<div className="relative w-full overflow-hidden bg-base-200 p-4 aspect-video rounded-xl flex items-center justify-center"> <div className="relative w-full overflow-hidden bg-base-200 p-4 aspect-video rounded-xl flex items-center justify-center">
<div className="bg-white w-full h-full rounded-xl shadow-lg mx-3 flex flex-col items-center justify-center overflow-hidden"> <div className="bg-white w-full h-full rounded-xl shadow-lg mx-3 flex flex-col items-center justify-center overflow-hidden">
{/* <div className="text-2xl font-bold">
{item.media_type}
</div>
<div className="text-xl font-bold">{item.slug}</div> */}
<video <video
src={item.video_url} src={item.video_url}
controls controls
@ -103,6 +120,21 @@ export default function VideoItem({ item }) {
) : ( ) : (
<></> <></>
)} )}
{item.status === "completed" && (
<li
onClick={handleExtendVideo}
className="py-[5px] h-8 flex whitespace-nowrap items-center gap-2 text-neutral p-2 hover:bg-base-100 rounded-md cursor-pointer"
>
<div className="flex gap-2 items-center w-full pr-4 transition-opacity opacity-70 hover:opacity-95">
{extendVideoLoading ? (
<span className="loading loading-spinner loading-sm text-secondary"></span>
) : (
t("extendVideo")
)}
{/* 翻译扩展视频 */}
</div>
</li>
)}
</ul> </ul>
</div> </div>
</div> </div>

View File

@ -247,7 +247,9 @@ export default function LoginForm({ toRegister }: LoginFormProps) {
{captchaLoading ? ( {captchaLoading ? (
<span className="loading loading-spinner loading-md text-gray-200"></span> <span className="loading loading-spinner loading-md text-gray-200"></span>
) : captchaTimer > 0 ? ( ) : captchaTimer > 0 ? (
`${captchaTimer}s` <span className="text-gray-200">
{captchaTimer}s
</span>
) : ( ) : (
t("getCaptcha") t("getCaptcha")
)} )}