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) { const url = attachmentFullUrl(String(file.fileUrl || '')) if (url) window.open(url, '_blank') } function handleAttachmentDownload(file: Record) { downloadAttachmentFile(file, { fullFileUrl: (u: string) => attachmentFullUrl(u) }) } return { handleAttachmentPreview, handleAttachmentDownload } }