108 lines
3.6 KiB
TypeScript

import { useEffect, useState } from "react";
import { useShotService } from "@/app/service/Interaction/ShotService";
import { useSearchParams } from 'next/navigation';
const mockShotData = [
{
id: '1',
name: 'Shot 1',
sketchUrl: 'https://example.com/sketch.png',
videoUrl: ['https://video-base-imf.oss-ap-southeast-7.aliyuncs.com/uploads/FJ1-0-20250725023719.mp4'],
status: 1, // 0:视频加载中 1:任务已完成 2:任务失败
lens: [
{
name: 'Shot 1',
script: '镜头聚焦在 President Alfred King 愤怒的脸上,他被压制住了。他发出一声绝望的吼叫,盖过了枪声。',
content: [{
roleName: 'President Alfred King',
content: '我需要一个镜头,镜头聚焦在 愤怒的脸上,他被压制住了。他发出一声绝望的吼叫,盖过了枪声。'
}]
}
]
}, {
id: '2',
name: 'Shot 2',
sketchUrl: 'https://example.com/sketch.png',
videoUrl: ['https://video-base-imf.oss-ap-southeast-7.aliyuncs.com/uploads/FJ3-0-20250725023725.mp4'],
status: 1, // 0:视频加载中 1:任务已完成 2:任务失败
lens: [
{
name: 'Shot 1',
script: '镜头聚焦在 Samuel Ryan 愤怒的脸上,他被压制住了。他发出一声绝望的吼叫,盖过了枪声。',
content: [{
roleName: 'Samuel Ryan',
content: '我需要一个镜头,镜头聚焦在 Samuel Ryan 愤怒的脸上,他被压制住了。他发出一声绝望的吼叫,盖过了枪声。'
}]
}
]
}, {
id: '3',
name: 'Shot 3',
sketchUrl: 'https://example.com/sketch.png',
videoUrl: [],
status: 0, // 0:视频加载中 1:任务已完成 2:任务失败
lens: [
{
name: 'Shot 1',
script: '镜头聚焦在 Samuel Ryan 愤怒的脸上,他被压制住了。他发出一声绝望的吼叫,盖过了枪声。',
content: [{
roleName: 'Samuel Ryan',
content: '我需要一个镜头,镜头聚焦在 Samuel Ryan 愤怒的脸上,他被压制住了。他发出一声绝望的吼叫,盖过了枪声。'
}]
}
]
}, {
id: '4',
name: 'Shot 4',
sketchUrl: 'https://example.com/sketch.png',
videoUrl: [],
status: 2, // 0:视频加载中 1:任务已完成 2:任务失败
lens: [
{
name: 'Shot 1',
script: '镜头聚焦在 Samuel Ryan 愤怒的脸上,他被压制住了。他发出一声绝望的吼叫,盖过了枪声。',
content: [{
roleName: 'Samuel Ryan',
content: '我需要一个镜头,镜头聚焦在 Samuel Ryan 愤怒的脸上,他被压制住了。他发出一声绝望的吼叫,盖过了枪声。'
}]
}
]
}
]
export const useEditData = (tabType: string) => {
const searchParams = useSearchParams();
const projectId = searchParams.get('episodeId') || '';
const [loading, setLoading] = useState(true);
const [shotData, setShotData] = useState<any[]>(mockShotData);
const {
videoSegments,
getVideoSegmentList,
setSelectedSegment,
regenerateVideoSegment
} = useShotService();
useEffect(() => {
if (tabType === 'shot') {
getVideoSegmentList(projectId).then(() => {
console.log('useEditData-----videoSegments', videoSegments);
// setShotData(videoSegments);
setLoading(false);
}).catch((err) => {
console.log('useEditData-----err', err);
setShotData(mockShotData);
setLoading(false);
});
}
}, [tabType]);
return {
loading,
shotData,
setSelectedSegment,
regenerateVideoSegment
}
}