Fix: 修复 Meta 解析错误问题
This commit is contained in:
+4
-4
@@ -11,7 +11,7 @@ interface MediaItem {
|
||||
content: string;
|
||||
url: string;
|
||||
thumb_url: string;
|
||||
meta: string;
|
||||
meta: string | null;
|
||||
take_time: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
@@ -75,14 +75,14 @@ const fetchPhotos = async () => {
|
||||
const data = await response.json();
|
||||
// 处理图片 URL
|
||||
const nextPhotos = data.data.map((photo: MediaItem) => {
|
||||
const parsedMeta = JSON.parse(photo.meta);
|
||||
const parsedMeta: { COMPUTED: { Width: number; Height: number } } | null = photo.meta ? JSON.parse(photo.meta) : null;
|
||||
|
||||
return {
|
||||
...photo,
|
||||
url: getImageUrl(photo.url),
|
||||
thumb_url: getImageUrl(photo.thumb_url),
|
||||
width: parsedMeta.COMPUTED.Width,
|
||||
height: parsedMeta.COMPUTED.Height,
|
||||
width: parsedMeta?.COMPUTED.Width,
|
||||
height: parsedMeta?.COMPUTED.Height,
|
||||
};
|
||||
});
|
||||
photos.value = nextPhotos;
|
||||
|
||||
@@ -10,7 +10,7 @@ interface MediaItem {
|
||||
content: string;
|
||||
url: string;
|
||||
thumb_url: string;
|
||||
meta: string;
|
||||
meta: string | null;
|
||||
take_time: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
|
||||
Reference in New Issue
Block a user