mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-18 21:17:34 +08:00
Updated: filename & file extname with qiniu & weibo
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user