This commit is contained in:
海龙 2025-08-08 14:09:25 +08:00
commit 067295a2bc
7 changed files with 58 additions and 31 deletions

View File

@ -90,7 +90,7 @@ export interface UseScriptService {
language: string language: string
) => Promise<void>; ) => Promise<void>;
/** 设置任何属性 */ /** 设置任何属性 */
setAnyAttribute: (type: string, value: SetStateAction<string>, tags?: string[]) => void; setAnyAttribute: any;
} }
/** /**
@ -389,41 +389,42 @@ export const useScriptService = (): UseScriptService => {
); );
const setAnyAttributeWrapper = useCallback( const setAnyAttributeWrapper = useCallback(
(type: string, value: SetStateAction<string>, tags?: string[]) => { (type: string, value: string,callback: (old: string) => void=() => {}) => {
console.log('setAnyAttributeWrapper', type);
if (type === 'synopsis') { if (type === 'synopsis') {
setFieldOld(synopsis) setFieldOld(synopsis)
scriptEditUseCase.replaceScript(fieldOld,synopsis) scriptEditUseCase.replaceScript(fieldOld,value )
setSynopsisWrapper(value); setSynopsisWrapper(value);
} else if (type === 'categories') { } else if (type === 'categories') {
setFieldOld(categories.join(',')) setFieldOld(categories.join(','))
scriptEditUseCase.replaceScript(fieldOld,categories.join(',')) scriptEditUseCase.replaceScript(fieldOld,value)
setCategoriesWrapper(tags || []); setCategoriesWrapper(value.split(',') || []);
} else if (type === 'protagonist') { } else if (type === 'protagonist') {
setFieldOld(protagonist) setFieldOld(protagonist)
scriptEditUseCase.replaceScript(fieldOld,protagonist) scriptEditUseCase.replaceScript(fieldOld,value)
setProtagonistWrapper(value); setProtagonistWrapper(value);
} else if (type === 'incitingIncident') { } else if (type === 'incitingIncident') {
setFieldOld(incitingIncident) setFieldOld(incitingIncident)
scriptEditUseCase.replaceScript(fieldOld,incitingIncident) scriptEditUseCase.replaceScript(fieldOld,value)
setIncitingIncidentWrapper(value); setIncitingIncidentWrapper(value);
} else if (type === 'problem') { } else if (type === 'problem') {
setFieldOld(problem) setFieldOld(problem)
scriptEditUseCase.replaceScript(fieldOld,problem) scriptEditUseCase.replaceScript(fieldOld,value)
setProblemWrapper(value); setProblemWrapper(value);
} else if (type === 'conflict') { } else if (type === 'conflict') {
setFieldOld(conflict) setFieldOld(conflict)
scriptEditUseCase.replaceScript(fieldOld,conflict) scriptEditUseCase.replaceScript(fieldOld,value)
setConflictWrapper(value); setConflictWrapper(value);
} else if (type === 'stakes') { } else if (type === 'stakes') {
setFieldOld(stakes) setFieldOld(stakes)
scriptEditUseCase.replaceScript(fieldOld,stakes) scriptEditUseCase.replaceScript(fieldOld,value)
setStakesWrapper(value); setStakesWrapper(value);
} else if (type === 'characterArc') { } else if (type === 'characterArc') {
setFieldOld(characterArc) setFieldOld(characterArc)
scriptEditUseCase.replaceScript(fieldOld,characterArc) scriptEditUseCase.replaceScript(fieldOld,value)
setCharacterArcWrapper(value); setCharacterArcWrapper(value);
} }
callback(fieldOld)
}, },
[categories, characterArc, conflict, fieldOld, incitingIncident, problem, protagonist, scriptEditUseCase, setCategoriesWrapper, setCharacterArcWrapper, setConflictWrapper, setIncitingIncidentWrapper, setProblemWrapper, setProtagonistWrapper, setStakesWrapper, setSynopsisWrapper, stakes, synopsis] [categories, characterArc, conflict, fieldOld, incitingIncident, problem, protagonist, scriptEditUseCase, setCategoriesWrapper, setCharacterArcWrapper, setConflictWrapper, setIncitingIncidentWrapper, setProblemWrapper, setProtagonistWrapper, setStakesWrapper, setSynopsisWrapper, stakes, synopsis]
); );

View File

@ -45,7 +45,8 @@ export default function WorkFlow() {
isPauseWorkFlow, isPauseWorkFlow,
mode, mode,
setIsPauseWorkFlow, setIsPauseWorkFlow,
setAnyAttribute setAnyAttribute,
applyScript
} = useWorkflowData(); } = useWorkflowData();
const { const {
@ -193,6 +194,8 @@ export default function WorkFlow() {
setIsPauseWorkFlow={setIsPauseWorkFlow} setIsPauseWorkFlow={setIsPauseWorkFlow}
setAnyAttribute={setAnyAttribute} setAnyAttribute={setAnyAttribute}
isPauseWorkFlow={isPauseWorkFlow} isPauseWorkFlow={isPauseWorkFlow}
applyScript={applyScript}
mode={mode}
/> />
</ErrorBoundary> </ErrorBoundary>
</div> </div>

View File

@ -26,8 +26,10 @@ interface MediaViewerProps {
onTogglePlay: () => void; onTogglePlay: () => void;
final?: any; final?: any;
setIsPauseWorkFlow: (isPause: boolean) => void; setIsPauseWorkFlow: (isPause: boolean) => void;
setAnyAttribute: (type: string, value: SetStateAction<string>, tags?: string[]) => void; setAnyAttribute: any;
isPauseWorkFlow: boolean; isPauseWorkFlow: boolean;
applyScript: any;
mode: string;
} }
export function MediaViewer({ export function MediaViewer({
@ -48,7 +50,9 @@ export function MediaViewer({
final, final,
setIsPauseWorkFlow, setIsPauseWorkFlow,
setAnyAttribute, setAnyAttribute,
isPauseWorkFlow isPauseWorkFlow,
applyScript,
mode
}: MediaViewerProps) { }: MediaViewerProps) {
const mainVideoRef = useRef<HTMLVideoElement>(null); const mainVideoRef = useRef<HTMLVideoElement>(null);
const finalVideoRef = useRef<HTMLVideoElement>(null); const finalVideoRef = useRef<HTMLVideoElement>(null);
@ -812,7 +816,14 @@ export function MediaViewer({
<div className="relative w-full h-full bg-white/10 rounded-lg overflow-hidden p-2"> <div className="relative w-full h-full bg-white/10 rounded-lg overflow-hidden p-2">
{ {
scriptData ? ( scriptData ? (
<ScriptRenderer data={scriptData} setIsPauseWorkFlow={setIsPauseWorkFlow} setAnyAttribute={setAnyAttribute} isPauseWorkFlow={isPauseWorkFlow} /> <ScriptRenderer
data={scriptData}
setIsPauseWorkFlow={setIsPauseWorkFlow}
setAnyAttribute={setAnyAttribute}
isPauseWorkFlow={isPauseWorkFlow}
applyScript={applyScript}
mode={mode}
/>
) : ( ) : (
<div className="flex gap-2 w-full h-full"> <div className="flex gap-2 w-full h-full">
<div className="w-[70%] h-full rounded-lg gap-2 flex flex-col"> <div className="w-[70%] h-full rounded-lg gap-2 flex flex-col">

View File

@ -94,7 +94,11 @@ export function useWorkflowData() {
// 初始化剧本 // 初始化剧本
useEffect(() => { useEffect(() => {
console.log('开始初始化剧本', originalText); console.log('开始初始化剧本', originalText);
originalText && initializeFromProject(episodeId, originalText); originalText && initializeFromProject(episodeId, originalText).then(() => {
console.log('应用剧本');
// 默认模式下 应用剧本
mode.includes('auto') && applyScript();
});
}, [originalText]); }, [originalText]);
// 监听剧本加载完毕 // 监听剧本加载完毕
useEffect(() => { useEffect(() => {
@ -106,13 +110,8 @@ export function useWorkflowData() {
}, [scriptBlocksMemo]); }, [scriptBlocksMemo]);
// 监听继续 请求更新数据 // 监听继续 请求更新数据
useEffect(() => { useEffect(() => {
// 应用剧本 自动模式 默认应用剧本
console.log('isPauseWorkFlow', isPauseWorkFlow, currentStep, scriptBlocksMemo.length, mode); }, [isPauseWorkFlow]);
if (!isPauseWorkFlow && currentStep === '0' && scriptBlocksMemo.length > 0 && mode.includes('auto')) {
console.log('应用剧本');
applyScript();
}
}, [isPauseWorkFlow, scriptBlocksMemo]);
// 自动开始播放一轮 // 自动开始播放一轮
const autoPlaySketch = useCallback(() => { const autoPlaySketch = useCallback(() => {
@ -615,6 +614,7 @@ export function useWorkflowData() {
isPauseWorkFlow, isPauseWorkFlow,
mode, mode,
setIsPauseWorkFlow, setIsPauseWorkFlow,
setAnyAttribute setAnyAttribute,
applyScript
}; };
} }

View File

@ -10,11 +10,13 @@ import { TypewriterText } from '@/components/workflow/work-office/common/Typewri
interface ScriptRendererProps { interface ScriptRendererProps {
data: any[]; data: any[];
setIsPauseWorkFlow: (isPause: boolean) => void; setIsPauseWorkFlow: (isPause: boolean) => void;
setAnyAttribute: (type: string, value: SetStateAction<string>, tags?: string[]) => void; setAnyAttribute: any;
isPauseWorkFlow: boolean; isPauseWorkFlow: boolean;
applyScript: any;
mode: string;
} }
export const ScriptRenderer: React.FC<ScriptRendererProps> = ({ data, setIsPauseWorkFlow, setAnyAttribute, isPauseWorkFlow }) => { export const ScriptRenderer: React.FC<ScriptRendererProps> = ({ data, setIsPauseWorkFlow, setAnyAttribute, isPauseWorkFlow, applyScript, mode }) => {
const [activeBlockId, setActiveBlockId] = useState<string | null>(null); const [activeBlockId, setActiveBlockId] = useState<string | null>(null);
const [hoveredBlockId, setHoveredBlockId] = useState<string | null>(null); const [hoveredBlockId, setHoveredBlockId] = useState<string | null>(null);
const contentRefs = useRef<{ [key: string]: HTMLDivElement | null }>({}); const contentRefs = useRef<{ [key: string]: HTMLDivElement | null }>({});
@ -111,7 +113,12 @@ export const ScriptRenderer: React.FC<ScriptRendererProps> = ({ data, setIsPause
if (contentEditableRef.current) { if (contentEditableRef.current) {
const text = contentEditableRef.current.innerText; const text = contentEditableRef.current.innerText;
console.log('contentEditableRef---text', text); console.log('contentEditableRef---text', text);
setAnyAttribute(block.id, text); setAnyAttribute(block.id, text,(old: string)=>{
if(old!==text){
mode.includes('auto') && applyScript();
setIsPauseWorkFlow(false);
}
});
} }
}; };
@ -127,7 +134,12 @@ export const ScriptRenderer: React.FC<ScriptRendererProps> = ({ data, setIsPause
} }
setIsPauseWorkFlow(true); setIsPauseWorkFlow(true);
setAddThemeTag(value); setAddThemeTag(value);
setAnyAttribute('categories', '', value); setAnyAttribute('categories', value.join(','),(old: string)=>{
if(old!==value.join(',')){
mode.includes('auto') && applyScript();
setIsPauseWorkFlow(false);
}
});
}; };
const handleEditBlock = (block: ScriptBlock) => { const handleEditBlock = (block: ScriptBlock) => {

View File

@ -24,7 +24,7 @@ interface EditModalProps {
roles?: any[]; roles?: any[];
music?: any; music?: any;
setIsPauseWorkFlow: (isPauseWorkFlow: boolean) => void; setIsPauseWorkFlow: (isPauseWorkFlow: boolean) => void;
setAnyAttribute: (type: string, value: SetStateAction<string>, tags?: string[]) => void; setAnyAttribute: any;
isPauseWorkFlow: boolean; isPauseWorkFlow: boolean;
scriptData: any[] | null; scriptData: any[] | null;
} }

View File

@ -7,7 +7,7 @@ import { ScriptRenderer } from '@/components/script-renderer/ScriptRenderer';
interface ScriptTabContentProps { interface ScriptTabContentProps {
scriptData: any[] | null; scriptData: any[] | null;
setIsPauseWorkFlow: (isPauseWorkFlow: boolean) => void; setIsPauseWorkFlow: (isPauseWorkFlow: boolean) => void;
setAnyAttribute: (type: string, value: SetStateAction<string>, tags?: string[]) => void; setAnyAttribute: any;
isPauseWorkFlow: boolean; isPauseWorkFlow: boolean;
} }