diff --git a/package.json b/package.json index 66f55a7..86f6cf9 100644 --- a/package.json +++ b/package.json @@ -73,6 +73,7 @@ "dependencies": { "axios": "^0.16.1", "element-ui": "^2.0.5", + "fecha": "^2.3.3", "fs-extra": "^4.0.2", "image-size": "^0.6.1", "keycode": "^2.1.9", diff --git a/src/main/utils/img2base64.js b/src/main/utils/img2base64.js index fbd93a2..81dbffc 100644 --- a/src/main/utils/img2base64.js +++ b/src/main/utils/img2base64.js @@ -1,6 +1,7 @@ import fs from 'fs-extra' import path from 'path' import sizeOf from 'image-size' +import fecha from 'fecha' const imgFromPath = async (imgPath) => { let results = [] @@ -13,7 +14,8 @@ const imgFromPath = async (imgPath) => { base64Image, fileName, width: imgSize.width, - height: imgSize.height + height: imgSize.height, + extname: path.extname(item.name) }) })) return results @@ -22,12 +24,13 @@ const imgFromPath = async (imgPath) => { const imgFromClipboard = (file) => { let result = [] if (file !== null) { - const today = new Date().toLocaleString().replace(/[ ]+/g, '-').replace(/\/+/g, '-') + const today = fecha.format(new Date(), 'YYYYMMDDHHmmss') result.push({ base64Image: file.imgUrl.replace(/^data\S+,/, ''), fileName: `${today}.png`, width: file.width, - height: file.height + height: file.height, + extname: '.png' }) } return result @@ -44,7 +47,8 @@ const imgFromUploader = async (files) => { base64Image, fileName, width: imgSize.width, - height: imgSize.height + height: imgSize.height, + extname: path.extname(item.name) }) })) return results diff --git a/src/main/utils/weiboUpload.js b/src/main/utils/weiboUpload.js index 8bfc8ac..6e03559 100644 --- a/src/main/utils/weiboUpload.js +++ b/src/main/utils/weiboUpload.js @@ -67,9 +67,11 @@ const weiboUpload = async function (img, type, webContents) { }) notification.show() } else { - imgList[i]['imgUrl'] = `https://ws1.sinaimg.cn/${quality}/${resTextJson.data.pics.pic_1.pid}` + const extname = imgList[i].extname === '.gif' ? '.gif' : '.jpg' + imgList[i]['imgUrl'] = `https://ws1.sinaimg.cn/${quality}/${resTextJson.data.pics.pic_1.pid}${extname}` imgList[i]['type'] = 'weibo' } + delete imgList[i].extname } webContents.send('uploadProgress', 100) return imgList diff --git a/src/renderer/components/SettingPage.vue b/src/renderer/components/SettingPage.vue index 373cc97..6e80c1b 100644 --- a/src/renderer/components/SettingPage.vue +++ b/src/renderer/components/SettingPage.vue @@ -98,7 +98,7 @@ export default { name: 'setting-page', data () { return { - version: pkg.version, + version: process.env.NODE_ENV === 'production' ? pkg.version : 'Dev', defaultActive: 'upload', menu: null, visible: false, diff --git a/yarn.lock b/yarn.lock index 2837794..a162c2a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3556,6 +3556,10 @@ fd-slicer@~1.0.1: dependencies: pend "~1.2.0" +fecha@^2.3.3: + version "2.3.3" + resolved "http://registry.npm.taobao.org/fecha/download/fecha-2.3.3.tgz#948e74157df1a32fd1b12c3a3c3cdcb6ec9d96cd" + figures@^1.4.0: version "1.7.0" resolved "https://registry.yarnpkg.com/figures/-/figures-1.7.0.tgz#cbe1e3affcf1cd44b80cadfed28dc793a9701d2e"