perf: 第三方登录自动注册的用户支持设置初始化密码

This commit is contained in:
xiaojunnuo
2026-05-15 00:25:28 +08:00
parent 229f22d5a9
commit a815d0245b
2 changed files with 32 additions and 2 deletions
@@ -5,6 +5,13 @@ import { nanoid } from 'nanoid';
import { cache } from '@certd/basic';
import { UploadFileInfo } from '@midwayjs/upload';
const imageExtSet = new Set(['.apng', '.avif', '.bmp', '.gif', '.ico', '.jpeg', '.jpg', '.png', '.svg', '.webp']);
const imageCacheSeconds = 3 * 24 * 60 * 60;
export function isImageFile(filePath: string) {
return imageExtSet.has(filePath.substring(filePath.lastIndexOf('.')).toLowerCase());
}
/**
*/
@Provide()
@@ -40,8 +47,11 @@ export class FileController extends BaseController {
userId = this.getUserId();
}
const filePath = this.fileService.getFile(key, userId);
this.ctx.response.attachment(filePath);
this.ctx.response.set('Cache-Control', 'public,max-age=2592000');
if (isImageFile(filePath)) {
this.ctx.response.set('Cache-Control', `public,max-age=${imageCacheSeconds}`);
} else {
this.ctx.response.attachment(filePath);
}
await send(this.ctx, filePath);
}
}