From e5d5bad115ad9684a91cc790cf31a90b3d9c78cf Mon Sep 17 00:00:00 2001 From: Molunerfinn Date: Thu, 18 Jan 2018 09:31:15 +0800 Subject: [PATCH] Fixed: cookie error --- src/main/utils/weiboUpload.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/utils/weiboUpload.js b/src/main/utils/weiboUpload.js index 832c101..8bfc8ac 100644 --- a/src/main/utils/weiboUpload.js +++ b/src/main/utils/weiboUpload.js @@ -59,8 +59,17 @@ const weiboUpload = async function (img, type, webContents) { result = result.replace(/<.*?\/>/, '').replace(/<(\w+).*?>.*?<\/\1>/, '') delete imgList[i].base64Image const resTextJson = JSON.parse(result) - imgList[i]['imgUrl'] = `https://ws1.sinaimg.cn/${quality}/${resTextJson.data.pics.pic_1.pid}` - imgList[i]['type'] = 'weibo' + if (resTextJson.data.pics.pic_1.pid === undefined) { + webContents.send('uploadProgress', -1) + const notification = new Notification({ + title: '上传失败!', + body: '微博Cookie失效,请在网页版重新登录一遍' + }) + notification.show() + } else { + imgList[i]['imgUrl'] = `https://ws1.sinaimg.cn/${quality}/${resTextJson.data.pics.pic_1.pid}` + imgList[i]['type'] = 'weibo' + } } webContents.send('uploadProgress', 100) return imgList