feat(web-admin): add photoUrls types and pl-photo helpers
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
479851ba4c
commit
e2f087e6b9
2 files changed
+21
No files matched your search
@@ -0,0 +1,17 @@
|
||||
import { normalizeAttachmentUrls } from '@/utils/download-attachment'
|
||||
|
||||
/** 取逗号分隔附件中的第一张 URL(相对或绝对) */
|
||||
export function firstPhotoUrl(raw?: string | null): string {
|
||||
const normalized = normalizeAttachmentUrls(raw)
|
||||
if (!normalized) return ''
|
||||
return normalized.split(',').map((s) => s.trim()).filter(Boolean)[0] || ''
|
||||
}
|
||||
|
||||
/** 拼 MinIO 完整访问地址(与 AttachmentUploadField 一致) */
|
||||
export function resolvePhotoDisplayUrl(url?: string | null): string {
|
||||
const trimmed = String(url || '').trim()
|
||||
if (!trimmed) return ''
|
||||
if (/^https?:\/\//i.test(trimmed)) return trimmed
|
||||
const base = String(import.meta.env.VITE_MINIO_BASE_URL || '').replace(/\/$/, '')
|
||||
return base ? `${base}/${trimmed.replace(/^\//, '')}` : trimmed
|
||||
}
|
||||
Reference in new issue
Block a user