This commit is contained in:
2026-10-27 23:26:21 +08:00
parent 0699995c16
commit feaf90bb78
10 changed files with 476 additions and 2 deletions
+53
View File
@@ -59,6 +59,59 @@ export const miniApps: MockMiniApp[] = Array.from({ length: 12 }, (_, index) =>
}
})
export interface MockFile {
id: number
storage_key: string
filename: string
origin_name: string
mime_type: string
ext: string
size: number
uploader_type: 'admin' | 'ma'
uploader_id: number
url: string
created_at: string
}
const MIME_BY_EXT: Record<string, string> = {
png: 'image/png',
jpg: 'image/jpeg',
jpeg: 'image/jpeg',
gif: 'image/gif',
pdf: 'application/pdf',
docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
txt: 'text/plain',
}
const MOCK_FILE_SAMPLES = [
{ name: '产品截图.png', ext: 'png', size: 245_000 },
{ name: '用户头像.jpg', ext: 'jpg', size: 88_400 },
{ name: '操作手册.pdf', ext: 'pdf', size: 1_280_000 },
{ name: '数据报表.xlsx', ext: 'xlsx', size: 56_200 },
{ name: '说明文档.docx', ext: 'docx', size: 33_100 },
{ name: '日志备份.txt', ext: 'txt', size: 12_800 },
]
export const files: MockFile[] = Array.from({ length: 18 }, (_, index) => {
const id = index + 1
const sample = MOCK_FILE_SAMPLES[index % MOCK_FILE_SAMPLES.length]
const rand = Math.random().toString(36).slice(2, 10)
return {
id,
storage_key: `2026/10/27/${rand}.${sample.ext}`,
filename: `${rand}.${sample.ext}`,
origin_name: sample.name,
mime_type: MIME_BY_EXT[sample.ext] ?? 'application/octet-stream',
ext: sample.ext,
size: sample.size + (id % 7) * 1024,
uploader_type: id % 3 === 0 ? 'ma' : 'admin',
uploader_id: (id % 3) + 1,
url: `/files/static/2026/10/27/${rand}.${sample.ext}`,
created_at: new Date(Date.now() - id * 3_600_000).toISOString().slice(0, 19).replace('T', ' '),
}
})
export const menuRoutes = [
{
path: '/system',