修复bug

This commit is contained in:
海龙 2025-08-12 23:21:51 +08:00
parent f147b72db6
commit 5c6b452e59
10 changed files with 29 additions and 32 deletions

View File

@ -484,13 +484,7 @@ export interface CharacterUpdateAndRegenerateResponse {
/** 角色描述(已更新) */
character_description: string;
/** 重新生成产物的图片地址 */
image_path?: string;
/** 角色类型/作用 */
role?: string;
/** 性别 */
gender?: string;
/** 角色简要说明/摘要 */
brief?: string;
image_url?: string;
/** 从角色描述提取的高亮关键词/短语 */
highlights: string[];
}

View File

@ -304,7 +304,7 @@ export const applyRoleToShots = async (request: {
message?: string;
}>;
}>> => {
return post("/movie/apply_role_to_shots", request);
return post("/movie/regenerate_shot_video", request);
};
/**

View File

@ -164,7 +164,7 @@ export const useRoleServiceHook = (): UseRoleService => {
console.error('优化角色文本失败:', error);
throw error;
}
}, [roleEditUseCase, currentRoleText, selectedRole]);
}, [roleEditUseCase, currentRoleText, selectedRole, selectRole]);
/**
* AI文本
@ -408,7 +408,7 @@ export const useRoleServiceHook = (): UseRoleService => {
const result = await roleEditUseCase.saveRegeneratedCharacterToLibrary(
selectedRole,
projectId,
User.id
String(User.id)
);
console.log('角色保存到角色库成功:', result);

View File

@ -149,12 +149,6 @@ export const useRoleShotServiceHook = (projectId: string,selectRole?:RoleEntity)
*/
const applyRoleToSelectedShots = useCallback(async (newRole: RoleEntity) => {
try {
// 检查是否有选中的分镜
const selectedShots = shotSelectionList.filter(shot => shot.selected);
if (selectedShots.length === 0) {
throw new Error('请先选择要应用角色的分镜');
}
// 检查是否有选中的角色
if (!selectedRole||!selectedRole.generateText ) {
throw new Error('请先选择要应用的角色');
@ -179,7 +173,7 @@ export const useRoleShotServiceHook = (projectId: string,selectRole?:RoleEntity)
];
// 循环调用接口,为每个选中的分镜单独调用
selectedShots.forEach(async (shot) => {
shotSelectionList.forEach(async (shot) => {
try {
// 调用应用角色到分镜接口(不等待完成)
applyRoleToShots({
@ -201,7 +195,7 @@ export const useRoleShotServiceHook = (projectId: string,selectRole?:RoleEntity)
}
});
console.log(`开始为 ${selectedShots.length} 个分镜替换角色`);
console.log(`开始为 ${shotSelectionList.length} 个分镜替换角色`);
// 延迟重置替换状态,给用户一些反馈时间
setTimeout(() => {

View File

@ -76,7 +76,7 @@ export const useShotService = (): UseShotService => {
const segments = await vidoEditUseCase.getVideoSegmentList(projectId);
setProjectId(projectId);
setVideoSegments(segments);
setIntervalIdHandler();
setIntervalIdHandler(projectId);
} catch (error) {
console.error("获取视频片段列表失败:", error);
} finally {
@ -86,7 +86,8 @@ export const useShotService = (): UseShotService => {
[vidoEditUseCase]
);
const setIntervalIdHandler = async (): Promise<void> => {
const setIntervalIdHandler = async (projectId: string): Promise<void> => {
// 每次执行前先清除之前的定时器,确保只存在一个定时器
if (intervalId) {
clearInterval(intervalId);
@ -95,9 +96,6 @@ export const useShotService = (): UseShotService => {
// 定义定时任务每5秒执行一次
const newIntervalId = setInterval(async () => {
try {
if (!projectId) {
return;
}
const segments = await vidoEditUseCase.getVideoSegmentList(projectId);
setVideoSegments(prevSegments => {

View File

@ -240,12 +240,11 @@ export class RoleEditUseCase {
loadingProgress: 100,
disableEdit: false
})), // 将高亮关键词转换为TagValueObject格式
imageUrl: characterData.image_path || '',
imageUrl: characterData.image_url || '',
loadingProgress: 100,
disableEdit: false,
updatedAt: Date.now()
};
return roleEntity;
} catch (error) {
console.error('AI生成角色失败:', error);

View File

@ -148,6 +148,7 @@ export function MediaViewer({
// 包装编辑按钮点击事件
const handleEditClick = (tab: string) => {
// TODO 点击没有任何事件效果,页面没变化
setUserHasInteracted(true);
onEditModalOpen(tab);
};

View File

@ -45,8 +45,9 @@ export const useEditData = (tabType: string) => {
optimizeRoleText,
updateRoleText,
regenerateRole,
uploadImageToQiniu,
saveRoleToLibrary
uploadImageAndUpdateRole,
saveRoleToLibrary,
} = useRoleServiceHook();
const {
@ -58,9 +59,18 @@ export const useEditData = (tabType: string) => {
toggleSelectAllShots,
toggleShotSelection,
applyRoleToSelectedShots,
clearShotSelection
clearShotSelection,
setSelectedRole
} = useRoleShotServiceHook(projectId, selectedRole || undefined);
useEffect(() => {
console.log('useEditData-----selectedRole', selectedRole);
if(selectedRole){
setSelectedRole(selectedRole);
}
}, [selectedRole]);
useEffect(() => {
if (tabType === 'shot') {
getVideoSegmentList(projectId).then(() => {
@ -107,7 +117,7 @@ export const useEditData = (tabType: string) => {
updateRoleText,
regenerateRole,
fetchUserRoleLibrary,
uploadImageToQiniu,
uploadImageAndUpdateRole,
// role shot
shotSelectionList,
selectedRoleId,

View File

@ -93,7 +93,8 @@ export function useWorkflowData() {
} = useScriptService();
// 初始化剧本
useEffect(() => {
console.log('开始初始化剧本', originalText);
console.log('开始初始化剧本', originalText,episodeId);
// TODO 为什么一开始没项目id
originalText && initializeFromProject(episodeId, originalText).then(() => {
console.log('应用剧本');
// 自动模式下 应用剧本;手动模式 需要点击 下一步 触发

View File

@ -90,7 +90,7 @@ export function CharacterTabContent({
updateRoleText,
regenerateRole,
fetchUserRoleLibrary,
uploadImageToQiniu,
uploadImageAndUpdateRole,
// role shot
shotSelectionList,
fetchRoleShots,
@ -230,7 +230,7 @@ export function CharacterTabContent({
}
setIsUploading(true);
uploadImageToQiniu(file).then((data) => {
uploadImageAndUpdateRole(file).then((data) => {
console.log('上传图片成功', data);
// 清空input的值这样同一个文件可以重复选择
event.target.value = '';