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