tachybase_todo/packages/plugins/@nocobase/plugin-file-manager/src/server/FileModel.ts

17 lines
619 B
TypeScript
Raw Normal View History

import { Model } from '@nocobase/database';
export class FileModel extends Model {
public toJSON() {
const json = super.toJSON();
const fileStorages = this.constructor['database']?.['_fileStorages'];
if (json.storageId && fileStorages && fileStorages.has(json.storageId)) {
const storage = fileStorages.get(json.storageId);
json['thumbnailRule'] = storage?.options?.thumbnailRule;
if (!json['thumbnailRule'] && storage?.type === 'ali-oss') {
json['thumbnailRule'] = '?x-oss-process=image/auto-orient,1/resize,m_fill,w_94,h_94/quality,q_90';
}
}
return json;
}
}