From ebb9a951bdab6d3fa369655e62ab1ad7d2343489 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8C=97=E6=9E=B3?= <7854742+wang_rumeng@user.noreply.gitee.com> Date: Tue, 12 Aug 2025 17:47:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=A7=92=E8=89=B2=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E6=95=B0=E6=8D=AE=E9=80=BB=E8=BE=91=EF=BC=8C=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E4=B8=8A=E4=BC=A0=E5=9B=BE=E7=89=87=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=B9=B6=E5=A4=84=E7=90=86=E5=8A=A0=E8=BD=BD=E7=8A=B6=E6=80=81?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96=E8=A7=92=E8=89=B2=E5=BA=93=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E7=BB=84=E4=BB=B6=E7=9A=84=E7=94=A8=E6=88=B7=E4=BD=93?= =?UTF-8?q?=E9=AA=8C=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/pages/work-flow/use-edit-data.tsx | 4 +++- components/ui/character-tab-content.tsx | 19 ++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) 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..cc115c8 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(); }; @@ -227,11 +230,12 @@ export function CharacterTabContent({ // 创建本地预览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状态 @@ -338,8 +342,9 @@ export function CharacterTabContent({ whileHover={{ scale: 1.05 }} whileTap={{ scale: 0.95 }} onClick={() => handleOpenReplaceLibrary()} + disabled={isUploading} > - + {isUploading ? : }