This commit is contained in:
海龙 2025-08-13 21:26:49 +08:00
commit 43b42e3d09
3 changed files with 18 additions and 19 deletions

View File

@ -145,18 +145,19 @@ export class RoleEditUseCase {
* @throws {Error} * @throws {Error}
*/ */
parseSimilarCharacterList(similarCharacterData: any): RoleEntity[] { parseSimilarCharacterList(similarCharacterData: any): RoleEntity[] {
if (!similarCharacterData || !Array.isArray(similarCharacterData.characters)) { // if (!similarCharacterData || !Array.isArray(similarCharacterData.characters)) {
throw new Error('相似角色数据格式错误'); // throw new Error('相似角色数据格式错误');
} // }
const characters = [...similarCharacterData.similar_characters, ...similarCharacterData.user_characters];
return similarCharacterData.characters.map((char: any, index: number) => { return characters.map((char: any, index: number) => {
/** 角色实体对象 */ /** 角色实体对象 */
const roleEntity: RoleEntity = { const roleEntity: RoleEntity = {
id: char.id || `role_${Date.now()}_${index}`, id: char.id || `role_${Date.now()}_${index}`,
name: char.name || '', name: char.name || '',
generateText: char.description || '', generateText: char.brief || '',
tags: [], // 相似角色接口可能不返回标签,暂时为空 tags: [], // 相似角色接口可能不返回标签,暂时为空
imageUrl: char.image_url || '', imageUrl: char.avatar || '',
loadingProgress: 100, loadingProgress: 100,
disableEdit: false, disableEdit: false,
updatedAt: Date.now(), updatedAt: Date.now(),

View File

@ -111,8 +111,8 @@ export function CharacterTabContent({
}, [roleData, isInitialized]); }, [roleData, isInitialized]);
useEffect(() => { useEffect(() => {
console.log('获取选中项数据', selectedRole); console.log('获取shotSelectionList数据', shotSelectionList);
}, [selectedRole]); }, [shotSelectionList]);
useEffect(() => { useEffect(() => {
console.log('获取角色库数据', userRoleLibrary); console.log('获取角色库数据', userRoleLibrary);
@ -184,8 +184,12 @@ export function CharacterTabContent({
setShowAddToLibrary(false); setShowAddToLibrary(false);
// 使用真实的角色数据 // 使用真实的角色数据
const selectedRole = userRoleLibrary[index]; const role = userRoleLibrary[index];
if (selectedRole) { if (role) {
selectRole({
...role,
name: selectedRole?.name || ''
});
handleStartReplaceCharacter(); handleStartReplaceCharacter();
} }
}; };

View File

@ -158,23 +158,22 @@ export function ReplacePanel({
whileHover={{ scale: 1.02 }} whileHover={{ scale: 1.02 }}
whileTap={{ scale: 0.98 }} whileTap={{ scale: 0.98 }}
> >
{shot.videoUrl && ( {shot.videoUrl && shot.videoUrl.length > 0 && (
<video <video
ref={el => { ref={el => {
if (el) videoRefs.current[shot.id] = el; if (el) videoRefs.current[shot.id] = el;
}} }}
src={shot.videoUrl} src={shot.videoUrl[0]}
className="w-full h-full object-cover" className="w-full h-full object-cover"
loop loop
muted muted
playsInline playsInline
/> />
)} )}
{!shot.videoUrl && ( {(!shot.videoUrl || shot.videoUrl.length === 0) && (
<> <>
<img <img
src={shot.sketchUrl} src={shot.sketchUrl}
alt={`Shot ${shot.id}`}
className="w-full h-full object-cover" className="w-full h-full object-cover"
/> />
<div className="absolute inset-0 bg-black/50 flex items-center justify-center"> <div className="absolute inset-0 bg-black/50 flex items-center justify-center">
@ -182,11 +181,6 @@ export function ReplacePanel({
</div> </div>
</> </>
)} )}
{selectedShots.includes(shot.id) && (
<div className="absolute top-2 right-2">
<Check className="w-4 h-4 text-blue-500" />
</div>
)}
</motion.div> </motion.div>
))} ))}
</div> </div>