diff --git a/src/webui/src/router/index.ts b/src/webui/src/router/index.ts index 2c3df19d..d6782614 100644 --- a/src/webui/src/router/index.ts +++ b/src/webui/src/router/index.ts @@ -13,14 +13,15 @@ export async function AuthApi(req: Request, res: Response, next: NextFunction) { next(); return; } - if (req.headers?.authorization) { - let token = req.headers?.authorization.split(' ')[1]; + if (req.headers.authorization) { + let token = req.headers.authorization.split(' ')[1]; let Credential = JSON.parse(Buffer.from(token, 'base64').toString('utf-8')); let config = await WebUiConfig.GetWebUIConfig(); let credentialJson = await AuthHelper.validateCredentialWithinOneHour(config.token, Credential); if (credentialJson) { //通过验证 next(); + return; } res.json({ code: -1, @@ -29,10 +30,7 @@ export async function AuthApi(req: Request, res: Response, next: NextFunction) { return; } } catch (e: any) { - res.json({ - code: -1, - msg: 'Server Error', - }); + console.log(e); return; } res.json({ diff --git a/static/QQLogin.html b/static/QQLogin.html index defadee6..71617f9a 100644 --- a/static/QQLogin.html +++ b/static/QQLogin.html @@ -252,8 +252,8 @@ optionUinEle.value = QuickUin; QuickListSelect.appendChild(optionUinEle); }); - generateQrCode(await GetQQLoginQrcode(), document.querySelector('#qrcode-canvas')); - setTimeout(HeartBeat, 3000); + generateQrCode(await GetQQLoginQrcode(localStorage.getItem('auth')), document.querySelector('#qrcode-canvas')); + setInterval(HeartBeat, 3000); } document.getElementById('quick-login').addEventListener('click', function () { let quickLoginOptions = document.querySelector('#quick-login-dropdown'); @@ -272,7 +272,7 @@ alert("登录失败," + errMsg); } //await (localStorage.getItem('auth')) - document.getElementById('quick-login-options').classList.remove('show'); + //document.getElementById('quick-login-options').classList.remove('show'); } document.getElementById('qrcode-login').addEventListener('click', function () { let loginForm = document.querySelector('#quick-login-dropdown');