This commit is contained in:
zlwu committed 2026-07-14 13:55:11 +08:00
1 parent f90726927e
commit 6eea13370c
103 files changed
+38401 -32231

No files matched your search

@@ -0,0 +1,28 @@
import { downloadAttachmentFile } from '@/utils/download-attachment'
const minioBaseUrl = (import.meta.env.VITE_MINIO_BASE_URL || '').replace(/\/$/, '')
export function attachmentFullUrl(url: string) {
const u = String(url || '').trim()
if (!u) return ''
if (/^https?:\/\//i.test(u)) return u
return minioBaseUrl ? `${minioBaseUrl}/${u.replace(/^\//, '')}` : u
}
export function useAttachmentActions() {
function handleAttachmentPreview(file: Record<string, unknown>) {
const url = attachmentFullUrl(String(file.fileUrl || ''))
if (url) window.open(url, '_blank')
}
function handleAttachmentDownload(file: Record<string, unknown>) {
downloadAttachmentFile(file, {
fullFileUrl: (u: string) => attachmentFullUrl(u)
})
}
return {
handleAttachmentPreview,
handleAttachmentDownload
}
}