Files
gaoYuJournal/miniprogram/api/MomentApi.ts
2025-12-17 16:56:33 +08:00

70 lines
1.4 KiB
TypeScript

import { Network } from "../utils/Network";
import { Attachment } from "../types/Attachment";
/**
* Moment 瞬间 API
*
* 管理临时照片/视频上传、归档到日记等操作
*/
export class MomentApi {
/**
* 获取 moment 列表
*/
static getList(): Promise<Attachment[]> {
return Network.post<Attachment[]>("/journal/moment/list");
}
/**
* MD5 查重过滤
*
* @param md5s - MD5 值数组
* @returns 未重复的 MD5 数组
*/
static filterByMD5(md5s: string[]): Promise<string[]> {
return Network.post<string[]>("/journal/moment/filter", md5s);
}
/**
* 创建 moment 附件
*
* @param tempFileIds - 临时文件 ID 数组
* @returns 创建的附件列表
*/
static create(tempFileIds: string[]): Promise<Attachment[]> {
return Network.post<Attachment[]>("/journal/moment/create", tempFileIds, {
showLoading: true,
loadingText: "正在保存.."
});
}
/**
* 归档 moments 到日记
*
* @param data - 归档数据
*/
static archive(data: {
id?: number;
type: string;
idea: string;
lat?: number;
lng?: number;
location?: string;
pusher: string;
thumbIds: number[];
}): Promise<void> {
return Network.post<void>("/journal/moment/archive", data, {
showLoading: true,
loadingText: "正在归档.."
});
}
/**
* 删除 moments
*
* @param ids - 附件 ID 数组
*/
static delete(ids: number[]): Promise<void> {
return Network.post<void>("/journal/moment/delete", ids);
}
}