diff --git a/app/service/Interaction/RoleShotService.ts b/app/service/Interaction/RoleShotService.ts index 0a54946..9954297 100644 --- a/app/service/Interaction/RoleShotService.ts +++ b/app/service/Interaction/RoleShotService.ts @@ -39,17 +39,19 @@ interface UseRoleShotService { applyRoleToSelectedShots: (newRole: RoleEntity) => Promise; /** 清空选择列表 */ clearShotSelection: () => void; + /** 设置选中的角色 */ + setSelectedRole: (role: RoleEntity) => void; } /** * 角色视频片段服务Hook * 提供角色与视频片段交互的所有响应式功能和业务逻辑 */ -export const useRoleShotServiceHook = (projectId: string,selectRole:RoleEntity): UseRoleShotService => { +export const useRoleShotServiceHook = (projectId: string,selectRole?:RoleEntity): UseRoleShotService => { // 响应式状态 const [shotSelectionList, setShotSelectionList] = useState([]); const [selectedRoleId, setSelectedRoleId] = useState(null); - const [selectedRole, setSelectedRole] = useState(selectRole); + const [selectedRole, setSelectedRole] = useState(selectRole || null); const [isReplacing, setIsReplacing] = useState(false); // 全局替换状态 // 计算属性 @@ -238,5 +240,6 @@ export const useRoleShotServiceHook = (projectId: string,selectRole:RoleEntity): toggleShotSelection, applyRoleToSelectedShots, clearShotSelection, + setSelectedRole }; }; diff --git a/components/pages/work-flow/use-edit-data.tsx b/components/pages/work-flow/use-edit-data.tsx index 99c80fb..de6452a 100644 --- a/components/pages/work-flow/use-edit-data.tsx +++ b/components/pages/work-flow/use-edit-data.tsx @@ -45,7 +45,8 @@ export const useEditData = (tabType: string) => { optimizeRoleText, updateRoleText, regenerateRole, - uploadImageToQiniu + uploadImageToQiniu, + saveRoleToLibrary } = useRoleServiceHook(); const { @@ -58,7 +59,7 @@ export const useEditData = (tabType: string) => { toggleShotSelection, applyRoleToSelectedShots, clearShotSelection - } = useRoleShotServiceHook(projectId, selectedRole); + } = useRoleShotServiceHook(projectId, selectedRole || undefined); useEffect(() => { if (tabType === 'shot') { @@ -116,6 +117,7 @@ export const useEditData = (tabType: string) => { toggleSelectAllShots, toggleShotSelection, applyRoleToSelectedShots, - clearShotSelection + clearShotSelection, + saveRoleToLibrary } -} \ No newline at end of file +} diff --git a/components/ui/character-tab-content.tsx b/components/ui/character-tab-content.tsx index 4560aa8..e4055f3 100644 --- a/components/ui/character-tab-content.tsx +++ b/components/ui/character-tab-content.tsx @@ -94,7 +94,8 @@ export function CharacterTabContent({ // role shot shotSelectionList, fetchRoleShots, - applyRoleToSelectedShots + applyRoleToSelectedShots, + saveRoleToLibrary } = useEditData('role'); const searchParams = useSearchParams(); const episodeId = searchParams.get('episodeId'); @@ -154,6 +155,9 @@ export function CharacterTabContent({ console.log('Add to library:', addToLibrary); applyRoleToSelectedShots(selectedRole || {} as RoleEntity); setIsReplacePanelOpen(false); + if(addToLibrary){ + saveRoleToLibrary(); + } }; // 取消替换