import { getOssListByIds } from '@/api/oss' export function isHttpUrl(value?: string) { return Boolean(value && /^https?:\/\//.test(value)) } export async function resolveOssUrlMap(rawIds: Array) { const map = new Map() const ossIds = rawIds .filter((id): id is string => Boolean(id && !isHttpUrl(id))) .map(String) if (!ossIds.length) return map try { const files = await getOssListByIds(ossIds) for (const file of files ?? []) { if (file.ossId && file.url) map.set(String(file.ossId), file.url) } } catch { // ignore } return map } export function pickMediaUrl(raw?: string, urlMap?: Map) { if (!raw) return undefined if (isHttpUrl(raw)) return raw return urlMap?.get(String(raw)) }