+
已经到底啦~
)
diff --git a/components/home/MaterialCard.tsx b/components/home/MaterialCard.tsx
index 722168e..ec9c8c8 100644
--- a/components/home/MaterialCard.tsx
+++ b/components/home/MaterialCard.tsx
@@ -4,7 +4,7 @@ import React, { useRef, useEffect, useState } from 'react'
import Image from 'next/image'
import { format } from 'date-fns'
import AudioVisualizer from '../AudioVisualizer'
-import { getTaskDetailSourceTypeLabel, normalizeTaskDetailSourceType } from '@/lib/task-detail-source-type'
+import { getTaskDetailSourceTypeLabel } from '@/lib/task-detail-source-type'
import { getCertificateReportDisplayTitle } from '@/lib/certificate-report'
import { isVideoMaterialType } from '@/lib/video-material-types'
import {
@@ -92,49 +92,38 @@ interface MaterialCardProps {
showToast: (message: string, options?: { variant?: 'success' | 'error' }) => void
}
-// 根据素材类型获取角标背景颜色
-const getMaterialTypeBadgeColor = (materialType: string): string => {
- const isVideoType = isVideoMaterialType(materialType)
-
- if (materialType === '3D场景' || materialType === '3DMAX') {
- return 'bg-red-500'
- } else if (isVideoType) {
- return 'bg-blue-600'
- } else if (materialType === '音乐') {
- return 'bg-purple-600'
- } else if (materialType === 'C4D模型') {
- return 'bg-blue-500'
- } else if (materialType === '详情模板' || materialType === '矢量文件') {
- return 'bg-amber-500'
- } else {
- return 'bg-gray-700'
- }
-}
+const OVERLAY_CHIP_CLASS = 'bg-white/92 text-[#1a1c1d] border border-[#e7e8ea] px-2 py-1 rounded-[8px] text-xs font-medium'
-// 格式化文件大小
-const formatFileSize = (bytes: string | number): string => {
- const size = typeof bytes === 'string' ? parseInt(bytes) : bytes
- if (size === 0) return '未知'
+function formatFileSize(bytes: string | number): string {
+ const size = typeof bytes === 'string' ? Number.parseInt(bytes, 10) : bytes
+ if (!size || Number.isNaN(size) || size <= 0) return ''
const units = ['B', 'KB', 'MB', 'GB']
- const i = Math.floor(Math.log(size) / Math.log(1024))
- return `${(size / Math.pow(1024, i)).toFixed(2)} ${units[i]}`
+ const unitIndex = Math.min(Math.floor(Math.log(size) / Math.log(1024)), units.length - 1)
+ return `${(size / Math.pow(1024, unitIndex)).toFixed(unitIndex === 0 ? 0 : 2)} ${units[unitIndex]}`
}
-const getTaskDetailSourceBadgeClassName = (value?: string | null): string => {
- const normalized = normalizeTaskDetailSourceType(value)
- if (normalized === '实拍') {
- return 'bg-emerald-100 dark:bg-emerald-900/30 text-emerald-700 dark:text-emerald-300'
- }
+function DownloadGlyph() {
+ return (
+
+ )
+}
- if (normalized === '渲染') {
- return 'bg-violet-100 dark:bg-violet-900/30 text-violet-700 dark:text-violet-300'
- }
+function ShareGlyph() {
+ return (
+
+ )
+}
- if (normalized === 'AI') {
- return 'bg-cyan-100 dark:bg-cyan-900/30 text-cyan-700 dark:text-cyan-300'
- }
-
- return 'bg-slate-100 dark:bg-slate-700/60 text-slate-700 dark:text-slate-300'
+function HeartGlyph({ filled }: { filled: boolean }) {
+ return (
+
+ )
}
export default function MaterialCard({
@@ -148,7 +137,6 @@ export default function MaterialCard({
audioRef,
downloadingId,
downloadProgress,
- themeColor,
onAudioPlay,
onDownload,
onLike,
@@ -306,69 +294,80 @@ export default function MaterialCard({
progressValue = Math.max(28, Math.min(35 + 55 * Math.min(0.95, 0) + (attempts > 1 ? 5 : 0), 92))
label = `转码中${stageName ? ` · ${stageName}` : ''}${attempts > 1 ? ` · 第${attempts}次` : ''}${waitingCount > 0 ? ` · 队列余${waitingCount}` : ''} · ${processingCount}/${maxConcurrent}并发`
}
- bgColor = 'bg-blue-600'
+ bgColor = 'bg-[#1a1c1d]'
} else if (status === 'processing') {
label = `转码中${attempts > 1 ? ` · 第${attempts}次` : ''}`
progressValue = 15
- bgColor = 'bg-blue-600'
+ bgColor = 'bg-[#1a1c1d]'
} else if (status === 'pending') {
label = `等待中${attempts > 1 ? ` · 第${attempts}次` : ''}`
progressValue = 5
- bgColor = 'bg-gray-600'
+ bgColor = 'bg-[#86898e]'
} else if (queueIndex !== null && queueIndex !== undefined) {
const processingCount = processingIds.length
label = `排队中 · ${queueIndex}/${queueTotal} · ${processingCount}/${maxConcurrent}执行中`
progressValue = 8
- bgColor = 'bg-amber-600'
+ bgColor = 'bg-[#6e79c8]'
} else {
label = status || '未知状态'
progressValue = 12
- bgColor = 'bg-gray-600'
+ bgColor = 'bg-[#86898e]'
}
return (
-
-
- {label}
- {status === 'failed' && !material.videoPreviewClipUrl && !material.videoPreview540Url && (
-
- )}
-
+ <>
+ {status !== 'failed' && (
+
+
+ {label}
+
+
+ )}
+
+ {label}
+ {status === 'failed' && !material.videoPreviewClipUrl && !material.videoPreview540Url && (
+
+ )}
+
+ className="h-1.5 w-full overflow-hidden rounded-[8px] bg-[#e7e8ea]"
+ role="progressbar"
+ aria-label={label}
+ aria-valuemin={0}
+ aria-valuemax={100}
+ aria-valuenow={progressValue}
+ >
+
+
-
+ >
)
}
+ const fileSizeLabel = formatFileSize(material.zipFileSize)
+
return (
-