forked from 77media/video-flow
更新角色编辑数据逻辑,新增上传图片功能并处理加载状态,优化角色库选择组件的用户体验。
This commit is contained in:
parent
55a61424e8
commit
ebb9a951bd
@ -44,7 +44,8 @@ export const useEditData = (tabType: string) => {
|
|||||||
fetchUserRoleLibrary,
|
fetchUserRoleLibrary,
|
||||||
optimizeRoleText,
|
optimizeRoleText,
|
||||||
updateRoleText,
|
updateRoleText,
|
||||||
regenerateRole
|
regenerateRole,
|
||||||
|
uploadImageToQiniu
|
||||||
} = useRoleServiceHook();
|
} = useRoleServiceHook();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@ -105,6 +106,7 @@ export const useEditData = (tabType: string) => {
|
|||||||
updateRoleText,
|
updateRoleText,
|
||||||
regenerateRole,
|
regenerateRole,
|
||||||
fetchUserRoleLibrary,
|
fetchUserRoleLibrary,
|
||||||
|
uploadImageToQiniu,
|
||||||
// role shot
|
// role shot
|
||||||
shotSelectionList,
|
shotSelectionList,
|
||||||
selectedRoleId,
|
selectedRoleId,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import React, { useState, useRef, useEffect } from 'react';
|
import React, { useState, useRef, useEffect } from 'react';
|
||||||
import { motion, AnimatePresence } from 'framer-motion';
|
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 { cn } from '@/public/lib/utils';
|
||||||
import { CharacterEditor } from './character-editor';
|
import { CharacterEditor } from './character-editor';
|
||||||
import ImageBlurTransition from './ImageBlurTransition';
|
import ImageBlurTransition from './ImageBlurTransition';
|
||||||
@ -78,6 +78,7 @@ export function CharacterTabContent({
|
|||||||
const [isRegenerate, setIsRegenerate] = useState(false);
|
const [isRegenerate, setIsRegenerate] = useState(false);
|
||||||
const [isLoadingShots, setIsLoadingShots] = useState(false);
|
const [isLoadingShots, setIsLoadingShots] = useState(false);
|
||||||
const [isLoadingLibrary, setIsLoadingLibrary] = useState(false);
|
const [isLoadingLibrary, setIsLoadingLibrary] = useState(false);
|
||||||
|
const [isUploading, setIsUploading] = useState(false);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
loading,
|
loading,
|
||||||
@ -89,6 +90,7 @@ export function CharacterTabContent({
|
|||||||
updateRoleText,
|
updateRoleText,
|
||||||
regenerateRole,
|
regenerateRole,
|
||||||
fetchUserRoleLibrary,
|
fetchUserRoleLibrary,
|
||||||
|
uploadImageToQiniu,
|
||||||
// role shot
|
// role shot
|
||||||
shotSelectionList,
|
shotSelectionList,
|
||||||
fetchRoleShots,
|
fetchRoleShots,
|
||||||
@ -212,6 +214,7 @@ export function CharacterTabContent({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleUploadClick = () => {
|
const handleUploadClick = () => {
|
||||||
|
setIsUploading(true);
|
||||||
fileInputRef.current?.click();
|
fileInputRef.current?.click();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -227,11 +230,12 @@ export function CharacterTabContent({
|
|||||||
|
|
||||||
// 创建本地预览URL
|
// 创建本地预览URL
|
||||||
const imageUrl = URL.createObjectURL(file);
|
const imageUrl = URL.createObjectURL(file);
|
||||||
setShowAddToLibrary(false);
|
uploadImageToQiniu(file).then((data) => {
|
||||||
handleReplaceCharacter(imageUrl);
|
console.log('上传图片成功', data);
|
||||||
|
// 清空input的值,这样同一个文件可以重复选择
|
||||||
// 清空input的值,这样同一个文件可以重复选择
|
event.target.value = '';
|
||||||
event.target.value = '';
|
setIsUploading(false);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 如果loading 显示loading状态
|
// 如果loading 显示loading状态
|
||||||
@ -338,8 +342,9 @@ export function CharacterTabContent({
|
|||||||
whileHover={{ scale: 1.05 }}
|
whileHover={{ scale: 1.05 }}
|
||||||
whileTap={{ scale: 0.95 }}
|
whileTap={{ scale: 0.95 }}
|
||||||
onClick={() => handleOpenReplaceLibrary()}
|
onClick={() => handleOpenReplaceLibrary()}
|
||||||
|
disabled={isUploading}
|
||||||
>
|
>
|
||||||
<Library className="w-4 h-4" />
|
{isUploading ? <Loader2 className="w-4 h-4 animate-spin" /> : <Library className="w-4 h-4" />}
|
||||||
</motion.button>
|
</motion.button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user