新增设置选中的角色功能,优化角色选择逻辑以支持未定义角色的情况,同时更新角色视频片段服务和编辑数据逻辑,确保角色库保存功能的完整性。

This commit is contained in:
海龙 2025-08-12 18:55:56 +08:00
parent b59d32d79d
commit 7112de9ac1
3 changed files with 16 additions and 7 deletions

View File

@ -39,17 +39,19 @@ interface UseRoleShotService {
applyRoleToSelectedShots: (newRole: RoleEntity) => Promise<void>;
/** 清空选择列表 */
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<ExtendedVideoSegmentEntity[]>([]);
const [selectedRoleId, setSelectedRoleId] = useState<string | null>(null);
const [selectedRole, setSelectedRole] = useState<RoleEntity | null>(selectRole);
const [selectedRole, setSelectedRole] = useState<RoleEntity | null>(selectRole || null);
const [isReplacing, setIsReplacing] = useState<boolean>(false); // 全局替换状态
// 计算属性
@ -238,5 +240,6 @@ export const useRoleShotServiceHook = (projectId: string,selectRole:RoleEntity):
toggleShotSelection,
applyRoleToSelectedShots,
clearShotSelection,
setSelectedRole
};
};

View File

@ -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
}
}
}

View File

@ -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();
}
};
// 取消替换