// 提取对象中的图片/文件ID数组(兼容多种字段名) export function getPhotosFromAny(obj: any, type: string): string[] { const candidates = [obj[type]] for (const c of candidates) { if (Array.isArray(c) && c.length > 0) { // 检查是否为对象数组,如果是则提取photo_name字段 if (typeof c[0] === 'object' && c[0] !== null) { const ids = c.map((item: any) => { const id = item?.photo_name || item?.id || item?.uid || item?.fileId || item?.value || item?.response?.id || item?.response?.fileId || item?.resourceId return id != null && id !== '' ? String(id) : null }).filter((id: string | null) => id !== null) return ids as string[] } // 如果是字符串数组,直接返回 return c as string[] } } return [] }