/** 只允许 HTTP(S) 与后端 /storage 路径;生产环境绝对 API 地址使用其源站。 */ export function mediaAssetUrl(value: string): string | null { const raw = value.trim() try { if (raw.startsWith('/storage/') && !raw.includes('\\')) { const api = import.meta.env.VITE_API_BASE_URL || '/api' const origin = /^https?:\/\//i.test(api) ? new URL(api).origin : window.location.origin const url = new URL(raw, origin) return url.pathname.startsWith('/storage/') ? url.href : null } const url = new URL(raw) return ['http:', 'https:'].includes(url.protocol) ? url.href : null } catch { return null } } /** 图片组件保留语义化入口,底层与视频共用同一套资源地址校验。 */ export function referenceImageUrl(value: string): string | null { return mediaAssetUrl(value) }