From e2f087e6b95fba0c1df6701bb281b2ba8caff1b4 Mon Sep 17 00:00:00 2001 From: zlwu <704541015@qq.com> Date: Sun, 2 Aug 2026 10:31:22 +0800 Subject: [PATCH] feat(web-admin): add photoUrls types and pl-photo helpers Co-authored-by: Cursor --- web-admin/src/api/pl/index.ts | 4 ++++ web-admin/src/utils/pl-photo.ts | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 web-admin/src/utils/pl-photo.ts diff --git a/web-admin/src/api/pl/index.ts b/web-admin/src/api/pl/index.ts index cbded2a98..5014100c6 100644 --- a/web-admin/src/api/pl/index.ts +++ b/web-admin/src/api/pl/index.ts @@ -100,6 +100,7 @@ export interface Vehicle { loadCapacity?: number vehicleStatus: string remark?: string + photoUrls?: string certList?: CertRead[] createTime: string } @@ -118,6 +119,7 @@ export interface VehiclePayload { loadCapacity?: number | null vehicleStatus: string remark?: string + photoUrls?: string personnelList?: VehiclePersonnelRow[] certList?: CertRow[] } @@ -153,6 +155,7 @@ export interface Personnel { personnelAffiliation: string status: string remark?: string + photoUrls?: string nearestExpireDate?: string certList?: CertRead[] createTime: string @@ -171,6 +174,7 @@ export interface PersonnelPayload { personnelAffiliation: string status: string remark?: string + photoUrls?: string certList?: CertRow[] } diff --git a/web-admin/src/utils/pl-photo.ts b/web-admin/src/utils/pl-photo.ts new file mode 100644 index 000000000..877240e7f --- /dev/null +++ b/web-admin/src/utils/pl-photo.ts @@ -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 +}