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

@ -1,7 +1,7 @@
// components/travel-location-popup/index.ts
import { TravelLocation, TravelLocationTypeLabel, TravelLocationTypeIcon } from "../../types/Travel";
import { TravelLocationApi } from "../../api/TravelLocationApi";
import { ImageMetadata, MediaAttachType } from "../../types/Attachment";
import { MediaAttachType, PreviewImageMetadata } from "../../types/Attachment";
import { MediaItem, MediaItemType } from "../../types/UI";
import config from "../../config/index";
import Toolkit from "../../utils/Toolkit";
@ -43,12 +43,11 @@ Component({
if (0 < thumbItems.length) {
const mediaItems: MediaItem[] = thumbItems.map((thumbItem, index) => {
const metadata = thumbItem.metadata as ImageMetadata;
const ext = typeof thumbItem.ext === "string" ? JSON.parse(thumbItem.ext) : thumbItem.ext;
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}`;
return {
type: ext.isVideo ? MediaItemType.VIDEO : MediaItemType.IMAGE,
type: metadata.isVideo ? MediaItemType.VIDEO : MediaItemType.IMAGE,
thumbURL,
sourceURL,
size: thumbItem.size || 0,