mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-01-23 14:48:13 -05:00
🐛 Fix: multiple uploading in the same time will cause output conflict
ISSUES CLOSED: #666
This commit is contained in:
parent
cf895deb8d
commit
06b67e50b9
@ -42,7 +42,7 @@
|
|||||||
"keycode": "^2.2.0",
|
"keycode": "^2.2.0",
|
||||||
"lodash-id": "^0.14.0",
|
"lodash-id": "^0.14.0",
|
||||||
"lowdb": "^1.0.0",
|
"lowdb": "^1.0.0",
|
||||||
"picgo": "^1.4.19",
|
"picgo": "^1.4.21",
|
||||||
"qrcode.vue": "^1.7.0",
|
"qrcode.vue": "^1.7.0",
|
||||||
"vue": "^2.6.10",
|
"vue": "^2.6.10",
|
||||||
"vue-gallery": "^2.0.1",
|
"vue-gallery": "^2.0.1",
|
||||||
|
@ -109,19 +109,10 @@ class Uploader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async upload (img?: IUploadOption): Promise<ImgInfo[]|false> {
|
async upload (img?: IUploadOption): Promise<ImgInfo[]|false> {
|
||||||
// if (this.uploading) {
|
|
||||||
// showNotification({
|
|
||||||
// title: '上传失败',
|
|
||||||
// body: '前序上传还在继续,请稍后再试'
|
|
||||||
// })
|
|
||||||
// return Promise.resolve(false)
|
|
||||||
// }
|
|
||||||
try {
|
try {
|
||||||
const startTime = Date.now()
|
const startTime = Date.now()
|
||||||
// this.uploading = true
|
|
||||||
const output = await picgo.upload(img)
|
const output = await picgo.upload(img)
|
||||||
// this.uploading = false
|
if (Array.isArray(output) && output.some((item: ImgInfo) => item.imgUrl)) {
|
||||||
if (Array.isArray(output) && output.every((item: ImgInfo) => item.imgUrl)) {
|
|
||||||
if (this.webContents) {
|
if (this.webContents) {
|
||||||
handleTalkingData(this.webContents, {
|
handleTalkingData(this.webContents, {
|
||||||
fromClipboard: !img,
|
fromClipboard: !img,
|
||||||
@ -130,12 +121,11 @@ class Uploader {
|
|||||||
duration: Date.now() - startTime
|
duration: Date.now() - startTime
|
||||||
} as IAnalyticsData)
|
} as IAnalyticsData)
|
||||||
}
|
}
|
||||||
return output
|
return output.filter(item => item.imgUrl)
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// this.uploading = false
|
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
showNotification({
|
showNotification({
|
||||||
|
@ -5,6 +5,12 @@ import {
|
|||||||
import logger from '@core/picgo/logger'
|
import logger from '@core/picgo/logger'
|
||||||
import windowManager from 'apis/app/window/windowManager'
|
import windowManager from 'apis/app/window/windowManager'
|
||||||
import { uploadChoosedFiles, uploadClipboardFiles } from 'apis/app/uploader/apis'
|
import { uploadChoosedFiles, uploadClipboardFiles } from 'apis/app/uploader/apis'
|
||||||
|
import { app } from 'electron'
|
||||||
|
import path from 'path'
|
||||||
|
const STORE_PATH = app.getPath('userData')
|
||||||
|
const LOG_PATH = path.join(STORE_PATH, 'picgo.log')
|
||||||
|
|
||||||
|
const errorMessage = `upload error. see ${LOG_PATH} for more detail.`
|
||||||
|
|
||||||
router.post('/upload', async ({
|
router.post('/upload', async ({
|
||||||
response,
|
response,
|
||||||
@ -31,7 +37,7 @@ router.post('/upload', async ({
|
|||||||
response,
|
response,
|
||||||
body: {
|
body: {
|
||||||
success: false,
|
success: false,
|
||||||
message: 'upload error'
|
message: errorMessage
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -58,7 +64,7 @@ router.post('/upload', async ({
|
|||||||
response,
|
response,
|
||||||
body: {
|
body: {
|
||||||
success: false,
|
success: false,
|
||||||
message: 'upload error'
|
message: errorMessage
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -69,7 +75,7 @@ router.post('/upload', async ({
|
|||||||
response,
|
response,
|
||||||
body: {
|
body: {
|
||||||
success: false,
|
success: false,
|
||||||
message: err
|
message: errorMessage
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -8306,10 +8306,10 @@ performance-now@^2.1.0:
|
|||||||
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
|
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
|
||||||
integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=
|
integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=
|
||||||
|
|
||||||
picgo@^1.4.19:
|
picgo@^1.4.21:
|
||||||
version "1.4.19"
|
version "1.4.21"
|
||||||
resolved "https://registry.yarnpkg.com/picgo/-/picgo-1.4.19.tgz#cbd4b39f1d1a2a5f231e62a7fdbf87f53298f2a8"
|
resolved "https://registry.yarnpkg.com/picgo/-/picgo-1.4.21.tgz#5ebbacda85200d63f5f83128b1c1b37c10cd80f3"
|
||||||
integrity sha512-Y1BUrwq9rzEDQ06ZV5ZR8WRZqQe5hAHNVs4F/nEtwWBfr2YFwPxdce0b/rEPMZDSM7dfCWrts2M1qZC8VxB2+g==
|
integrity sha512-WxPVNbWa2LPFfPftRvdFqf1fwUn6TrBn2vm12hSMHUjhdU+7nK3uysBfL5R9/vOAk+OPt3bU74zRHYi6gME+Dw==
|
||||||
dependencies:
|
dependencies:
|
||||||
chalk "^2.4.1"
|
chalk "^2.4.1"
|
||||||
commander "^2.17.0"
|
commander "^2.17.0"
|
||||||
|
Loading…
Reference in New Issue
Block a user