diff --git a/src/App.tsx b/src/App.tsx index 24d07b1..30616b0 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -81,7 +81,7 @@ function App() { }>} /> } /> } /> - } /> + }>} /> => api.get(`/admin-api/files?page=${page}&limit=20`), + }) + + const handleDelete = (file: any) => modal.confirm({ + title: '删除文件', content: `确定删除 ${file.filename}?`, okType: 'danger', + onOk: async () => { await api.delete(`/admin-api/files/${file.id}`); message.success('已删除'); qc.invalidateQueries({ queryKey: ['admin-files'] }) }, + }) + + 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: 'sizeBytes', width: 80, render: (v: number) => v ? (v / 1024).toFixed(1) + 'KB' : '-' }, + { title: '用途', dataIndex: 'purpose', width: 80, render: (v: string) => {v || '-'} }, + { title: '上传时间', dataIndex: 'createdAt', width: 150, render: (d: string) => dayjs(d).format('MM-DD HH:mm') }, + { title: '操作', width: 80, render: (_:any, r:any) => + + `共 ${t} 个` }} /> + + ) +}