task-266/267(admin.html观感对齐): 店铺数据任务改每店铺卡片(单文件下载/删除/批量/合计)+筛选权限对齐
This commit is contained in:
@@ -9,6 +9,22 @@ export interface ShopDataDownloadJob {
|
||||
errorCount?: number
|
||||
}
|
||||
|
||||
/** 从 Content-Disposition 解析单文件下载名(rfc5987 优先),失败回默认名。 */
|
||||
export function shopDataFilenameFromDisposition(disposition: string | undefined, fallback: string): string {
|
||||
const text = typeof disposition === 'string' ? disposition : ''
|
||||
const encoded = /filename\*=UTF-8''([^;]+)/i.exec(text)
|
||||
if (encoded) {
|
||||
try {
|
||||
const decoded = decodeURIComponent(encoded[1])
|
||||
if (decoded.trim()) return decoded.trim()
|
||||
} catch {
|
||||
// 回退普通 filename
|
||||
}
|
||||
}
|
||||
const plain = /filename="?([^";]+)"?/i.exec(text)
|
||||
return plain && plain[1] ? plain[1].trim() : fallback
|
||||
}
|
||||
|
||||
function finitePositive(value: unknown): number | null {
|
||||
const number = typeof value === 'number' && Number.isFinite(value)
|
||||
? value
|
||||
|
||||
Reference in New Issue
Block a user