Skip to content

Commit

Permalink
修复图片压缩无法覆盖的问题。
Browse files Browse the repository at this point in the history
  • Loading branch information
CNOliverZhang committed Sep 24, 2021
1 parent 5a4dc62 commit b20ed88
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "potatofield-image-toolkit",
"version": "3.4.0",
"version": "3.4.1",
"author": "张志毅",
"description": "一个为设计师和摄影师等创意行业从业者设计的多功能图片工具箱。",
"copyright": "Copyright © 2021 张志毅",
Expand All @@ -22,7 +22,7 @@
"appId": "cn.potatofield.imagetoolkit",
"artifactName": "potatofield-image-toolkit-${version}.${ext}",
"releaseInfo": {
"releaseNotes": "优化图像压缩算法,提升压缩速度,提高压缩比。\n修复了图片加水印工具字体失效的问题。\n修复了消息中心时间显示错误的问题"
"releaseNotes": "修复了图片压缩工具覆盖保存失败的问题"
},
"publish": [
{
Expand Down
10 changes: 8 additions & 2 deletions src/renderer/pages/compress.vue
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ import EXIF from 'exif-js'
import sharp from 'sharp'
const path = require('path')
const fs = require('fs')
export default {
name: 'compress',
Expand Down Expand Up @@ -462,8 +463,13 @@ export default {
distPath = imageInfo.filepath
}
let distFullpath = path.join(distPath, distFilename)
parsedImage.toFile(distFullpath).then(() => {
resolve()
parsedImage.toBuffer().then((buffer) => {
fs.writeFile(distFullpath, buffer, (error) => {
if (error) {
this.errorList.push(imageInfo.fullpath)
}
resolve()
})
}).catch(() => {
this.errorList.push(imageInfo.fullpath)
resolve()
Expand Down

0 comments on commit b20ed88

Please sign in to comment.