✨ feat(frontend): 补齐本地文件免上传分享入口

This commit is contained in:
orion committed 2026-09-18 10:56:46 +08:00
1 parent 7f9aaf8a4d
commit 638a56d894
16 files changed
+402

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
const labels: Record<string, string> = { day: '按天', hour: '按小时', minute: '按分钟', count: '按取件次数(最长 1 天)', forever: '永久有效' }
export function expirationChoices(styles: string[]) {
return [...new Set(styles)].filter(style => Object.prototype.hasOwnProperty.call(labels, style)).map(value => ({ value, label: labels[value] }))
}
export function localBreadcrumbs(path: string) {
const parts = path ? path.split('/') : []
return [{ name: '本地文件', path: '' }, ...parts.map((name, index) => ({ name, path: parts.slice(0, index + 1).join('/') }))]
}
export function buildLocalShareRequest(filename: string, style: string, value: string, allowed: string[]) {
if (!filename) throw new Error('请先选择文件')
if (!allowed.includes(style) || !Object.prototype.hasOwnProperty.call(labels, style)) throw new Error('请选择允许的有效期方式')
const amount = style === 'forever' ? 1 : Number(value)
if (!Number.isSafeInteger(amount) || amount < 1 || amount > 1_000_000) throw new Error('请输入 1 到 1000000 的整数')
return { filename, expire_style: style, expire_value: amount }
}