diff --git a/app/service/Interaction/ShotService.ts b/app/service/Interaction/ShotService.ts index d537b1c..5b80d8e 100644 --- a/app/service/Interaction/ShotService.ts +++ b/app/service/Interaction/ShotService.ts @@ -309,7 +309,7 @@ export const useShotService = (): UseShotService => { */ const filterRole = useCallback(async ( video: HTMLVideoElement, - ): Promise => { + ) => { try { // 创建canvas元素来截取视频帧 const canvas = document.createElement('canvas'); @@ -356,12 +356,11 @@ export const useShotService = (): UseShotService => { imageUrl ); console.log('角色识别结果:', recognitionResult); + return recognitionResult; } catch (recognitionError) { console.warn('角色识别失败,但图片上传成功:', recognitionError); } } - - return imageUrl; } catch (error) { console.error('获取视频帧失败:', error); throw error; diff --git a/app/service/usecase/ShotEditUsecase.ts b/app/service/usecase/ShotEditUsecase.ts index a2c0b74..ba4a7eb 100644 --- a/app/service/usecase/ShotEditUsecase.ts +++ b/app/service/usecase/ShotEditUsecase.ts @@ -439,7 +439,7 @@ export interface RoleRecognitionResponse { characters_used: CharacterUsed[]; } -const roleRecognitionResponse:RoleRecognitionResponse = { +export const roleRecognitionResponse:RoleRecognitionResponse = { "project_id": "d0df7120-e27b-4f84-875c-e532f1bd318c", "video_id": "984f3347-c81c-4af8-9145-49ead82becde", "target_image_url": "https://cdn.qikongjian.com/videos/1754970412744_kqxplx.png", diff --git a/components/pages/work-flow/use-edit-data.tsx b/components/pages/work-flow/use-edit-data.tsx index d199032..99c80fb 100644 --- a/components/pages/work-flow/use-edit-data.tsx +++ b/components/pages/work-flow/use-edit-data.tsx @@ -44,7 +44,8 @@ export const useEditData = (tabType: string) => { fetchUserRoleLibrary, optimizeRoleText, updateRoleText, - regenerateRole + regenerateRole, + uploadImageToQiniu } = useRoleServiceHook(); const { @@ -105,6 +106,7 @@ export const useEditData = (tabType: string) => { updateRoleText, regenerateRole, fetchUserRoleLibrary, + uploadImageToQiniu, // role shot shotSelectionList, selectedRoleId, diff --git a/components/ui/character-tab-content.tsx b/components/ui/character-tab-content.tsx index 73911f0..4560aa8 100644 --- a/components/ui/character-tab-content.tsx +++ b/components/ui/character-tab-content.tsx @@ -1,6 +1,6 @@ import React, { useState, useRef, useEffect } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; -import { ImageUp, Library, Play, Pause, RefreshCw, Wand2, Users, Check, ReplaceAll, X, TriangleAlert } from 'lucide-react'; +import { ImageUp, Library, Play, Pause, RefreshCw, Wand2, Users, Check, ReplaceAll, X, TriangleAlert, Loader2 } from 'lucide-react'; import { cn } from '@/public/lib/utils'; import { CharacterEditor } from './character-editor'; import ImageBlurTransition from './ImageBlurTransition'; @@ -78,6 +78,7 @@ export function CharacterTabContent({ const [isRegenerate, setIsRegenerate] = useState(false); const [isLoadingShots, setIsLoadingShots] = useState(false); const [isLoadingLibrary, setIsLoadingLibrary] = useState(false); + const [isUploading, setIsUploading] = useState(false); const { loading, @@ -89,6 +90,7 @@ export function CharacterTabContent({ updateRoleText, regenerateRole, fetchUserRoleLibrary, + uploadImageToQiniu, // role shot shotSelectionList, fetchRoleShots, @@ -212,6 +214,7 @@ export function CharacterTabContent({ }; const handleUploadClick = () => { + setIsUploading(true); fileInputRef.current?.click(); }; @@ -225,13 +228,12 @@ export function CharacterTabContent({ return; } - // 创建本地预览URL - const imageUrl = URL.createObjectURL(file); - setShowAddToLibrary(false); - handleReplaceCharacter(imageUrl); - - // 清空input的值,这样同一个文件可以重复选择 - event.target.value = ''; + uploadImageToQiniu(file).then((data) => { + console.log('上传图片成功', data); + // 清空input的值,这样同一个文件可以重复选择 + event.target.value = ''; + setIsUploading(false); + }); }; // 如果loading 显示loading状态 @@ -329,8 +331,9 @@ export function CharacterTabContent({ whileHover={{ scale: 1.05 }} whileTap={{ scale: 0.95 }} onClick={handleUploadClick} + disabled={isUploading} > - + {isUploading ? : }