Self-hosted personal gallery application with online photo management and albums, supporting Live/Motion Photos, EXIF parsing, geolocation recognition, and an explore map.
TypeScript albumsexif-extractiongeocodinglive-photomotion-photophoto-galleryphoto-sharingwebgl-viewer
feat(dashboard): enhance upload functionality with improved status handling and UI components
Timothy Yin2cde8a13c62e
diff --git a/app/components/ui/UploadQueueItem.vue b/app/components/ui/UploadQueueItem.vuenew file mode 100644index 00000000..4a31a8c4--- /dev/null+++ b/app/components/ui/UploadQueueItem.vue@@ -0,0 +1,570 @@+<script lang="ts" setup>+import { motion, AnimatePresence } from 'motion-v'+import { computed, ref, watch, nextTick, onUnmounted } from 'vue'++interface UploadFile {+ file: File+ fileName: string+ fileId: string+ status:+ | 'waiting'+ | 'preparing'+ | 'uploading'+ | 'processing'+ | 'completed'+ | 'error'+ stage?: string | null+ progress?: number+ error?: string+ taskId?: number+ uploadProgress?: {+ loaded: number+ total: number+ percentage: number+ speed?: number+ timeRemaining?: number+ speedText?: string+ timeRemainingText?: string+ }+ canAbort?: boolean+ abortUpload?: () => void+}++const props = defineProps<{+ uploadingFile: UploadFile+ fileId: string+}>()++const emit = defineEmits<{+ removeFile: [fileId: string]+}>()++const fileIcon = computed(() => {+ const file = props.uploadingFile.file+ if (file.type.startsWith('image/')) {+ return 'tabler:photo'+ } else if (file.type.startsWith('video/')) {+ return 'tabler:video'+ }+ return 'tabler:file'+})++const statusColor = computed(() => {+ switch (props.uploadingFile.status) {+ case 'waiting':+ return 'neutral'+ case 'preparing':+ return 'primary'+ case 'uploading':+ return 'primary'+ case 'processing':+ return 'info'+ case 'completed':+ return 'success'+ case 'error':+ return 'error'+ default:+ return 'neutral'+ }+})++const statusText = computed(() => {+ switch (props.uploadingFile.status) {+ case 'waiting':+ return '等待上传'+ case 'preparing':+ return '准备中'+ case 'uploading':+ return `上传中 ${props.uploadingFile.progress || 0}%`+ case 'processing':+ return props.uploadingFile.stage+ ? getStageText(props.uploadingFile.stage)+ : '等待处理'+ case 'completed':+ return '完成'+ case 'error':+ return '错误'+ default:+ return '未知'+ }+})++// 获取处理阶段文本+const getStageText = (stage: string) => {+ const stageMap: Record<string, string> = {+ preprocessing: '预处理中',+ metadata: '提取元数据',+ thumbnail: '生成缩略图',+ exif: '处理 EXIF',+ 'reverse-geocoding': '地理解析',+ 'live-photo': '检测 LivePhoto',+ }+ return stageMap[stage] || stage+}++// 文件大小格式化+const formatBytes = (bytes: number) => {+ if (bytes === 0) return '0 B'+ const k = 1024+ const sizes = ['B', 'KB', 'MB', 'GB']+ const i = Math.floor(Math.log(bytes) / Math.log(k))+ return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + ' ' + sizes[i]+}++// 处理完成粒子动画+const showParticles = ref(false)+const particleCount = 12++// 处理时间警告+const showProcessingWarning = ref(false)+const processingStartTime = ref<number | null>(null)+let processingTimer: NodeJS.Timeout | null = null++watch(+ () => props.uploadingFile.status,+ async (newStatus, oldStatus) => {+ if (newStatus === 'completed' && oldStatus !== 'completed') {+ await nextTick()+ // 延迟触发粒子动画,让完成指示器先显示+ setTimeout(() => {+ showParticles.value = true+ // 2秒后隐藏粒子+ setTimeout(() => {+ showParticles.value = false+ }, 2000)+ }, 300)+ }++ // 处理状态变化时的时间跟踪+ if (newStatus === 'processing' && oldStatus !== 'processing') {+ // 开始处理,记录时间+ processingStartTime.value = Date.now()+ showProcessingWarning.value = false++ // 30秒后显示警告+ processingTimer = setTimeout(() => {+ if (props.uploadingFile.status === 'processing') {+ showProcessingWarning.value = true+ }+ }, 30000)+ } else if (oldStatus === 'processing' && newStatus !== 'processing') {+ // 处理结束,清理定时器和状态+ if (processingTimer) {+ clearTimeout(processingTimer)+ processingTimer = null+ }+ showProcessingWarning.value = false+ processingStartTime.value = null+ }+ },+)++// 组件卸载时清理定时器+onUnmounted(() => {+ if (processingTimer) {+ clearTimeout(processingTimer)+ }+})++const generateParticleStyle = (index: number) => {+ const angle = (360 / particleCount) * index+ const distance = 60 + Math.random() * 40 // 60-100px的随机距离+ const duration = 1.5 + Math.random() * 0.5 // 1.5-2s的随机持续时间++ return {+ '--angle': `${angle}deg`,+ '--distance': `${distance}px`,+ '--duration': `${duration}s`,+ '--delay': `${Math.random() * 0.3}s`,+ }+}+</script>++<template>+ <motion.div+ class="bg-white dark:bg-neutral-800 rounded-lg p-3 shadow-sm border border-neutral-200 dark:border-neutral-700"+ :initial="{ opacity: 0, scale: 0.95, y: 20 }"+ :animate="{ opacity: 1, scale: 1, y: 0 }"+ :exit="{ opacity: 0, scale: 0.95, y: -20 }"+ :transition="{ duration: 0.3, ease: 'easeOut' }"+ layout+ >+ <!-- 文件信息头部 -->+ <div class="flex items-start justify-between mb-3">+ <div class="flex items-center gap-3 flex-1 min-w-0">+ <!-- 文件图标 -->+ <motion.div+ class="relative flex-shrink-0"+ :transition="{+ duration: uploadingFile.status === 'processing' ? 2 : 0.3,+ repeat: uploadingFile.status === 'processing' ? Infinity : 0,+ ease: 'linear',+ }"+ >+ <div+ class="w-10 h-10 rounded-lg border flex items-center justify-center"+ :class="{+ 'bg-blue-100 dark:bg-blue-900/30 border-blue-200 dark:border-blue-800/50':+ statusColor === 'primary' || statusColor === 'info',+ 'bg-green-100 dark:bg-green-900/30 border-green-200 dark:border-green-800/50':+ statusColor === 'success',+ 'bg-red-100 dark:bg-red-900/30 border-red-200 dark:border-red-800/50':+ statusColor === 'error',+ 'bg-neutral-100 dark:bg-neutral-900/30 border-neutral-200 dark:border-neutral-800/50':+ statusColor === 'neutral',+ }"+ >+ <Icon+ :name="fileIcon"+ class="w-5 h-5"+ :class="{+ 'text-blue-600/80 dark:text-blue-400/80':+ statusColor === 'primary' || statusColor === 'info',+ 'text-green-600/80 dark:text-green-400/80':+ statusColor === 'success',+ 'text-red-600/80 dark:text-red-400/80': statusColor === 'error',+ 'text-neutral-600/80 dark:text-neutral-400/80':+ statusColor === 'neutral',+ }"+ />+ </div>++ <!-- 完成指示器 -->+ <motion.div+ v-if="uploadingFile.status === 'completed'"+ class="absolute -top-2 -right-2 size-5 bg-green-900 rounded-full border-2 border-white dark:border-neutral-800 flex items-center justify-center"+ :initial="{ scale: 0 }"+ :animate="{ scale: 1 }"+ :transition="{ delay: 0.2, duration: 0.3, ease: 'backOut' }"+ >+ <Icon+ name="tabler:check"+ class="size-3 text-white"+ />+ </motion.div>++ <!-- 完成粒子动画 -->+ <AnimatePresence>+ <motion.div+ v-if="showParticles && uploadingFile.status === 'completed'"+ class="absolute -top-2 -right-2 size-5 pointer-events-none"+ :initial="{ opacity: 0 }"+ :animate="{ opacity: 1 }"+ :exit="{ opacity: 0 }"+ :transition="{ duration: 0.2 }"+ >+ <div+ v-for="i in particleCount"+ :key="i"+ class="absolute top-1/2 left-1/2 w-1.5 h-1.5 rounded-full particle-burst"+ :style="generateParticleStyle(i - 1)"+ />+ </motion.div>+ </AnimatePresence>+ </motion.div>++ <!-- 文件信息 -->+ <div class="flex-1 min-w-0">+ <div class="flex items-center gap-2 mb-1">+ <p+ class="font-medium text-sm truncate text-neutral-900 dark:text-neutral-100"+ >+ {{ uploadingFile.fileName }}+ </p>+ <UBadge+ :color="statusColor"+ variant="soft"+ size="sm"+ >+ {{ statusText }}+ </UBadge>+ </div>++ <div+ class="flex items-center gap-1 text-xs text-neutral-500 dark:text-neutral-400"+ >+ <span>{{ formatBytes(uploadingFile.file.size) }}</span>+ <span+ v-if="+ uploadingFile.uploadProgress?.speedText &&+ uploadingFile.status === 'uploading'+ "+ class="hidden sm:inline"+ >+ • {{ uploadingFile.uploadProgress.speedText }}+ </span>+ </div>+ </div>+ </div>++ <!-- 操作按钮 -->+ <div class="flex items-center gap-2 ml-2">+ <!-- 中止上传按钮 -->+ <motion.div+ v-if="uploadingFile.status === 'uploading' && uploadingFile.canAbort"+ :initial="{ opacity: 0, scale: 0.8 }"+ :animate="{ opacity: 1, scale: 1 }"+ :exit="{ opacity: 0, scale: 0.8 }"+ >+ <UButton+ size="xs"+ color="error"+ variant="ghost"+ icon="tabler:x"+ @click="uploadingFile.abortUpload?.()"+ >+ 中止+ </UButton>+ </motion.div>++ <!-- 清除按钮 -->+ <motion.div+ v-if="+ uploadingFile.status === 'completed' ||+ uploadingFile.status === 'error'+ "+ :initial="{ opacity: 0, scale: 0.8 }"+ :animate="{ opacity: 1, scale: 1 }"+ :exit="{ opacity: 0, scale: 0.8 }"+ >+ <UButton+ size="xs"+ color="neutral"+ variant="soft"+ icon="tabler:x"+ @click="emit('removeFile', fileId)"+ >+ 清除+ </UButton>+ </motion.div>+ </div>+ </div>++ <!-- 进度条区域 -->+ <AnimatePresence>+ <motion.div+ v-if="+ uploadingFile.status === 'uploading' ||+ uploadingFile.status === 'processing'+ "+ :initial="{ opacity: 0, height: 0 }"+ :animate="{ opacity: 1, height: 'auto' }"+ :exit="{ opacity: 0, height: 0 }"+ :transition="{ duration: 0.3 }"+ class="space-y-2"+ >+ <!-- 上传进度 -->+ <div+ v-if="uploadingFile.status === 'uploading'"+ class="space-y-1"+ >+ <div class="flex justify-between items-center">+ <span class="text-xs text-neutral-600 dark:text-neutral-400">+ 上传进度+ </span>+ <span+ class="text-xs font-mono text-neutral-600 dark:text-neutral-400"+ >+ {{ uploadingFile.progress }}%+ </span>+ </div>++ <motion.div+ class="relative"+ :initial="{ scaleX: 0 }"+ :animate="{ scaleX: 1 }"+ :transition="{ duration: 0.5 }"+ >+ <UProgress+ :model-value="uploadingFile.progress"+ :color="statusColor"+ />+ </motion.div>++ <div+ v-if="uploadingFile.uploadProgress?.timeRemainingText"+ class="text-xs text-neutral-500 dark:text-neutral-400"+ >+ 剩余时间: {{ uploadingFile.uploadProgress.timeRemainingText }}+ </div>+ </div>++ <!-- 处理进度 -->+ <div+ v-if="uploadingFile.status === 'processing'"+ class="space-y-1"+ >+ <div class="flex justify-between items-center">+ <span class="text-xs text-neutral-600 dark:text-neutral-400">+ 处理状态+ </span>+ <motion.span+ class="text-xs text-info-600 dark:text-info-400"+ :animate="{ opacity: [0.8, 1, 0.8] }"+ :transition="{ duration: 2, repeat: Infinity }"+ >+ {{ getStageText(uploadingFile.stage || 'pending') }}+ </motion.span>+ </div>++ <UProgress+ :model-value="null"+ animation="swing"+ color="info"+ />+ </div>+ </motion.div>+ </AnimatePresence>++ <!-- 错误信息 -->+ <AnimatePresence>+ <motion.div+ v-if="uploadingFile.status === 'error' && uploadingFile.error"+ :initial="{ opacity: 0, height: 0, y: -10 }"+ :animate="{ opacity: 1, height: 'auto', y: 0 }"+ :exit="{ opacity: 0, height: 0, y: -10 }"+ :transition="{ duration: 0.3 }"+ >+ <UAlert+ :description="uploadingFile.error"+ color="error"+ variant="soft"+ icon="tabler:alert-circle"+ :ui="{+ root: 'px-2.5 py-2',+ }"+ />+ </motion.div>+ </AnimatePresence>++ <!-- 处理时间警告 -->+ <AnimatePresence>+ <motion.div+ v-if="showProcessingWarning && uploadingFile.status === 'processing'"+ :initial="{ opacity: 0, height: 0, y: -10 }"+ :animate="{ opacity: 1, height: 'auto', y: 0 }"+ :exit="{ opacity: 0, height: 0, y: -10 }"+ :transition="{ duration: 0.3 }"+ class="mt-2"+ >+ <UAlert+ description="大文件处理时间较长,为正常现象"+ color="info"+ variant="soft"+ icon="tabler:info-circle"+ :ui="{+ root: 'px-2.5 py-2',+ }"+ />+ </motion.div>+ </AnimatePresence>++ <!-- 成功动画 -->+ <AnimatePresence>+ <motion.div+ v-if="uploadingFile.status === 'completed'"+ :initial="{ opacity: 0, scale: 0.8, y: 10 }"+ :animate="{+ opacity: 1,+ scale: [0.8, 1.1, 1],+ y: 0,+ }"+ :exit="{ opacity: 0, scale: 0.9, y: -10 }"+ :transition="{+ duration: 0.6,+ ease: 'backOut',+ }"+ >+ <UAlert+ description="文件已成功上传并处理"+ color="success"+ variant="soft"+ icon="tabler:circle-check"+ :ui="{+ root: 'px-2.5 py-2',+ }"+ />+ </motion.div>+ </AnimatePresence>+ </motion.div>+</template>++<style scoped>+/* 粒子爆开动画 */+.particle-burst {+ background: linear-gradient(45deg, #10b981, #059669, #047857);+ transform: translate(-50%, -50%);+ animation:+ particle-explode var(--duration, 1.5s) ease-out var(--delay, 0s) forwards,+ particle-fade var(--duration, 1.5s) ease-out var(--delay, 0s) forwards;+}++@keyframes particle-explode {+ 0% {+ transform: translate(-50%, -50%) scale(1) rotate(0deg);+ opacity: 1;+ }+ 20% {+ transform: translate(+ calc(+ -50% + cos(var(--angle, 0deg)) * calc(var(--distance, 60px) * 0.3)+ ),+ calc(-50% + sin(var(--angle, 0deg)) * calc(var(--distance, 60px) * 0.3))+ )+ scale(1.2) rotate(calc(var(--angle, 0deg) * 2));+ opacity: 1;+ }+ 100% {+ transform: translate(+ calc(-50% + cos(var(--angle, 0deg)) * var(--distance, 60px)),+ calc(-50% + sin(var(--angle, 0deg)) * var(--distance, 60px))+ )+ scale(0.3) rotate(calc(var(--angle, 0deg) * 4));+ opacity: 0;+ }+}++@keyframes particle-fade {+ 0% {+ opacity: 1;+ }+ 70% {+ opacity: 0.8;+ }+ 100% {+ opacity: 0;+ }+}++/* 为不同的粒子添加颜色变化 */+.particle-burst:nth-child(3n + 1) {+ background: linear-gradient(45deg, #10b981, #34d399);+}++.particle-burst:nth-child(3n + 2) {+ background: linear-gradient(45deg, #059669, #10b981);+}++.particle-burst:nth-child(3n + 3) {+ background: linear-gradient(45deg, #047857, #059669);+}++/* 添加一些粒子的闪烁效果 */+.particle-burst:nth-child(4n + 1) {+ animation:+ particle-explode var(--duration, 1.5s) ease-out var(--delay, 0s) forwards,+ particle-fade var(--duration, 1.5s) ease-out var(--delay, 0s) forwards,+ particle-sparkle calc(var(--duration, 1.5s) * 0.5) ease-in-out+ var(--delay, 0s) forwards;+}++@keyframes particle-sparkle {+ 0%,+ 100% {+ box-shadow: 0 0 0 rgba(16, 185, 129, 0);+ }+ 50% {+ box-shadow: 0 0 8px rgba(16, 185, 129, 0.8);+ }+}+</style>diff --git a/app/components/upload/UploadQueueContainer.vue b/app/components/ui/UploadQueuePanel.vuesimilarity index 76%rename from app/components/upload/UploadQueueContainer.vuerename to app/components/ui/UploadQueuePanel.vueindex 5fa4c745..2cd4da56 100644--- a/app/components/upload/UploadQueueContainer.vue+++ b/app/components/ui/UploadQueuePanel.vue@@ -5,7 +5,13 @@ interface UploadFile {file: FilefileName: stringfileId: string- status: 'preparing' | 'uploading' | 'processing' | 'completed' | 'error'+ status:+ | 'waiting'+ | 'preparing'+ | 'uploading'+ | 'processing'+ | 'completed'+ | 'error'stage?: string | nullprogress?: numbererror?: string@@ -42,6 +48,7 @@ const stats = computed(() => {const files = Array.from(props.uploadingFiles.values())return {total: files.length,+ waiting: files.filter((f) => f.status === 'waiting').length,uploading: files.filter((f) => f.status === 'uploading').length,processing: files.filter((f) => f.status === 'processing').length,completed: files.filter((f) => f.status === 'completed').length,@@ -49,6 +56,9 @@ const stats = computed(() => {active: files.filter((f) => f.status === 'uploading' || f.status === 'processing',).length,+ pending: files.filter(+ (f) => f.status === 'waiting' || f.status === 'preparing',+ ).length,}})@@ -60,11 +70,20 @@ const overallProgress = computed(() => {let totalProgress = 0files.forEach((file) => {if (file.status === 'completed') {+ // 完成状态:100%totalProgress += 100} else if (file.status === 'uploading' && file.progress !== undefined) {- totalProgress += file.progress+ // 上传中:上传进度 * 0.7(上传占总进度的70%)+ totalProgress += file.progress * 0.7} else if (file.status === 'processing') {- totalProgress += 50 // 估算处理进度为50%+ // 处理中:上传完成(70%)+ totalProgress += 70+ } else if (file.status === 'preparing') {+ // 准备中:0%+ totalProgress += 0+ } else if (file.status === 'waiting') {+ // 等待状态:0%+ totalProgress += 0}})@@ -101,10 +120,10 @@ const clearAllFiles = () => {<template><divv-if="uploadingFiles.size > 0"- class="fixed bottom-4 right-4 z-50 w-96 max-w-[calc(100vw-2rem)]"+ class="fixed bottom-2 inset-x-2 sm:inset-x-6 sm:bottom-6 sm:left-auto z-50 min-w-sm"><motion.div- class="bg-white dark:bg-neutral-900 rounded-xl shadow-xl border border-neutral-200 dark:border-neutral-700 overflow-hidden"+ class="bg-white dark:bg-neutral-900 rounded-xl shadow-2xl border border-neutral-200 dark:border-neutral-700 overflow-hidden":initial="{ opacity: 0, y: 100, scale: 0.9 }":animate="{ opacity: 1, y: 0, scale: 1 }":exit="{ opacity: 0, y: 100, scale: 0.9 }"@@ -121,21 +140,22 @@ const clearAllFiles = () => {<div class="flex items-center justify-between"><div class="flex items-center gap-3"><!-- 状态指示器 -->- <motion.div- class="w-3 h-3 rounded-full"+ <Icon+ :name="+ {+ primary: 'tabler:upload',+ success: 'tabler:circle-check',+ error: 'tabler:alert-circle',+ neutral: 'tabler:info-circle',+ }[statusColor]+ "+ class="size-5":class="{- 'bg-blue-500': statusColor === 'primary',- 'bg-green-500': statusColor === 'success',- 'bg-red-500': statusColor === 'error',- 'bg-neutral-400': statusColor === 'neutral',- }"- :animate="{- scale: stats.active > 0 ? [1, 1.2, 1] : 1,- opacity: stats.active > 0 ? [0.7, 1, 0.7] : 1,- }"- :transition="{- duration: 2,- repeat: stats.active > 0 ? Infinity : 0,+ 'text-blue-600 dark:text-blue-400': statusColor === 'primary',+ 'text-green-600 dark:text-green-400': statusColor === 'success',+ 'text-red-600 dark:text-red-400': statusColor === 'error',+ 'text-neutral-600 dark:text-neutral-400':+ statusColor === 'neutral',}"/>@@ -153,6 +173,12 @@ const clearAllFiles = () => {<divclass="flex items-center gap-2 text-xs text-neutral-500 dark:text-neutral-400 mt-1">+ <span+ v-if="stats.waiting > 0"+ class="text-neutral-600 dark:text-neutral-400"+ >+ {{ stats.waiting }} 等待+ </span><spanv-if="stats.active > 0"class="text-blue-600 dark:text-blue-400"@@ -191,7 +217,7 @@ const clearAllFiles = () => {><Iconname="tabler:chevron-down"- class="w-4 h-4 text-neutral-500 dark:text-neutral-400"+ class="size-5 text-neutral-500 dark:text-neutral-400 block"/></motion.div></div>@@ -222,11 +248,11 @@ const clearAllFiles = () => {:animate="{ height: 'auto', opacity: 1 }":exit="{ height: 0, opacity: 0 }":transition="{ duration: 0.3, ease: 'easeInOut' }"- class="max-h-96 overflow-y-auto"+ class="max-h-[calc(100vh-25.3rem)] sm:max-h-[600px] overflow-hidden overflow-y-auto filelist-container"><div class="p-2 space-y-2"><AnimatePresence mode="popLayout">- <UploadAnimationCard+ <UploadQueueItemv-for="[fileId, uploadingFile] in uploadingFiles":key="fileId":uploading-file="uploadingFile"@@ -242,10 +268,11 @@ const clearAllFiles = () => {<AnimatePresence><motion.divv-if="!isCollapsed && (stats.completed > 0 || stats.error > 0)"- :initial="{ opacity: 0, height: 0 }"- :animate="{ opacity: 1, height: 'auto' }"- :exit="{ opacity: 0, height: 0 }"+ :initial="{ opacity: 0, scaleY: 0 }"+ :animate="{ opacity: 1, scaleY: 1 }"+ :exit="{ opacity: 0, scaleY: 0 }":transition="{ duration: 0.3 }"+ style="transform-origin: bottom"class="p-3 border-t border-neutral-200 dark:border-neutral-700 bg-neutral-50 dark:bg-neutral-800/50"><div class="flex items-center justify-between gap-2">@@ -282,20 +309,20 @@ const clearAllFiles = () => {<style scoped>/* 滚动条样式 */-.max-h-96::-webkit-scrollbar {+.filelist-container::-webkit-scrollbar {width: 4px;}-.max-h-96::-webkit-scrollbar-track {+.filelist-container::-webkit-scrollbar-track {background: transparent;}-.max-h-96::-webkit-scrollbar-thumb {+.filelist-container::-webkit-scrollbar-thumb {background: rgba(0, 0, 0, 0.2);border-radius: 2px;}-.dark .max-h-96::-webkit-scrollbar-thumb {+.dark .filelist-container::-webkit-scrollbar-thumb {background: rgba(255, 255, 255, 0.2);}</style>diff --git a/app/components/upload/DragDropUploadZone.vue b/app/components/upload/DragDropUploadZone.vuedeleted file mode 100644index 115a7e2c..00000000--- a/app/components/upload/DragDropUploadZone.vue+++ /dev/null@@ -1,347 +0,0 @@-<script lang="ts" setup>-import { motion, AnimatePresence } from 'motion-v'-import { ref, computed } from 'vue'--interface Props {- isDragOver?: boolean- isUploading?: boolean- acceptedTypes?: string- maxFileSize?: number- disabled?: boolean-}--const props = withDefaults(defineProps<Props>(), {- isDragOver: false,- isUploading: false,- acceptedTypes: 'image/jpeg,image/png,image/heic,image/heif,video/quicktime,.mov',- maxFileSize: 100,- disabled: false-})--const emit = defineEmits<{- filesSelected: [files: FileList]- dragEnter: []- dragLeave: []-}>()--const fileInputRef = ref<HTMLInputElement>()-const isDragOverInternal = ref(false)-const dragCounter = ref(0)--// 计算拖拽状态-const isActive = computed(() => props.isDragOver || isDragOverInternal.value)--// 处理拖拽事件-const handleDragEnter = (e: DragEvent) => {- e.preventDefault()- e.stopPropagation()- dragCounter.value++-- if (dragCounter.value === 1) {- isDragOverInternal.value = true- emit('dragEnter')- }-}--const handleDragLeave = (e: DragEvent) => {- e.preventDefault()- e.stopPropagation()- dragCounter.value---- if (dragCounter.value === 0) {- isDragOverInternal.value = false- emit('dragLeave')- }-}--const handleDragOver = (e: DragEvent) => {- e.preventDefault()- e.stopPropagation()-}--const handleDrop = (e: DragEvent) => {- e.preventDefault()- e.stopPropagation()-- dragCounter.value = 0- isDragOverInternal.value = false- emit('dragLeave')-- if (props.disabled) return-- const files = e.dataTransfer?.files- if (files && files.length > 0) {- emit('filesSelected', files)- }-}--// 处理文件选择-const handleFileSelect = (e: Event) => {- const input = e.target as HTMLInputElement- if (input.files && input.files.length > 0) {- emit('filesSelected', input.files)- }- // 清空输入值以允许重新选择相同文件- input.value = ''-}--// 触发文件选择-const triggerFileSelect = () => {- if (!props.disabled) {- fileInputRef.value?.click()- }-}--// 格式化接受的文件类型-const acceptedTypesText = computed(() => {- return 'JPEG、PNG、HEIC 格式照片,以及 MOV 格式 LivePhoto 视频'-})-</script>--<template>- <motion.div- class="relative border-2 border-dashed rounded-xl transition-all duration-300 cursor-pointer overflow-hidden"- :class="{- 'border-blue-300 bg-blue-50 dark:border-blue-600 dark:bg-blue-950/30': isActive && !disabled,- 'border-neutral-300 dark:border-neutral-600 hover:border-neutral-400 dark:hover:border-neutral-500': !isActive && !disabled,- 'border-neutral-200 dark:border-neutral-700 cursor-not-allowed opacity-50': disabled- }"- :animate="{- scale: isActive ? 1.02 : 1,- borderWidth: isActive ? 3 : 2- }"- :transition="{ duration: 0.2, ease: 'easeOut' }"- @dragenter="handleDragEnter"- @dragleave="handleDragLeave"- @dragover="handleDragOver"- @drop="handleDrop"- @click="triggerFileSelect"- >- <!-- 背景动画 -->- <AnimatePresence>- <motion.div- v-if="isActive"- class="absolute inset-0 bg-gradient-to-br from-blue-400/10 to-purple-400/10 dark:from-blue-600/20 dark:to-purple-600/20"- :initial="{ opacity: 0 }"- :animate="{ opacity: 1 }"- :exit="{ opacity: 0 }"- :transition="{ duration: 0.3 }"- />- </AnimatePresence>-- <!-- 内容区域 -->- <div class="relative p-8 text-center">- <!-- 图标区域 -->- <motion.div- class="mb-4 flex justify-center"- :animate="{- y: isActive ? -8 : 0,- scale: isActive ? 1.1 : 1- }"- :transition="{ duration: 0.3, ease: 'backOut' }"- >- <div- class="p-4 rounded-full"- :class="{- 'bg-blue-100 dark:bg-blue-900/50': isActive,- 'bg-neutral-100 dark:bg-neutral-800': !isActive- }"- >- <AnimatePresence mode="wait">- <motion.div- :key="isUploading ? 'uploading' : isActive ? 'active' : 'idle'"- :initial="{ opacity: 0, rotate: -90 }"- :animate="{ opacity: 1, rotate: 0 }"- :exit="{ opacity: 0, rotate: 90 }"- :transition="{ duration: 0.3 }"- >- <Icon- v-if="isUploading"- name="tabler:loader"- class="w-8 h-8 text-blue-600 dark:text-blue-400 animate-spin"- />- <Icon- v-else-if="isActive"- name="tabler:cloud-upload"- class="w-8 h-8 text-blue-600 dark:text-blue-400"- />- <Icon- v-else- name="tabler:photo-plus"- class="w-8 h-8 text-neutral-500 dark:text-neutral-400"- />- </motion.div>- </AnimatePresence>- </div>- </motion.div>-- <!-- 文本区域 -->- <motion.div- :animate="{- y: isActive ? -4 : 0- }"- :transition="{ duration: 0.3, ease: 'easeOut' }"- >- <AnimatePresence mode="wait">- <motion.div- :key="isUploading ? 'uploading' : isActive ? 'active' : 'idle'"- :initial="{ opacity: 0, y: 10 }"- :animate="{ opacity: 1, y: 0 }"- :exit="{ opacity: 0, y: -10 }"- :transition="{ duration: 0.3 }"- >- <h3- class="text-lg font-semibold mb-2"- :class="{- 'text-blue-700 dark:text-blue-300': isActive,- 'text-neutral-900 dark:text-neutral-100': !isActive- }"- >- <template v-if="isUploading">- 正在上传文件...- </template>- <template v-else-if="isActive">- 松开以上传文件- </template>- <template v-else>- 选择照片上传- </template>- </h3>-- <p- class="text-sm mb-4"- :class="{- 'text-blue-600 dark:text-blue-400': isActive,- 'text-neutral-600 dark:text-neutral-400': !isActive- }"- >- <template v-if="isUploading">- 请稍候,文件正在处理中...- </template>- <template v-else-if="isActive">- 拖拽文件到此区域即可开始上传- </template>- <template v-else>- 点击选择文件或将文件拖拽到此处- </template>- </p>- </motion.div>- </AnimatePresence>-- <!-- 支持的文件类型 -->- <motion.div- class="text-xs text-neutral-500 dark:text-neutral-400"- :animate="{- opacity: isActive ? 0.8 : 0.6- }"- :transition="{ duration: 0.2 }"- >- <p class="mb-1">支持格式: {{ acceptedTypesText }}</p>- <p>最大文件大小: {{ maxFileSize }}MB</p>- </motion.div>-- <!-- 上传按钮 -->- <motion.div- v-if="!isActive && !isUploading"- class="mt-4"- :initial="{ opacity: 0, scale: 0.9 }"- :animate="{ opacity: 1, scale: 1 }"- :transition="{ delay: 0.1, duration: 0.3 }"- >- <UButton- color="primary"- variant="soft"- icon="tabler:upload"- :disabled="disabled"- @click.stop="triggerFileSelect"- >- 选择文件- </UButton>- </motion.div>- </motion.div>-- <!-- 浮动粒子效果 -->- <AnimatePresence>- <motion.div- v-if="isActive"- class="absolute inset-0 pointer-events-none"- :initial="{ opacity: 0 }"- :animate="{ opacity: 1 }"- :exit="{ opacity: 0 }"- >- <div- v-for="i in 6"- :key="i"- class="absolute w-2 h-2 bg-blue-400 dark:bg-blue-500 rounded-full opacity-30"- :class="`particle-${i}`"- />- </motion.div>- </AnimatePresence>- </div>-- <!-- 隐藏的文件输入 -->- <input- ref="fileInputRef"- type="file"- multiple- :accept="acceptedTypes"- class="hidden"- :disabled="disabled"- @change="handleFileSelect"- >- </motion.div>-</template>--<style scoped>-/* 粒子动画 */-.particle-1 {- top: 20%;- left: 15%;- animation: float 3s ease-in-out infinite;- animation-delay: 0s;-}--.particle-2 {- top: 30%;- right: 20%;- animation: float 2.5s ease-in-out infinite;- animation-delay: 0.5s;-}--.particle-3 {- bottom: 30%;- left: 25%;- animation: float 3.5s ease-in-out infinite;- animation-delay: 1s;-}--.particle-4 {- bottom: 20%;- right: 15%;- animation: float 2.8s ease-in-out infinite;- animation-delay: 1.5s;-}--.particle-5 {- top: 50%;- left: 10%;- animation: float 3.2s ease-in-out infinite;- animation-delay: 2s;-}--.particle-6 {- top: 60%;- right: 25%;- animation: float 2.3s ease-in-out infinite;- animation-delay: 2.5s;-}--@keyframes float {- 0%, 100% {- transform: translateY(0) scale(1);- }- 50% {- transform: translateY(-20px) scale(1.2);- }-}-</style>diff --git a/app/components/upload/UploadAnimationCard.vue b/app/components/upload/UploadAnimationCard.vuedeleted file mode 100644index 142e127d..00000000--- a/app/components/upload/UploadAnimationCard.vue+++ /dev/null@@ -1,449 +0,0 @@-<script lang="ts" setup>-import { motion, AnimatePresence } from 'motion-v'-import { computed } from 'vue'--interface UploadFile {- file: File- fileName: string- fileId: string- status: 'preparing' | 'uploading' | 'processing' | 'completed' | 'error'- stage?: string | null- progress?: number- error?: string- taskId?: number- uploadProgress?: {- loaded: number- total: number- percentage: number- speed?: number- timeRemaining?: number- speedText?: string- timeRemainingText?: string- }- canAbort?: boolean- abortUpload?: () => void-}--const props = defineProps<{- uploadingFile: UploadFile- fileId: string-}>()--const emit = defineEmits<{- removeFile: [fileId: string]-}>()--// 计算文件图标-const fileIcon = computed(() => {- const file = props.uploadingFile.file- if (file.type.startsWith('image/')) {- return 'tabler:photo'- } else if (file.type.startsWith('video/')) {- return 'tabler:video'- }- return 'tabler:file'-})--// 计算状态颜色-const statusColor = computed(() => {- switch (props.uploadingFile.status) {- case 'preparing':- return 'primary'- case 'uploading':- return 'primary'- case 'processing':- return 'info'- case 'completed':- return 'success'- case 'error':- return 'error'- default:- return 'neutral'- }-})--// 计算状态文本-const statusText = computed(() => {- switch (props.uploadingFile.status) {- case 'preparing':- return '准备中'- case 'uploading':- return `上传中 ${props.uploadingFile.progress || 0}%`- case 'processing':- return props.uploadingFile.stage- ? getStageText(props.uploadingFile.stage)- : '等待处理'- case 'completed':- return '完成'- case 'error':- return '错误'- default:- return '未知'- }-})--// 获取处理阶段文本-const getStageText = (stage: string) => {- const stageMap: Record<string, string> = {- 'preprocessing': '预处理中',- 'metadata': '提取元数据',- 'thumbnail': '生成缩略图',- 'exif': '处理EXIF',- 'reverse-geocoding': '地理解析',- 'live-photo': '处理LivePhoto'- }- return stageMap[stage] || stage-}--// 计算进度值-const progressValue = computed(() => {- if (props.uploadingFile.status === 'uploading') {- return props.uploadingFile.progress || 0- }- if (props.uploadingFile.status === 'processing') {- return props.uploadingFile.stage ? undefined : null- }- if (props.uploadingFile.status === 'completed') {- return 100- }- return 0-})--// 文件大小格式化-const formatBytes = (bytes: number) => {- if (bytes === 0) return '0 B'- const k = 1024- const sizes = ['B', 'KB', 'MB', 'GB']- const i = Math.floor(Math.log(bytes) / Math.log(k))- return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + ' ' + sizes[i]-}-</script>--<template>- <motion.div- class="bg-white dark:bg-neutral-800 rounded-lg p-4 shadow-sm border border-neutral-200 dark:border-neutral-700"- :initial="{ opacity: 0, scale: 0.95, y: 20 }"- :animate="{ opacity: 1, scale: 1, y: 0 }"- :exit="{ opacity: 0, scale: 0.95, y: -20 }"- :transition="{ duration: 0.3, ease: 'easeOut' }"- layout- >- <!-- 文件信息头部 -->- <div class="flex items-center justify-between mb-3">- <div class="flex items-center gap-3 flex-1 min-w-0">- <!-- 文件图标 -->- <motion.div- class="relative flex-shrink-0"- :animate="{- rotate: uploadingFile.status === 'processing' ? 360 : 0- }"- :transition="{- duration: uploadingFile.status === 'processing' ? 2 : 0.3,- repeat: uploadingFile.status === 'processing' ? Infinity : 0,- ease: 'linear'- }"- >- <div- class="w-10 h-10 rounded-lg flex items-center justify-center"- :class="{- 'bg-blue-100 dark:bg-blue-900/30': statusColor === 'primary',- 'bg-green-100 dark:bg-green-900/30': statusColor === 'success',- 'bg-red-100 dark:bg-red-900/30': statusColor === 'error',- 'bg-blue-100 dark:bg-blue-900/30': statusColor === 'info',- 'bg-neutral-100 dark:bg-neutral-900/30': statusColor === 'neutral'- }"- >- <Icon- :name="fileIcon"- class="w-5 h-5"- :class="`text-${statusColor}-600 dark:text-${statusColor}-400`"- />- </div>-- <!-- 状态指示器 -->- <motion.div- v-if="uploadingFile.status !== 'completed'"- class="absolute -top-1 -right-1 w-4 h-4 rounded-full border-2 border-white dark:border-neutral-800 flex items-center justify-center"- :class="{- 'bg-blue-500': uploadingFile.status === 'preparing' || uploadingFile.status === 'uploading',- 'bg-purple-500': uploadingFile.status === 'processing',- 'bg-red-500': uploadingFile.status === 'error'- }"- :animate="{- scale: uploadingFile.status === 'processing' ? [1, 1.2, 1] : 1- }"- :transition="{- duration: 1,- repeat: uploadingFile.status === 'processing' ? Infinity : 0- }"- >- <Icon- v-if="uploadingFile.status === 'error'"- name="tabler:x"- class="w-2.5 h-2.5 text-white"- />- <motion.div- v-else- class="w-2 h-2 bg-white rounded-full"- :animate="{- opacity: uploadingFile.status === 'processing' ? [0.5, 1, 0.5] : 1- }"- :transition="{- duration: 1.5,- repeat: uploadingFile.status === 'processing' ? Infinity : 0- }"- />- </motion.div>-- <!-- 完成指示器 -->- <motion.div- v-if="uploadingFile.status === 'completed'"- class="absolute -top-1 -right-1 w-4 h-4 bg-green-500 rounded-full border-2 border-white dark:border-neutral-800 flex items-center justify-center"- :initial="{ scale: 0 }"- :animate="{ scale: 1 }"- :transition="{ delay: 0.2, duration: 0.3, ease: 'backOut' }"- >- <Icon- name="tabler:check"- class="w-2.5 h-2.5 text-white"- />- </motion.div>- </motion.div>-- <!-- 文件信息 -->- <div class="flex-1 min-w-0">- <div class="flex items-center gap-2 mb-1">- <p class="font-medium text-sm truncate text-neutral-900 dark:text-neutral-100">- {{ uploadingFile.fileName }}- </p>- <UBadge- :color="statusColor"- variant="soft"- size="sm"- >- {{ statusText }}- </UBadge>- </div>-- <div class="flex items-center gap-2 text-xs text-neutral-500 dark:text-neutral-400">- <span>{{ formatBytes(uploadingFile.file.size) }}</span>- <span- v-if="uploadingFile.uploadProgress?.speedText && uploadingFile.status === 'uploading'"- class="hidden sm:inline"- >- • {{ uploadingFile.uploadProgress.speedText }}- </span>- </div>- </div>- </div>-- <!-- 操作按钮 -->- <div class="flex items-center gap-2 ml-2">- <!-- 中止上传按钮 -->- <motion.div- v-if="uploadingFile.status === 'uploading' && uploadingFile.canAbort"- :initial="{ opacity: 0, scale: 0.8 }"- :animate="{ opacity: 1, scale: 1 }"- :exit="{ opacity: 0, scale: 0.8 }"- >- <UButton- size="xs"- color="red"- variant="ghost"- icon="tabler:x"- @click="uploadingFile.abortUpload?.()"- >- 中止- </UButton>- </motion.div>-- <!-- 清除按钮 -->- <motion.div- v-if="uploadingFile.status === 'completed' || uploadingFile.status === 'error'"- :initial="{ opacity: 0, scale: 0.8 }"- :animate="{ opacity: 1, scale: 1 }"- :exit="{ opacity: 0, scale: 0.8 }"- >- <UButton- size="xs"- color="neutral"- variant="ghost"- icon="tabler:x"- @click="emit('removeFile', fileId)"- >- 清除- </UButton>- </motion.div>- </div>- </div>-- <!-- 进度条区域 -->- <AnimatePresence>- <motion.div- v-if="uploadingFile.status === 'uploading' || uploadingFile.status === 'processing'"- :initial="{ opacity: 0, height: 0 }"- :animate="{ opacity: 1, height: 'auto' }"- :exit="{ opacity: 0, height: 0 }"- :transition="{ duration: 0.3 }"- class="space-y-2"- >- <!-- 上传进度 -->- <div- v-if="uploadingFile.status === 'uploading'"- class="space-y-1"- >- <div class="flex justify-between items-center">- <span class="text-xs text-neutral-600 dark:text-neutral-400">- 上传进度- </span>- <span class="text-xs font-mono text-neutral-600 dark:text-neutral-400">- {{ uploadingFile.progress }}%- </span>- </div>-- <motion.div- class="relative"- :initial="{ scaleX: 0 }"- :animate="{ scaleX: 1 }"- :transition="{ duration: 0.5 }"- >- <UProgress- :model-value="progressValue"- :color="statusColor"- class="h-2"- />- </motion.div>-- <div- v-if="uploadingFile.uploadProgress?.timeRemainingText"- class="text-xs text-neutral-500 dark:text-neutral-400"- >- 剩余时间: {{ uploadingFile.uploadProgress.timeRemainingText }}- </div>- </div>-- <!-- 处理进度 -->- <div- v-if="uploadingFile.status === 'processing'"- class="space-y-1"- >- <div class="flex justify-between items-center">- <span class="text-xs text-neutral-600 dark:text-neutral-400">- 处理状态- </span>- <motion.span- class="text-xs text-purple-600 dark:text-purple-400"- :animate="{ opacity: [0.6, 1, 0.6] }"- :transition="{ duration: 2, repeat: Infinity }"- >- {{ getStageText(uploadingFile.stage || 'pending') }}- </motion.span>- </div>-- <UProgress- :model-value="progressValue"- animation="carousel"- color="purple"- class="h-2"- />- </div>- </motion.div>- </AnimatePresence>-- <!-- 错误信息 -->- <AnimatePresence>- <motion.div- v-if="uploadingFile.status === 'error' && uploadingFile.error"- :initial="{ opacity: 0, height: 0, y: -10 }"- :animate="{ opacity: 1, height: 'auto', y: 0 }"- :exit="{ opacity: 0, height: 0, y: -10 }"- :transition="{ duration: 0.3 }"- class="mt-3"- >- <UAlert- :description="uploadingFile.error"- color="red"- variant="soft"- icon="tabler:alert-circle"- />- </motion.div>- </AnimatePresence>-- <!-- 成功动画 -->- <AnimatePresence>- <motion.div- v-if="uploadingFile.status === 'completed'"- :initial="{ opacity: 0, scale: 0.8, y: 10 }"- :animate="{- opacity: 1,- scale: [0.8, 1.1, 1],- y: 0,- backgroundColor: ['rgba(34, 197, 94, 0)', 'rgba(34, 197, 94, 0.1)', 'rgba(34, 197, 94, 0)']- }"- :exit="{ opacity: 0, scale: 0.9, y: -10 }"- :transition="{- duration: 0.6,- ease: 'backOut',- backgroundColor: { duration: 1.2, ease: 'easeInOut' }- }"- class="mt-3 flex items-center gap-2 text-green-600 dark:text-green-400 rounded-lg p-2 -m-2"- >- <motion.div- :animate="{ rotate: [0, 360] }"- :transition="{ duration: 0.5, delay: 0.1 }"- >- <Icon name="tabler:check-circle" class="w-4 h-4" />- </motion.div>- <span class="text-sm font-medium">处理完成</span>-- <!-- 庆祝粒子效果 -->- <motion.div- v-for="i in 3"- :key="`particle-${i}`"- class="absolute w-1 h-1 bg-green-500 rounded-full pointer-events-none"- :style="{- left: `${20 + i * 10}px`,- top: `${10 + i * 5}px`- }"- :animate="{- y: [-5, -15, -5],- x: [0, (i - 2) * 10, 0],- opacity: [0, 1, 0],- scale: [0, 1.5, 0]- }"- :transition="{- duration: 1,- delay: 0.2 + i * 0.1,- ease: 'easeOut'- }"- />- </motion.div>- </AnimatePresence>- </motion.div>-</template>--<style scoped>-/* 动态颜色类 - 确保Tailwind包含这些类 */-.bg-blue-100,-.bg-blue-900\/30,-.text-blue-600,-.text-blue-400,-.bg-purple-100,-.bg-purple-900\/30,-.text-purple-600,-.text-purple-400,-.bg-green-100,-.bg-green-900\/30,-.text-green-600,-.text-green-400,-.bg-red-100,-.bg-red-900\/30,-.text-red-600,-.text-red-400,-.bg-neutral-100,-.bg-neutral-900\/30,-.text-neutral-600,-.text-neutral-400 {- /* Tailwind会自动生成这些类 */-}-</style>diff --git a/app/components/upload/UploadProgressToast.vue b/app/components/upload/UploadProgressToast.vuedeleted file mode 100644index f94820d4..00000000--- a/app/components/upload/UploadProgressToast.vue+++ /dev/null@@ -1,156 +0,0 @@-<script lang="ts" setup>-import { motion, AnimatePresence } from 'motion-v'-import { computed } from 'vue'--interface UploadStats {- total: number- uploading: number- processing: number- completed: number- error: number- active: number- overallProgress: number-}--const props = defineProps<{- stats: UploadStats- visible: boolean-}>()--const emit = defineEmits<{- close: []- showDetails: []-}>()--// 计算显示文本-const statusText = computed(() => {- if (props.stats.active === 0) {- return props.stats.error > 0 ? '上传完成(有错误)' : '上传完成'- }- return `${props.stats.active} 个文件正在处理`-})--// 计算状态颜色-const statusColor = computed(() => {- if (props.stats.error > 0 && props.stats.active === 0) return 'red'- if (props.stats.active > 0) return 'blue'- return 'green'-})--// 计算图标-const statusIcon = computed(() => {- if (props.stats.active > 0) return 'tabler:upload'- if (props.stats.error > 0) return 'tabler:alert-circle'- return 'tabler:check-circle'-})-</script>--<template>- <AnimatePresence>- <motion.div- v-if="visible"- class="fixed top-4 right-4 z-50 max-w-sm"- :initial="{ opacity: 0, x: 100, scale: 0.9 }"- :animate="{ opacity: 1, x: 0, scale: 1 }"- :exit="{ opacity: 0, x: 100, scale: 0.9 }"- :transition="{ duration: 0.3, ease: 'backOut' }"- >- <motion.div- class="bg-white dark:bg-neutral-900 rounded-lg shadow-lg border border-neutral-200 dark:border-neutral-700 p-4 cursor-pointer"- :whileHover="{ scale: 1.02 }"- :whileTap="{ scale: 0.98 }"- @click="emit('showDetails')"- >- <!-- 头部 -->- <div class="flex items-center justify-between mb-3">- <div class="flex items-center gap-2">- <motion.div- :animate="{- rotate: stats.active > 0 ? 360 : 0- }"- :transition="{- duration: stats.active > 0 ? 2 : 0.3,- repeat: stats.active > 0 ? Infinity : 0,- ease: 'linear'- }"- >- <Icon- :name="statusIcon"- class="w-5 h-5"- :class="{- 'text-blue-600 dark:text-blue-400': statusColor === 'blue',- 'text-green-600 dark:text-green-400': statusColor === 'green',- 'text-red-600 dark:text-red-400': statusColor === 'red'- }"- />- </motion.div>-- <span class="font-medium text-sm text-neutral-900 dark:text-neutral-100">- {{ statusText }}- </span>- </div>-- <UButton- size="xs"- color="neutral"- variant="ghost"- icon="tabler:x"- @click.stop="emit('close')"- />- </div>-- <!-- 进度信息 -->- <div class="space-y-2">- <!-- 整体进度条 -->- <motion.div- v-if="stats.active > 0"- :initial="{ scaleX: 0 }"- :animate="{ scaleX: 1 }"- :transition="{ duration: 0.5 }"- style="transform-origin: left"- >- <div class="flex justify-between text-xs text-neutral-600 dark:text-neutral-400 mb-1">- <span>整体进度</span>- <span>{{ stats.overallProgress }}%</span>- </div>- <UProgress- :model-value="stats.overallProgress"- :color="statusColor"- class="h-1.5"- />- </motion.div>-- <!-- 统计信息 -->- <div class="flex items-center gap-4 text-xs text-neutral-600 dark:text-neutral-400">- <div v-if="stats.uploading > 0" class="flex items-center gap-1">- <div class="w-2 h-2 bg-blue-500 rounded-full animate-pulse" />- <span>{{ stats.uploading }} 上传中</span>- </div>-- <div v-if="stats.processing > 0" class="flex items-center gap-1">- <div class="w-2 h-2 bg-purple-500 rounded-full animate-pulse" />- <span>{{ stats.processing }} 处理中</span>- </div>-- <div v-if="stats.completed > 0" class="flex items-center gap-1">- <div class="w-2 h-2 bg-green-500 rounded-full" />- <span>{{ stats.completed }} 完成</span>- </div>-- <div v-if="stats.error > 0" class="flex items-center gap-1">- <div class="w-2 h-2 bg-red-500 rounded-full" />- <span>{{ stats.error }} 失败</span>- </div>- </div>- </div>-- <!-- 点击提示 -->- <div class="mt-2 text-xs text-neutral-500 dark:text-neutral-400">- 点击查看详情- </div>- </motion.div>- </motion.div>- </AnimatePresence>-</template>--<style scoped></style>diff --git a/app/pages/dashboard/photos.vue b/app/pages/dashboard/photos.vueindex b4364306..ffaaf806 100644--- a/app/pages/dashboard/photos.vue+++ b/app/pages/dashboard/photos.vue@@ -33,7 +33,13 @@ interface UploadingFile {file: FilefileName: stringfileId: string- status: 'preparing' | 'uploading' | 'processing' | 'completed' | 'error'+ status:+ | 'waiting'+ | 'preparing'+ | 'uploading'+ | 'processing'+ | 'completed'+ | 'error'stage?: PipelineQueueItem['statusStage'] | nullprogress?: numbererror?: string@@ -54,25 +60,34 @@ interface UploadingFile {const uploadingFiles = ref<Map<string, UploadingFile>>(new Map())-const uploadImage = async (file: File) => {+const uploadImage = async (file: File, existingFileId?: string) => {const fileName = file.name- const fileId = `${Date.now()}-${fileName}`+ const fileId = existingFileId || `${Date.now()}-${fileName}`const uploadManager = useUpload({timeout: 10 * 60 * 1000, // 10分钟超时})- const uploadingFile: UploadingFile = {- file,- fileName,- fileId,- status: 'preparing',- canAbort: false,- abortUpload: () => uploadManager.abortUpload(),+ // 获取或创建 uploadingFile+ let uploadingFile = uploadingFiles.value.get(fileId)+ if (!uploadingFile) {+ uploadingFile = {+ file,+ fileName,+ fileId,+ status: 'preparing',+ canAbort: false,+ abortUpload: () => uploadManager.abortUpload(),+ }+ uploadingFiles.value.set(fileId, uploadingFile)+ } else {+ // 更新现有条目的状态和回调+ uploadingFile.status = 'preparing'+ uploadingFile.canAbort = false+ uploadingFile.abortUpload = () => uploadManager.abortUpload()+ uploadingFiles.value = new Map(uploadingFiles.value)}- uploadingFiles.value.set(fileId, uploadingFile)-try {// 第一步:获取预签名 URLuploadingFile.status = 'preparing'@@ -601,31 +616,26 @@ const handleUpload = async () => {return}- // 显示批量上传进度- const uploadToast = toast.add({- title: '开始批量上传',- description: `正在上传 ${fileList.length} 个文件...`,- color: 'info',- })-- let successCount = 0- let errorCount = 0const errors: string[] = []// 先验证所有文件const validFiles: File[] = []+ const fileIdMapping = new Map<File, string>()+for (const file of fileList) {const validation = validateFile(file)if (!validation.valid) {errors.push(`${file.name}: ${validation.error}`)- errorCount++} else {validFiles.push(file)+ // 为每个有效文件生成唯一ID+ const fileId = `${Date.now()}-${Math.random().toString(36).substr(2, 9)}-${file.name}`+ fileIdMapping.set(file, fileId)}}if (validFiles.length === 0) {- toast.update(uploadToast.id, {+ toast.add({title: '批量上传失败',description: '所有文件验证失败',color: 'error',@@ -634,63 +644,66 @@ const handleUpload = async () => {return}- // 并发上传,但限制并发数量以避免资源竞争- const CONCURRENT_LIMIT = 3 // 限制同时上传的文件数量- const uploadPromises: Promise<void>[] = []-- for (let i = 0; i < validFiles.length; i += CONCURRENT_LIMIT) {- const batch = validFiles.slice(i, i + CONCURRENT_LIMIT)-- const batchPromises = batch.map(async (file) => {- try {- await uploadImage(file)- successCount++- } catch (error: any) {- errorCount++- errors.push(`${file.name}: ${error.message || '上传失败'}`)- console.error('上传错误:', error)- }- })+ // 立即为所有有效文件创建队列条目,状态为 waiting+ for (const file of validFiles) {+ const fileId = fileIdMapping.get(file)!+ const uploadingFile: UploadingFile = {+ file,+ fileName: file.name,+ fileId,+ status: 'waiting',+ canAbort: false,+ }+ uploadingFiles.value.set(fileId, uploadingFile)+ }- uploadPromises.push(...batchPromises)+ // 触发队列更新+ uploadingFiles.value = new Map(uploadingFiles.value)- // 等待当前批次完成再处理下一批次- await Promise.allSettled(batchPromises)+ // 动态并发上传,始终保持 CONCURRENT_LIMIT 个文件在上传+ const CONCURRENT_LIMIT = 3 // 限制同时上传的文件数量- // 更新进度- const processed = Math.min(i + CONCURRENT_LIMIT, validFiles.length)- toast.update(uploadToast.id, {- title: '批量上传进行中',- description: `已处理 ${processed}/${validFiles.length} 个文件`,- color: 'info',- })+ // 创建文件队列+ const fileQueue = [...validFiles]+ const activeUploads = new Set<Promise<void>>()++ // 启动上传任务的函数+ const startUpload = async (file: File): Promise<void> => {+ const fileId = fileIdMapping.get(file)!+ try {+ await uploadImage(file, fileId)+ } catch (error: any) {+ errors.push(`${file.name}: ${error.message || '上传失败'}`)+ console.error('上传错误:', error)+ }}- // 等待所有上传完成- await Promise.allSettled(uploadPromises)+ // 处理队列的函数+ const processQueue = async (): Promise<void> => {+ while (fileQueue.length > 0 || activeUploads.size > 0) {+ // 如果当前活跃上传数量小于限制,且队列中还有文件,则启动新的上传+ while (activeUploads.size < CONCURRENT_LIMIT && fileQueue.length > 0) {+ const file = fileQueue.shift()!+ const uploadPromise = startUpload(file)- // 显示最终结果- if (errorCount === 0) {- toast.update(uploadToast.id, {- title: '批量上传成功',- description: `成功上传 ${successCount} 个文件`,- color: 'success',- })- } else if (successCount === 0) {- toast.update(uploadToast.id, {- title: '批量上传失败',- description: `所有 ${errorCount} 个文件上传失败`,- color: 'error',- })- } else {- toast.update(uploadToast.id, {- title: '批量上传部分成功',- description: `成功: ${successCount}, 失败: ${errorCount}`,- color: 'warning',- })+ activeUploads.add(uploadPromise)++ // 当上传完成时,从活跃集合中移除+ uploadPromise.finally(() => {+ activeUploads.delete(uploadPromise)+ })+ }++ // 如果有活跃的上传,等待至少一个完成+ if (activeUploads.size > 0) {+ await Promise.race(activeUploads)+ }+ }}- // 如果有错误,显示详细错误信息+ // 开始处理队列+ await processQueue()+if (errors.length > 0) {console.error('批量上传错误详情:', errors)}@@ -944,7 +957,7 @@ onUnmounted(() => {<template><div class="flex flex-col gap-3 sm:gap-4 h-full p-3 sm:p-4"><!-- 上传队列容器 - 使用新的浮动组件 -->- <UploadQueueContainer+ <UploadQueuePanel:uploading-files="uploadingFiles"@remove-file="removeUploadingFile"@clear-completed="clearCompletedUploads"