interface RawData { uri: string; exif?: Record; location?: { latitude?: string | number; }; [key: string]: any; // Allow any additional properties } export function transformData(data: RawData): Omit { const result = { ...data }; if (result.exif) { const newExif: Record = {}; for (const key in result.exif) { const value: unknown = result.exif[key]; // 普通对象:{Exif}, {TIFF}, {XMP} 等 if (typeof value === 'object' && value !== null && !Array.isArray(value)) { const obj = value as Record; if (key === '{GPS}') { // 处理 GPS 字段:所有子字段加前缀 "GPS" for (const subKey in obj) { const newKey = 'GPS' + subKey; // 所有字段都加前缀 newExif[newKey] = obj[subKey]; } } else { // 其它嵌套对象直接展开字段 for (const subKey in obj) { newExif[subKey] = obj[subKey]; } } } else { // 非对象字段保留原样 newExif[key] = value; } } // 合并展开的 exif 数据并移除 exif 属性 const { exif, ...rest } = result; return { ...rest, ...newExif }; } // 如果没有 exif 数据,直接返回原数据(排除 exif 属性) const { exif, ...rest } = result; return rest; }