update image thumb

This commit is contained in:
Timi
2026-08-22 01:27:45 +08:00
parent e2af521996
commit 3b56de2430
16 changed files with 69 additions and 38 deletions
+21
View File
@@ -0,0 +1,21 @@
import { AttachmentAPI } from "timi-web";
/**
* 获取附件读取地址。
*
* @param id 附件 ID
* @param thumbnailSize 缩略图尺寸,不传时返回原图地址
*/
export function getAttachmentReadURL(id: string, thumbnailSize?: number): string {
const url = AttachmentAPI.getReadURL(id);
if (thumbnailSize === undefined) {
return url;
}
const params = new URLSearchParams({
thumbWidth: String(thumbnailSize),
thumbHeight: String(thumbnailSize)
});
const separator = url.includes("?") ? "&" : "?";
return `${url}${separator}${params.toString()}`;
}