forked from 77media/video-flow
修复问题
This commit is contained in:
parent
f7b1c62df3
commit
4b37d20df9
@ -517,24 +517,6 @@ export const regenerateShot = async (request: {
|
||||
return post<ApiResponse<any>>("/movie/regenerate_shot", request);
|
||||
};
|
||||
|
||||
/**
|
||||
* 修改分镜对话内容
|
||||
* @param request - 修改分镜对话内容请求参数
|
||||
* @returns Promise<ApiResponse<修改后的分镜>>
|
||||
*/
|
||||
export const updateShotContent = async (request: {
|
||||
/** 分镜ID */
|
||||
shotId: string;
|
||||
/** 新的对话内容,ContentItem数量和ID顺序不能变,只能修改content字段 */
|
||||
content: Array<{
|
||||
/** 角色ID */
|
||||
roleId: string;
|
||||
/** 对话内容 */
|
||||
content: string;
|
||||
}>;
|
||||
}): Promise<ApiResponse<VideoSegmentEntity>> => {
|
||||
return post<ApiResponse<any>>("/movie/update_shot_content", request);
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取分镜列表
|
||||
|
||||
@ -34,11 +34,6 @@ export interface UseShotService {
|
||||
userRequirement: string,
|
||||
lensData: LensType[]
|
||||
) => Promise<LensType[]>;
|
||||
/** 更新视频内容 */
|
||||
updateVideoContent: (
|
||||
shotId: string,
|
||||
content: Array<{ roleId: string; content: string }>
|
||||
) => Promise<VideoSegmentEntity>;
|
||||
/** 中断当前操作 */
|
||||
abortOperation: () => void;
|
||||
/** 设置选中的视频片段 */
|
||||
@ -176,47 +171,6 @@ export const useShotService = (): UseShotService => {
|
||||
},
|
||||
[shotEditUseCase]
|
||||
);
|
||||
|
||||
/**
|
||||
* 更新视频内容
|
||||
* @param shotId 视频片段ID
|
||||
* @param content 新的对话内容
|
||||
* @returns Promise<VideoSegmentEntity> 更新后的视频片段
|
||||
*/
|
||||
const updateVideoContent = useCallback(
|
||||
async (
|
||||
shotId: string,
|
||||
content: Array<{ roleId: string; content: string }>
|
||||
): Promise<VideoSegmentEntity> => {
|
||||
try {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
|
||||
const updatedSegment = await shotEditUseCase.updateVideoContent(
|
||||
shotId,
|
||||
content
|
||||
);
|
||||
|
||||
// 更新列表中的对应项
|
||||
setVideoSegments(prev =>
|
||||
prev.map(segment =>
|
||||
segment.id === shotId ? updatedSegment : segment
|
||||
)
|
||||
);
|
||||
|
||||
return updatedSegment;
|
||||
} catch (error) {
|
||||
const errorMessage = error instanceof Error ? error.message : "更新视频内容失败";
|
||||
setError(errorMessage);
|
||||
console.error("更新视频内容失败:", error);
|
||||
throw error;
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
},
|
||||
[shotEditUseCase]
|
||||
);
|
||||
|
||||
/**
|
||||
* 中断当前操作
|
||||
*/
|
||||
@ -249,77 +203,8 @@ export const useShotService = (): UseShotService => {
|
||||
getVideoSegmentList,
|
||||
regenerateVideoSegment,
|
||||
optimizeVideoContent,
|
||||
updateVideoContent,
|
||||
abortOperation,
|
||||
setSelectedSegment: setSelectedSegmentHandler,
|
||||
clearError,
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* 使用示例:
|
||||
*
|
||||
* ```tsx
|
||||
* import { useShotService } from '@/app/service/Interaction/ShotService';
|
||||
*
|
||||
* const VideoSegmentComponent = () => {
|
||||
* const {
|
||||
* loading,
|
||||
* videoSegments,
|
||||
* selectedSegment,
|
||||
* error,
|
||||
* getVideoSegmentList,
|
||||
* regenerateVideoSegment,
|
||||
* optimizeVideoContent,
|
||||
* updateVideoContent,
|
||||
* setSelectedSegment,
|
||||
* clearError
|
||||
* } = useShotService();
|
||||
*
|
||||
* // 获取视频片段列表
|
||||
* useEffect(() => {
|
||||
* getVideoSegmentList('project-id');
|
||||
* }, [getVideoSegmentList]);
|
||||
*
|
||||
* // 重新生成视频片段
|
||||
* const handleRegenerate = async () => {
|
||||
* try {
|
||||
* await regenerateVideoSegment([
|
||||
* new LensType('特写', '镜头描述', '运镜')
|
||||
* ]);
|
||||
* } catch (error) {
|
||||
* console.error('重新生成失败:', error);
|
||||
* }
|
||||
* };
|
||||
*
|
||||
* // AI优化镜头数据
|
||||
* const handleOptimize = async () => {
|
||||
* try {
|
||||
* const optimizedLensData = await optimizeVideoContent(
|
||||
* 'shot-id',
|
||||
* '让镜头更加动态',
|
||||
* [new LensType('特写', '当前镜头描述', '运镜')]
|
||||
* );
|
||||
*
|
||||
* // 处理优化后的镜头数据
|
||||
* console.log('优化后的镜头数据:', optimizedLensData);
|
||||
* } catch (error) {
|
||||
* console.error('优化失败:', error);
|
||||
* }
|
||||
* };
|
||||
*
|
||||
* return (
|
||||
* <div>
|
||||
* {loading && <div>加载中...</div>}
|
||||
* {error && <div>错误: {error}</div>}
|
||||
* {videoSegments.map(segment => (
|
||||
* <div key={segment.id}>
|
||||
* <h3>{segment.name}</h3>
|
||||
* <p>状态: {segment.status}</p>
|
||||
* </div>
|
||||
* ))}
|
||||
* </div>
|
||||
* );
|
||||
* };
|
||||
* ```
|
||||
*/
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
import { VideoSegmentEntity } from "../domain/Entities";
|
||||
import { ContentItem, LensType } from "../domain/valueObject";
|
||||
import { LensType } from "../domain/valueObject";
|
||||
import {
|
||||
getShotList,
|
||||
regenerateShot,
|
||||
updateShotContent,
|
||||
optimizeShotContent,
|
||||
} from "@/api/video_flow";
|
||||
|
||||
@ -118,41 +117,6 @@ export class VideoSegmentEditUseCase {
|
||||
this.loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 更新视频片段的对话内容
|
||||
* @param shotId 视频片段ID
|
||||
* @param content 新的对话内容
|
||||
* @returns Promise<VideoSegmentEntity> 更新后的视频片段
|
||||
*/
|
||||
async updateVideoContent(
|
||||
shotId: string,
|
||||
content: Array<{
|
||||
roleId: string;
|
||||
content: string;
|
||||
}>
|
||||
): Promise<VideoSegmentEntity> {
|
||||
try {
|
||||
this.loading = true;
|
||||
|
||||
const response = await updateShotContent({
|
||||
shotId,
|
||||
content,
|
||||
});
|
||||
|
||||
if (!response.successful) {
|
||||
throw new Error(response.message || "更新视频内容失败");
|
||||
}
|
||||
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error("更新视频内容失败:", error);
|
||||
throw error;
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 中断当前操作
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user