From ea61034a1fffc586466db77c10a124a0f5e260c9 Mon Sep 17 00:00:00 2001 From: Lan Date: Wed, 3 Jun 2026 19:41:08 +0800 Subject: [PATCH] fix: resolve frontend lint errors --- src/composables/useAdminFiles.ts | 4 ++-- src/utils/download-action.ts | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/composables/useAdminFiles.ts b/src/composables/useAdminFiles.ts index 91a3b1e..d9d2ba3 100644 --- a/src/composables/useAdminFiles.ts +++ b/src/composables/useAdminFiles.ts @@ -632,13 +632,13 @@ export function useAdminFiles() { const storage = detail.storage const expiredAt = policy?.expiredAt ?? policy?.expired_at ?? file.expired_at ?? null const expiredCount = policy?.expiredCount ?? policy?.expired_count ?? file.expired_count ?? null + const prefixedName = `${file.prefix || ''}${file.suffix || ''}` const displayName = detail.displayName ?? detail.display_name ?? detail.filename ?? file.name ?? - `${file.prefix}${file.suffix}` ?? - file.code + (prefixedName || file.code) const normalizedFile: FileListItem = { ...file, name: displayName, diff --git a/src/utils/download-action.ts b/src/utils/download-action.ts index 3e14409..b3a4aa5 100644 --- a/src/utils/download-action.ts +++ b/src/utils/download-action.ts @@ -2,6 +2,11 @@ import { saveAs } from 'file-saver' import type { AdminFileViewItem, ApiResponse, ReceivedFileRecord } from '@/types' import { buildDownloadUrl } from '@/utils/share-url' +const unsafeFilenamePattern = new RegExp( + `[\\\\/:*?"<>|${String.fromCharCode(0)}-${String.fromCharCode(31)}]`, + 'g' +) + export function downloadReceivedRecord(record: ReceivedFileRecord): void { if (record.downloadUrl) { window.open(buildDownloadUrl(record.downloadUrl), '_blank') @@ -16,7 +21,7 @@ export function downloadReceivedRecord(record: ReceivedFileRecord): void { export const getSafeFilename = (name: string) => name - .replace(/[\\/:*?"<>|\x00-\x1F]/g, '_') + .replace(unsafeFilenamePattern, '_') .replace(/\s+/g, ' ') .trim() .slice(0, 180) || 'download'