Skip to content

Commit

Permalink
當網易雲登入失敗時,使用 QR Code 重試。
Browse files Browse the repository at this point in the history
  • Loading branch information
lekoOwO committed Apr 7, 2023
1 parent b1a4434 commit a19868c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions dataModule/netease2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}
//自動重新登入
Expand Down

0 comments on commit a19868c

Please sign in to comment.