diff --git a/src/pages/FilesAdmin.tsx b/src/pages/FilesAdmin.tsx index 85876df..c6bff0c 100644 --- a/src/pages/FilesAdmin.tsx +++ b/src/pages/FilesAdmin.tsx @@ -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 = { + '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 = { + 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) => {v || '-'} }, + { title: '用途', dataIndex: 'purpose', width: 80, render: (v: string) => {purposeLabels[v] || v || '-'} }, { title: '上传时间', dataIndex: 'createdAt', width: 150, render: (d: string) => dayjs(d).format('MM-DD HH:mm') }, { title: '操作', width: 80, render: (_:any, r:any) =>