feat: 新增头像上传前裁剪功能

This commit is contained in:
Bull-BCLS
2023-11-02 14:53:17 +08:00
parent 4a4233647f
commit cbc652de77
5 changed files with 151 additions and 50 deletions

View File

@@ -12,6 +12,20 @@ export interface AvatarRes {
avatar: string;
}
export interface cropperOptions {
autoCrop: boolean; // 是否默认生成截图框
autoCropWidth: number; // 默认生成截图框宽度
autoCropHeight: number; // 默认生成截图框高度
canMove: boolean; // 上传图片是否可以移动 (默认:true)
centerBox: boolean; // 截图框是否被限制在图片里面 (默认:false)
full: boolean; // 是否输出原图比例的截图 选true生成的图片会非常大 (默认:false)
fixed: boolean; // 是否开启截图框宽高固定比例 (默认:false)
fixedBox: boolean; // 固定截图框大小 不允许改变
img: string | ArrayBuffer | null; // 裁剪图片的地址
outputSize: number; // 裁剪生成图片的质量 (默认:1)
outputType: string; // 默认生成截图为PNG格式
}
export function uploadAvatar(data: FormData) {
return axios.post<AvatarRes>(`${BASE_URL}/avatar`, data);
}