Skip to content

Commit

Permalink
refactor: 增加 canvas 销毁代码,防止内存泄漏
Browse files Browse the repository at this point in the history
  • Loading branch information
ArgoZhang committed Oct 12, 2024
1 parent acd73ad commit c0b9f23
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,18 @@ export function dispose(id) {
}
}
export function crop(id, isRound = false) {
let ret = null;
const cropper = Data.get(id);
if (cropper != null) {
cropper.crop();
let resultData = cropper.getCroppedCanvas();
if (isRound) {
resultData = getRoundCanvas(resultData);
}
return resultData.toDataURL("image/jpeg", 0.8);
ret = resultData.toDataURL("image/jpeg", 0.8);
resultData = null;
}
return ret;
}

export function replace(id, url) {
Expand Down

0 comments on commit c0b9f23

Please sign in to comment.