🔨 Refactor: picgo server the way of uploading

This commit is contained in:
PiEgg
2021-05-07 01:04:17 +08:00
parent ab762ef465
commit cf895deb8d
3 changed files with 21 additions and 22 deletions

View File

@@ -54,7 +54,7 @@ const handleTalkingData = (webContents: WebContents, options: IAnalyticsData) =>
class Uploader {
private webContents: WebContents | null = null
private uploading: boolean = false
// private uploading: boolean = false
constructor () {
this.init()
}
@@ -109,18 +109,18 @@ class Uploader {
}
async upload (img?: IUploadOption): Promise<ImgInfo[]|false> {
if (this.uploading) {
showNotification({
title: '上传失败',
body: '前序上传还在继续,请稍后再试'
})
return Promise.resolve(false)
}
// if (this.uploading) {
// showNotification({
// title: '上传失败',
// body: '前序上传还在继续,请稍后再试'
// })
// return Promise.resolve(false)
// }
try {
const startTime = Date.now()
this.uploading = true
// this.uploading = true
const output = await picgo.upload(img)
this.uploading = false
// this.uploading = false
if (Array.isArray(output) && output.every((item: ImgInfo) => item.imgUrl)) {
if (this.webContents) {
handleTalkingData(this.webContents, {
@@ -135,7 +135,7 @@ class Uploader {
return false
}
} catch (e) {
this.uploading = false
// this.uploading = false
logger.error(e)
setTimeout(() => {
showNotification({