fix: add Chinese mime type + purpose labels for FilesAdmin
All checks were successful
Deploy Admin Frontend / build-and-deploy (push) Successful in 9s

This commit is contained in:
wangdl 2026-06-19 13:15:23 +08:00
parent e07f09002d
commit c758a2cec8

View File

@ -5,6 +5,18 @@ import { ReloadOutlined, DeleteOutlined, FileOutlined } from '@ant-design/icons'
import { api } from '@/services/http-client'
import dayjs from 'dayjs'
const mimeLabels: Record<string, string> = {
'text/plain': '文本', 'text/markdown': 'Markdown', 'text/html': 'HTML',
'application/pdf': 'PDF', 'application/msword': 'Word', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': 'Word',
'application/vnd.ms-excel': 'Excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': 'Excel',
'application/vnd.ms-powerpoint': 'PPT', 'application/vnd.openxmlformats-officedocument.presentationml.presentation': 'PPT',
'application/epub+zip': 'EPUB', 'application/zip': 'ZIP',
'image/jpeg': '图片', 'image/png': '图片', 'image/gif': '图片', 'image/webp': '图片', 'image/svg+xml': '图片',
}
const purposeLabels: Record<string, string> = {
avatar: '头像', cover: '封面', import: '导入', export: '导出', attachment: '附件', file: '文件', image: '图片',
}
const { Title } = Typography
export default function FilesAdminPage() {
@ -25,9 +37,9 @@ export default function FilesAdminPage() {
const cols = [
{ title: '文件名', dataIndex: 'filename', width: 200, ellipsis: true },
{ title: '用户', width: 120, render: (_:any, r:any) => r.user?.nickname || r.user?.email || '-' },
{ title: '类型', dataIndex: 'mimeType', width: 100, ellipsis: true },
{ title: '类型', dataIndex: 'mimeType', width: 100, ellipsis: true, render: (v: string) => mimeLabels[v] || v?.split('/').pop() || '-' },
{ title: '大小', dataIndex: 'sizeBytes', width: 80, render: (v: number) => v ? (v / 1024).toFixed(1) + 'KB' : '-' },
{ title: '用途', dataIndex: 'purpose', width: 80, render: (v: string) => <Tag>{v || '-'}</Tag> },
{ title: '用途', dataIndex: 'purpose', width: 80, render: (v: string) => <Tag>{purposeLabels[v] || v || '-'}</Tag> },
{ title: '上传时间', dataIndex: 'createdAt', width: 150, render: (d: string) => dayjs(d).format('MM-DD HH:mm') },
{ title: '操作', width: 80, render: (_:any, r:any) => <Button type="link" size="small" danger icon={<DeleteOutlined />} onClick={() => handleDelete(r)} /> },
]