From a19868c2fdcb5d2ba064796a396b7d4d58af6de5 Mon Sep 17 00:00:00 2001 From: Leko Date: Fri, 7 Apr 2023 17:20:56 +0800 Subject: [PATCH] =?UTF-8?q?=E7=95=B6=E7=B6=B2=E6=98=93=E9=9B=B2=E7=99=BB?= =?UTF-8?q?=E5=85=A5=E5=A4=B1=E6=95=97=E6=99=82=EF=BC=8C=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=20QR=20Code=20=E9=87=8D=E8=A9=A6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dataModule/netease2.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/dataModule/netease2.js b/dataModule/netease2.js index 1f0448a..3ca6126 100644 --- a/dataModule/netease2.js +++ b/dataModule/netease2.js @@ -171,7 +171,7 @@ async function qrLogin() { }) } async function login(config) { - let result; + let result = null; try { if (config.login.method == 'phone') { if (config.login.countrycode) { @@ -184,14 +184,22 @@ async function login(config) { } } catch (e) { pokaLog.logDMErr('Netease2', e.response.data) - result = await qrLogin() } - if (result.code === 200) { + + if (result?.code === 200) { pokaLog.logDM('Netease2', `登入成功`) fs.writeFileSync('./cookie.json', JSON.stringify(jar.toJSON())); } else { - pokaLog.logDMErr('Netease2', `登入失敗`) + pokaLog.logDMErr('Netease2', `登入失敗,使用 QR Code 重試`) + result = await qrLogin() + if (result.code === 200) { + pokaLog.logDM('Netease2', `登入成功`) + fs.writeFileSync('./cookie.json', JSON.stringify(jar.toJSON())); + } else { + pokaLog.logDMErr('Netease2', `QR Code 重試登入失敗`) + } } + return result; } //自動重新登入