merge Attachment metadata/ext

This commit is contained in:
Timi
2026-01-04 17:41:02 +08:00
parent f4232e8752
commit 2c6478c729
10 changed files with 41 additions and 54 deletions

View File

@ -3,7 +3,7 @@
import config from "../../../config/index";
import { TravelLocationApi } from "../../../api/TravelLocationApi";
import { TravelLocation, TravelLocationTypeIcon, TravelLocationTypeLabel } from "../../../types/Travel";
import { MediaAttachExt, MediaAttachType } from "../../../types/Attachment";
import { MediaAttachType, PreviewImageMetadata } from "../../../types/Attachment";
import { MapMarker, MediaItem, MediaItemType } from "../../../types/UI";
import Toolkit from "../../../utils/Toolkit";
@ -95,18 +95,18 @@ Page({
thumbItems.forEach((thumbItem) => {
try {
const ext = JSON.parse(thumbItem.ext!.toString()) as MediaAttachExt;
const metadata = (typeof thumbItem.metadata === "string" ? JSON.parse(thumbItem.metadata) : thumbItem.metadata) as PreviewImageMetadata;
const thumbURL = `${config.url}/attachment/read/${thumbItem.mongoId}`;
const sourceURL = `${config.url}/attachment/read/${ext.sourceMongoId}`;
const sourceURL = `${config.url}/attachment/read/${metadata.sourceMongoId}`;
mediaItems.push({
type: ext.isVideo ? MediaItemType.VIDEO : MediaItemType.IMAGE,
type: metadata.isVideo ? MediaItemType.VIDEO : MediaItemType.IMAGE,
thumbURL,
sourceURL,
size: thumbItem.size || 0,
attachmentId: thumbItem.id!
});
} catch (parseError) {
console.warn("解析附件扩展信息失败", parseError);
console.warn("解析附件元数据失败", parseError);
}
});