去除 preload 里的 picture-compressor

This commit is contained in:
fofolee
2022-04-16 00:45:51 +08:00
parent 983a2f7419
commit 8d74288ed7
5 changed files with 76 additions and 166 deletions

View File

@@ -90,6 +90,7 @@
<script>
import { ref } from "vue";
import pictureCompress from "picture-compressor";
export default {
data() {
@@ -142,7 +143,7 @@ export default {
getLocalIcon() {
utools.showMainWindow();
window.getBase64Ico(this.localIconFile.path).then((dataUrl) => {
this.compressingPic(window.getBase64Ico(imgPath)).then((dataUrl) => {
dataUrl && this.setIcon(dataUrl);
});
},
@@ -163,7 +164,7 @@ export default {
quickcommand
.downloadFile(imgUrl, imgPath)
.then(() => {
window.getBase64Ico(imgPath).then((src) => {
this.compressingPic(window.getBase64Ico(imgPath)).then((src) => {
callback(src);
});
})
@@ -171,6 +172,16 @@ export default {
quickcommand.showMessageBox("图片地址有误!", "error");
});
},
async compressingPic(img, width = 80) {
let compressedImage = await pictureCompress({
img: img,
width: width,
height: width,
type: "png",
quality: 1,
});
return compressedImage.img;
},
},
};
</script>