forked from 77media/video-flow
60 lines
1.9 KiB
TypeScript
60 lines
1.9 KiB
TypeScript
import React, { useState, useCallback, useEffect, SetStateAction } from 'react';
|
|
import { motion, AnimatePresence } from 'framer-motion';
|
|
import { FileText } from 'lucide-react';
|
|
import { ScriptRenderer } from '@/components/script-renderer/ScriptRenderer';
|
|
import { useEditData } from '@/components/pages/work-flow/use-edit-data';
|
|
|
|
|
|
interface ScriptTabContentProps {
|
|
setIsPauseWorkFlow: (isPauseWorkFlow: boolean) => void;
|
|
isPauseWorkFlow: boolean;
|
|
originalText?: string;
|
|
}
|
|
|
|
export function ScriptTabContent({
|
|
setIsPauseWorkFlow,
|
|
isPauseWorkFlow,
|
|
originalText,
|
|
}: ScriptTabContentProps) {
|
|
const { loading, scriptData, setAnyAttribute, applyScript } = useEditData('script', originalText);
|
|
|
|
// 如果loading 显示loading状态
|
|
if (loading) {
|
|
return (
|
|
<div className="flex flex-col items-center justify-center min-h-[400px] text-white/50">
|
|
<div className="w-12 h-12 mb-4 animate-spin rounded-full border-b-2 border-blue-600" />
|
|
<p>Loading...</p>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
// 如果没有数据,显示空状态
|
|
if (!scriptData || scriptData.length === 0) {
|
|
return (
|
|
<div className="flex flex-col items-center justify-center min-h-[400px] text-white/50">
|
|
<FileText className="w-16 h-16 mb-4" />
|
|
<p>No script data</p>
|
|
</div>
|
|
);
|
|
}
|
|
return (
|
|
<div className="flex flex-col h-full">
|
|
<motion.div
|
|
className="relative w-full h-[90vh] backdrop-blur-xl rounded-2xl shadow-2xl overflow-hidden flex flex-col"
|
|
initial={{ opacity: 0, y: 20 }}
|
|
animate={{ opacity: 1, y: 0 }}
|
|
>
|
|
<ScriptRenderer
|
|
data={scriptData}
|
|
setIsPauseWorkFlow={setIsPauseWorkFlow}
|
|
setAnyAttribute={setAnyAttribute}
|
|
isPauseWorkFlow={isPauseWorkFlow}
|
|
applyScript={applyScript}
|
|
mode='manual'
|
|
from='tab'
|
|
/>
|
|
</motion.div>
|
|
</div>
|
|
);
|
|
};
|