diff --git a/packages/core/client/src/schema-component/antd/upload/Upload.tsx b/packages/core/client/src/schema-component/antd/upload/Upload.tsx index 6cc50e6527..57b00995d9 100644 --- a/packages/core/client/src/schema-component/antd/upload/Upload.tsx +++ b/packages/core/client/src/schema-component/antd/upload/Upload.tsx @@ -41,6 +41,9 @@ attachmentFileTypes.add({ return matchMimetype(file, 'image/*'); }, getThumbnailURL(file) { + if (file.preview) { + return file.preview; + } if (file.url) { return `${file.url}${file.thumbnailRule || ''}`; } diff --git a/packages/plugins/@nocobase/plugin-file-manager/src/server/FileModel.ts b/packages/plugins/@nocobase/plugin-file-manager/src/server/FileModel.ts index e955b8d64a..98586bff8f 100644 --- a/packages/plugins/@nocobase/plugin-file-manager/src/server/FileModel.ts +++ b/packages/plugins/@nocobase/plugin-file-manager/src/server/FileModel.ts @@ -8,6 +8,9 @@ */ import { Model } from '@nocobase/database'; +import { STORAGE_TYPE_ALI_OSS, STORAGE_TYPE_LOCAL, STORAGE_TYPE_S3, STORAGE_TYPE_TX_COS } from '../constants'; + +const currentStorage = [STORAGE_TYPE_LOCAL, STORAGE_TYPE_ALI_OSS, STORAGE_TYPE_S3, STORAGE_TYPE_TX_COS]; export class FileModel extends Model { public toJSON() { @@ -15,6 +18,10 @@ export class FileModel extends Model { const fileStorages = this.constructor['database']?.['_fileStorages']; if (json.storageId && fileStorages && fileStorages.has(json.storageId)) { const storage = fileStorages.get(json.storageId); + // 当前文件管理器内的存储类型拼接生成预览链接,其他文件存储自行处理 + if (currentStorage.includes(storage?.type) && storage?.options?.thumbnailRule) { + json['preview'] = `${json['url']}${storage?.options?.thumbnailRule || ''}`; + } if (storage?.options?.thumbnailRule) { json['thumbnailRule'] = storage?.options?.thumbnailRule; }