merge Attachment metadata/ext
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
import { Journal } from "../../types/Journal";
|
||||
import config from "../../config/index";
|
||||
import Toolkit from "../../utils/Toolkit";
|
||||
import { ImageMetadata, MediaAttachExt, MediaAttachType } from "../../types/Attachment";
|
||||
import { MediaAttachType, PreviewImageMetadata } from "../../types/Attachment";
|
||||
import { MediaItem, MediaItemType } from "../../types/UI";
|
||||
import Time from "../../utils/Time";
|
||||
import { JournalApi } from "../../api/JournalApi";
|
||||
@ -47,12 +47,11 @@ Component({
|
||||
return;
|
||||
}
|
||||
const mediaItems: MediaItem[] = thumbItems.map((thumbItem, index) => {
|
||||
const metadata = thumbItem.metadata as ImageMetadata;
|
||||
const ext = thumbItem.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}`;
|
||||
return {
|
||||
type: ext.isVideo ? MediaItemType.VIDEO : MediaItemType.IMAGE,
|
||||
type: metadata.isVideo ? MediaItemType.VIDEO : MediaItemType.IMAGE,
|
||||
thumbURL,
|
||||
sourceURL,
|
||||
size: thumbItem.size || 0,
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
const envArgs = {
|
||||
develop: {
|
||||
url: "http://localhost:8091"
|
||||
// url: "https://api.imyeyu.dev"
|
||||
// url: "https://api.imyeyu.com"
|
||||
// url: "http://192.168.3.123:8091"
|
||||
// url: "http://192.168.3.137:8091"
|
||||
// url: "http://192.168.3.173:8091"
|
||||
url: "http://192.168.3.174:8091"
|
||||
// url: "http://192.168.3.174:8091"
|
||||
},
|
||||
trial: {
|
||||
url: "https://api.imyeyu.com"
|
||||
|
||||
@ -5,7 +5,7 @@ import Toolkit from "../../../utils/Toolkit";
|
||||
import config from "../../../config/index";
|
||||
import { Location, MediaItem, MediaItemType, WechatMediaItem } from "../../../types/UI";
|
||||
import { JournalType } from "../../../types/Journal";
|
||||
import { MediaAttachExt, MediaAttachType } from "../../../types/Attachment";
|
||||
import { MediaAttachType, PreviewImageMetadata } from "../../../types/Attachment";
|
||||
import IOSize, { Unit } from "../../../utils/IOSize";
|
||||
import { JournalApi } from "../../../api/JournalApi";
|
||||
|
||||
@ -156,11 +156,11 @@ Page({
|
||||
const thumbItems = items.filter((item) => item.attachType === MediaAttachType.THUMB);
|
||||
|
||||
const mediaList: MediaItem[] = thumbItems.map((thumbItem) => {
|
||||
const ext = thumbItem.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}`;
|
||||
return {
|
||||
type: ext.isVideo ? MediaItemType.VIDEO : MediaItemType.IMAGE,
|
||||
type: metadata.isVideo ? MediaItemType.VIDEO : MediaItemType.IMAGE,
|
||||
thumbURL,
|
||||
sourceURL,
|
||||
size: thumbItem.size || 0,
|
||||
|
||||
@ -6,7 +6,7 @@ import Events from "../../../utils/Events";
|
||||
import Toolkit from "../../../utils/Toolkit";
|
||||
import { Journal, JournalPage, JournalPageType } from "../../../types/Journal";
|
||||
import { OrderType } from "../../../types/Model";
|
||||
import { ImageMetadata, MediaAttachExt } from "../../../types/Attachment";
|
||||
import { PreviewImageMetadata } from "../../../types/Attachment";
|
||||
import { MediaItem, MediaItemType } from "../../../types/UI";
|
||||
import { JournalApi } from "../../../api/JournalApi";
|
||||
|
||||
@ -163,12 +163,11 @@ Page({
|
||||
}
|
||||
list.forEach(journal => {
|
||||
const mediaItems = journal.items!.filter((item) => item.attachType === "THUMB").map((thumbItem, index) => {
|
||||
const metadata = thumbItem.metadata as ImageMetadata;
|
||||
const ext = thumbItem.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}`;
|
||||
return {
|
||||
type: ext.isVideo ? MediaItemType.VIDEO : MediaItemType.IMAGE,
|
||||
type: metadata.isVideo ? MediaItemType.VIDEO : MediaItemType.IMAGE,
|
||||
thumbURL,
|
||||
sourceURL,
|
||||
size: thumbItem.size || 0,
|
||||
|
||||
@ -5,7 +5,7 @@ import IOSize, { Unit } from "../../../utils/IOSize";
|
||||
import Time from "../../../utils/Time";
|
||||
import Toolkit from "../../../utils/Toolkit";
|
||||
import { Location, MediaItemType } from "../../../types/UI";
|
||||
import { MediaAttachExt } from "../../../types/Attachment";
|
||||
import { PreviewImageMetadata } from "../../../types/Attachment";
|
||||
import { MomentApi } from "../../../api/MomentApi";
|
||||
import { JournalApi } from "../../../api/JournalApi";
|
||||
import { Network } from "../../../utils/Network";
|
||||
@ -134,12 +134,12 @@ Page({
|
||||
}
|
||||
this.setData({
|
||||
list: list.map((item: any) => {
|
||||
const ext = JSON.parse(item.ext) as MediaAttachExt;
|
||||
const metadata = (typeof item.metadata === "string" ? JSON.parse(item.metadata) : item.metadata) as PreviewImageMetadata;
|
||||
const thumbURL = `${config.url}/attachment/read/${item.mongoId}`;
|
||||
const sourceURL = `${config.url}/attachment/read/${ext.sourceMongoId}`;
|
||||
const sourceURL = `${config.url}/attachment/read/${metadata.sourceMongoId}`;
|
||||
return {
|
||||
id: item.id,
|
||||
type: ext.isImage ? MediaItemType.IMAGE : MediaItemType.VIDEO,
|
||||
type: metadata.isImage ? MediaItemType.IMAGE : MediaItemType.VIDEO,
|
||||
thumbURL,
|
||||
sourceURL,
|
||||
checked: false
|
||||
@ -259,12 +259,12 @@ Page({
|
||||
const list = await MomentApi.create(tempFileIds);
|
||||
wx.showToast({ title: "上传成功", icon: "success" });
|
||||
const added = list.map((item: any) => {
|
||||
const ext = JSON.parse(item.ext) as MediaAttachExt;
|
||||
const metadata = (typeof item.metadata === "string" ? JSON.parse(item.metadata) : item.metadata) as PreviewImageMetadata;
|
||||
const thumbURL = `${config.url}/attachment/read/${item.mongoId}`;
|
||||
const sourceURL = `${config.url}/attachment/read/${ext.sourceMongoId}`;
|
||||
const sourceURL = `${config.url}/attachment/read/${metadata.sourceMongoId}`;
|
||||
return {
|
||||
id: item.id,
|
||||
type: ext.isImage ? MediaItemType.IMAGE : MediaItemType.VIDEO,
|
||||
type: metadata.isImage ? MediaItemType.IMAGE : MediaItemType.VIDEO,
|
||||
thumbURL,
|
||||
sourceURL,
|
||||
checked: false
|
||||
|
||||
@ -6,7 +6,7 @@ import Events from "../../../utils/Events";
|
||||
import Toolkit from "../../../utils/Toolkit";
|
||||
import { Journal, JournalPage, JournalPageType } from "../../../types/Journal";
|
||||
import { OrderType, } from "../../../types/Model";
|
||||
import { ImageMetadata, MediaAttachExt } from "../../../types/Attachment";
|
||||
import { PreviewImageMetadata } from "../../../types/Attachment";
|
||||
import { MediaItem, MediaItemType } from "../../../types/UI";
|
||||
import { JournalApi } from "../../../api/JournalApi";
|
||||
|
||||
@ -92,12 +92,11 @@ Page({
|
||||
}
|
||||
list.forEach(journal => {
|
||||
const mediaItems = journal.items!.filter((item) => item.attachType === "THUMB").map((thumbItem, index) => {
|
||||
const metadata = thumbItem.metadata as ImageMetadata;
|
||||
const ext = thumbItem.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}`;
|
||||
return {
|
||||
type: ext.isVideo ? MediaItemType.VIDEO : MediaItemType.IMAGE,
|
||||
type: metadata.isVideo ? MediaItemType.VIDEO : MediaItemType.IMAGE,
|
||||
thumbURL,
|
||||
sourceURL,
|
||||
size: thumbItem.size || 0,
|
||||
|
||||
@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
import { Network, WechatMediaItem } from "../../../utils/Network";
|
||||
import { TravelLocationApi } from "../../../api/TravelLocationApi";
|
||||
import { TravelLocationType, TravelLocationTypeLabel } from "../../../types/Travel";
|
||||
import { MediaAttachExt, MediaAttachType } from "../../../types/Attachment";
|
||||
import { MediaAttachType, PreviewImageMetadata } from "../../../types/Attachment";
|
||||
import config from "../../../config/index";
|
||||
import { MediaItem, MediaItemType } from "../../../types/UI";
|
||||
|
||||
@ -161,11 +161,11 @@ Page({
|
||||
const thumbItems = items.filter((item) => item.attachType === MediaAttachType.THUMB);
|
||||
|
||||
const mediaList: MediaItem[] = thumbItems.map((thumbItem) => {
|
||||
const ext = thumbItem.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}`;
|
||||
return {
|
||||
type: ext.isVideo ? MediaItemType.VIDEO : MediaItemType.IMAGE,
|
||||
type: metadata.isVideo ? MediaItemType.VIDEO : MediaItemType.IMAGE,
|
||||
thumbURL,
|
||||
sourceURL,
|
||||
size: thumbItem.size || 0,
|
||||
|
||||
@ -17,7 +17,7 @@ export type Attachment = {
|
||||
|
||||
mimeType?: string;
|
||||
|
||||
metadata?: string | ImageMetadata;
|
||||
metadata?: string | ImageMetadata | PreviewImageMetadata;
|
||||
|
||||
/** 文件 MD5 */
|
||||
md5: string;
|
||||
@ -27,9 +27,6 @@ export type Attachment = {
|
||||
|
||||
/** 大小 */
|
||||
size: number;
|
||||
|
||||
/** 扩展数据 */
|
||||
ext?: string | MediaAttachExt;
|
||||
} & Model;
|
||||
|
||||
/** 媒体附件类型 */
|
||||
@ -52,8 +49,7 @@ export type ImageMetadata = {
|
||||
height: number;
|
||||
}
|
||||
|
||||
/** 媒体附件扩展数据 */
|
||||
export type MediaAttachExt = {
|
||||
export type PreviewImageMetadata = {
|
||||
|
||||
/** 原文件附件 ID */
|
||||
sourceId: number;
|
||||
@ -66,10 +62,4 @@ export type MediaAttachExt = {
|
||||
|
||||
/** true 为视频 */
|
||||
isVideo: boolean;
|
||||
|
||||
/** 原图宽度(像素) */
|
||||
width?: number;
|
||||
|
||||
/** 原图高度(像素) */
|
||||
height?: number;
|
||||
}
|
||||
} & ImageMetadata;
|
||||
|
||||
Reference in New Issue
Block a user