diff --git a/components/pages/work-flow/use-workflow-data.tsx b/components/pages/work-flow/use-workflow-data.tsx index 7ae30c0..b3e8f44 100644 --- a/components/pages/work-flow/use-workflow-data.tsx +++ b/components/pages/work-flow/use-workflow-data.tsx @@ -103,15 +103,13 @@ export function useWorkflowData() { } = useScriptService(); // 初始化剧本 useUpdateEffect(() => { - if (currentStep !== '0') { - console.log('开始初始化剧本', originalText,episodeId); - // TODO 为什么一开始没项目id - originalText && initializeFromProject(episodeId, originalText).then(() => { - console.log('应用剧本'); - // 自动模式下 应用剧本;手动模式 需要点击 下一步 触发 - mode.includes('auto') && applyScript(); - }); - } + console.log('开始初始化剧本', originalText,episodeId); + // TODO 为什么一开始没项目id + originalText && initializeFromProject(episodeId, originalText).then(() => { + console.log('应用剧本'); + // 自动模式下 应用剧本;手动模式 需要点击 下一步 触发 + mode.includes('auto') && applyScript(); + }); }, [originalText], {mode: 'none'}); // 监听剧本加载完毕 useEffect(() => { diff --git a/components/ui/edit-modal.tsx b/components/ui/edit-modal.tsx index 5399d94..47c573b 100644 --- a/components/ui/edit-modal.tsx +++ b/components/ui/edit-modal.tsx @@ -101,7 +101,7 @@ const [pendingSwitchTabId, setPendingSwitchTabId] = useState(null if (activeTab === '0') { const scriptTabContent = scriptTabContentRef.current; if (scriptTabContent) { - return scriptTabContent.checkUpdate(); + return scriptTabContent.switchBefore(tabId); } } else if (activeTab === '1') { const characterTabContent = characterTabContentRef.current; @@ -183,6 +183,8 @@ const [pendingSwitchTabId, setPendingSwitchTabId] = useState(null setIsPauseWorkFlow={setIsPauseWorkFlow} isPauseWorkFlow={isPauseWorkFlow} originalText={originalText} + onApply={handleApply} + setActiveTab={setActiveTab} /> ); case '1': diff --git a/components/ui/person-detection.tsx b/components/ui/person-detection.tsx index b2dcc04..952d41d 100644 --- a/components/ui/person-detection.tsx +++ b/components/ui/person-detection.tsx @@ -41,6 +41,7 @@ export type PersonDetection = { }; type Props = { + scanState: 'idle' | 'scanning' | 'detected' | 'failed' | 'timeout'; backgroundImage?: string; videoSrc?: string; detections: PersonDetection[]; @@ -56,6 +57,7 @@ type Props = { }; export const PersonDetectionScene: React.FC = ({ + scanState, backgroundImage, videoSrc, detections, @@ -201,210 +203,214 @@ export const PersonDetectionScene: React.FC = ({ /> )} - {/* 暗化层 */} - - {isShowScan && ( - - )} - + {scanState !== 'idle' && ( + <> + {/* 暗化层 */} + + {isShowScan && ( + + )} + - {/* 扫描状态提示 */} - - {isShowScan && ( - - {/* 状态图标 */} -
- {!isShowError ? ( - <> - - -
- - ) : ( + {/* 扫描状态提示 */} + + {isShowScan && ( + + {/* 状态图标 */} +
+ {!isShowError ? ( + <> + + +
+ + ) : ( + + + + )} +
+ + {/* 状态文字 */} - +
+ {!isShowError ? ( + + Intelligenting portrait recognition + + ) : ( + + {scanStatus === 'timeout' ? 'Timeout, please try again' : 'Failed, please try again'} + + )} +
- )} -
+
+ )} +
- {/* 状态文字 */} - -
- {!isShowError ? ( - - Intelligenting portrait recognition - - ) : ( - - {scanStatus === 'timeout' ? 'Timeout, please try again' : 'Failed, please try again'} - - )} -
-
- - )} - - - {/* 扫描动画效果 */} - - {isShowScan && ( - - {/* 主扫描线 */} - - {/* 扫描线中心光束 */} + {/* 扫描动画效果 */} + + {isShowScan && scanState === 'scanning' && ( - - - {/* 扫描网格 */} -
- - -
- - {/* 四角扫描框 */} -
- - {/* 左上角 */} -
- {/* 右上角 */} -
- {/* 左下角 */} -
- {/* 右下角 */} -
- -
- - )} - + {/* 主扫描线 */} + + {/* 扫描线中心光束 */} + + - {/* 人物识别框和浮签 */} - - {detections.length === 0 && triggerSuccess && ( -
- No portrait detected -
- )} - {detections.map((person, index) => { - return ( -
{ - onPersonClick?.(person); - }}> - - - {person.name} + {/* 扫描网格 */} +
+ + +
+ + {/* 四角扫描框 */} +
+ + {/* 左上角 */} +
+ {/* 右上角 */} +
+ {/* 左下角 */} +
+ {/* 右下角 */} +
+ +
-
- ); - })} - + )} + + + {/* 人物识别框和浮签 */} + + {detections.length === 0 && triggerSuccess && ( +
+ No portrait detected +
+ )} + {detections.map((person, index) => { + return ( +
{ + onPersonClick?.(person); + }}> + + + {person.name} + +
+ ); + })} +
+ + )}
); }; diff --git a/components/ui/script-tab-content.tsx b/components/ui/script-tab-content.tsx index 5a1abf9..6b8b86f 100644 --- a/components/ui/script-tab-content.tsx +++ b/components/ui/script-tab-content.tsx @@ -1,24 +1,29 @@ import React, { useState, useCallback, useEffect, SetStateAction, forwardRef } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; -import { FileText } from 'lucide-react'; +import { FileText, Undo2, X, TriangleAlert } from 'lucide-react'; import { ScriptRenderer } from '@/components/script-renderer/ScriptRenderer'; import { useEditData } from '@/components/pages/work-flow/use-edit-data'; +import FloatingGlassPanel from './FloatingGlassPanel'; interface ScriptTabContentProps { setIsPauseWorkFlow: (isPauseWorkFlow: boolean) => void; isPauseWorkFlow: boolean; originalText?: string; + onApply: () => void; + setActiveTab: (tabId: string) => void; } export const ScriptTabContent = forwardRef< - { checkUpdate: () => boolean }, + { switchBefore: (tabId: string) => boolean }, ScriptTabContentProps >((props, ref) => { - const { setIsPauseWorkFlow, isPauseWorkFlow, originalText } = props; + const { setIsPauseWorkFlow, isPauseWorkFlow, originalText, onApply, setActiveTab } = props; const { loading, scriptData, setAnyAttribute, applyScript } = useEditData('script', originalText); const [isUpdate, setIsUpdate] = useState(false); + const [isRemindApplyUpdate, setIsRemindApplyUpdate] = useState(false); + const [nextToTabId, setNextToTabId] = useState(''); useEffect(() => { console.log('contentEditableRef---scriptTabContentIsChange', isUpdate); @@ -26,9 +31,24 @@ export const ScriptTabContent = forwardRef< // 暴露方法给父组件 React.useImperativeHandle(ref, () => ({ - checkUpdate: () => isUpdate + switchBefore: (tabId: string) => { + setNextToTabId(tabId); + console.log('switchBefore', isUpdate); + if (isUpdate) { + setIsRemindApplyUpdate(true); + } + return isUpdate; + }, })); + const handleApply = () => { + onApply(); + } + const handleCancel = () => { + setIsRemindApplyUpdate(false); + setActiveTab(nextToTabId); + } + // 如果loading 显示loading状态 if (loading) { return ( @@ -66,6 +86,39 @@ export const ScriptTabContent = forwardRef< setIsUpdate={setIsUpdate} /> + + +
+
+ +

剧本内容已修改,是否需要应用?

+
+ +
+ + + +
+
+
); }); diff --git a/components/ui/shot-tab-content.tsx b/components/ui/shot-tab-content.tsx index 9187510..07b010a 100644 --- a/components/ui/shot-tab-content.tsx +++ b/components/ui/shot-tab-content.tsx @@ -329,6 +329,7 @@ export function ShotTabContent({