diff --git a/src/main/apis/app/uploader/index.ts b/src/main/apis/app/uploader/index.ts index 6ed0d5a..5ff3be9 100644 --- a/src/main/apis/app/uploader/index.ts +++ b/src/main/apis/app/uploader/index.ts @@ -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 { - 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({ diff --git a/src/main/server/index.ts b/src/main/server/index.ts index 11857b2..1161150 100644 --- a/src/main/server/index.ts +++ b/src/main/server/index.ts @@ -67,7 +67,7 @@ class Server { } }) } - logger.info(`[PicGo Server] get the request`) + logger.info(`[PicGo Server] get the request`, body) const handler = routers.getHandler(request.url!) handler!({ ...postObj, diff --git a/src/main/server/routerManager.ts b/src/main/server/routerManager.ts index da6ee68..bf8b874 100644 --- a/src/main/server/routerManager.ts +++ b/src/main/server/routerManager.ts @@ -1,12 +1,10 @@ import router from './router' -import { - uploadWithClipboardFiles, - uploadWithFiles -} from '@core/bus/apis' import { handleResponse } from './utils' import logger from '@core/picgo/logger' +import windowManager from 'apis/app/window/windowManager' +import { uploadChoosedFiles, uploadClipboardFiles } from 'apis/app/uploader/apis' router.post('/upload', async ({ response, @@ -19,13 +17,13 @@ router.post('/upload', async ({ if (list.length === 0) { // upload with clipboard logger.info('[PicGo Server] upload clipboard file') - const res = await uploadWithClipboardFiles() - if (res.success) { + const res = await uploadClipboardFiles() + if (res) { handleResponse({ response, body: { success: true, - result: res.result + result: res } }) } else { @@ -45,13 +43,14 @@ router.post('/upload', async ({ path: item } }) - const res = await uploadWithFiles(pathList) - if (res.success) { + const win = windowManager.getAvailableWindow() + const res = await uploadChoosedFiles(win.webContents, pathList) + if (res.length) { handleResponse({ response, body: { success: true, - result: res.result + result: res } }) } else {