mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-02-02 11:08:13 -05:00
Updated: filename & file extname with qiniu & weibo
This commit is contained in:
parent
504690b729
commit
df39511cdf
@ -73,6 +73,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.16.1",
|
"axios": "^0.16.1",
|
||||||
"element-ui": "^2.0.5",
|
"element-ui": "^2.0.5",
|
||||||
|
"fecha": "^2.3.3",
|
||||||
"fs-extra": "^4.0.2",
|
"fs-extra": "^4.0.2",
|
||||||
"image-size": "^0.6.1",
|
"image-size": "^0.6.1",
|
||||||
"keycode": "^2.1.9",
|
"keycode": "^2.1.9",
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import fs from 'fs-extra'
|
import fs from 'fs-extra'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import sizeOf from 'image-size'
|
import sizeOf from 'image-size'
|
||||||
|
import fecha from 'fecha'
|
||||||
|
|
||||||
const imgFromPath = async (imgPath) => {
|
const imgFromPath = async (imgPath) => {
|
||||||
let results = []
|
let results = []
|
||||||
@ -13,7 +14,8 @@ const imgFromPath = async (imgPath) => {
|
|||||||
base64Image,
|
base64Image,
|
||||||
fileName,
|
fileName,
|
||||||
width: imgSize.width,
|
width: imgSize.width,
|
||||||
height: imgSize.height
|
height: imgSize.height,
|
||||||
|
extname: path.extname(item.name)
|
||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
return results
|
return results
|
||||||
@ -22,12 +24,13 @@ const imgFromPath = async (imgPath) => {
|
|||||||
const imgFromClipboard = (file) => {
|
const imgFromClipboard = (file) => {
|
||||||
let result = []
|
let result = []
|
||||||
if (file !== null) {
|
if (file !== null) {
|
||||||
const today = new Date().toLocaleString().replace(/[ ]+/g, '-').replace(/\/+/g, '-')
|
const today = fecha.format(new Date(), 'YYYYMMDDHHmmss')
|
||||||
result.push({
|
result.push({
|
||||||
base64Image: file.imgUrl.replace(/^data\S+,/, ''),
|
base64Image: file.imgUrl.replace(/^data\S+,/, ''),
|
||||||
fileName: `${today}.png`,
|
fileName: `${today}.png`,
|
||||||
width: file.width,
|
width: file.width,
|
||||||
height: file.height
|
height: file.height,
|
||||||
|
extname: '.png'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
@ -44,7 +47,8 @@ const imgFromUploader = async (files) => {
|
|||||||
base64Image,
|
base64Image,
|
||||||
fileName,
|
fileName,
|
||||||
width: imgSize.width,
|
width: imgSize.width,
|
||||||
height: imgSize.height
|
height: imgSize.height,
|
||||||
|
extname: path.extname(item.name)
|
||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
return results
|
return results
|
||||||
|
@ -67,9 +67,11 @@ const weiboUpload = async function (img, type, webContents) {
|
|||||||
})
|
})
|
||||||
notification.show()
|
notification.show()
|
||||||
} else {
|
} 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'
|
imgList[i]['type'] = 'weibo'
|
||||||
}
|
}
|
||||||
|
delete imgList[i].extname
|
||||||
}
|
}
|
||||||
webContents.send('uploadProgress', 100)
|
webContents.send('uploadProgress', 100)
|
||||||
return imgList
|
return imgList
|
||||||
|
@ -98,7 +98,7 @@ export default {
|
|||||||
name: 'setting-page',
|
name: 'setting-page',
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
version: pkg.version,
|
version: process.env.NODE_ENV === 'production' ? pkg.version : 'Dev',
|
||||||
defaultActive: 'upload',
|
defaultActive: 'upload',
|
||||||
menu: null,
|
menu: null,
|
||||||
visible: false,
|
visible: false,
|
||||||
|
@ -3556,6 +3556,10 @@ fd-slicer@~1.0.1:
|
|||||||
dependencies:
|
dependencies:
|
||||||
pend "~1.2.0"
|
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:
|
figures@^1.4.0:
|
||||||
version "1.7.0"
|
version "1.7.0"
|
||||||
resolved "https://registry.yarnpkg.com/figures/-/figures-1.7.0.tgz#cbe1e3affcf1cd44b80cadfed28dc793a9701d2e"
|
resolved "https://registry.yarnpkg.com/figures/-/figures-1.7.0.tgz#cbe1e3affcf1cd44b80cadfed28dc793a9701d2e"
|
||||||
|
Loading…
Reference in New Issue
Block a user