From 7fe9d36b73e8fb61c8cb4b74d95c7cddb8d0866b Mon Sep 17 00:00:00 2001 From: binaryify Date: Sat, 9 Sep 2023 18:15:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/qrlogin-nocookie.html | 6 +++--- public/qrlogin.html | 6 +++--- server.test.js | 8 +++++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/public/qrlogin-nocookie.html b/public/qrlogin-nocookie.html index 209dd04..e9a682a 100644 --- a/public/qrlogin-nocookie.html +++ b/public/qrlogin-nocookie.html @@ -33,7 +33,7 @@ let timer let timestamp = Date.now() const cookie = localStorage.getItem('cookie') - this.getLoginStatus(cookie) + getLoginStatus(cookie) const res = await axios({ url: `/login/qr/key?timestamp=${Date.now()}`, }) @@ -44,7 +44,7 @@ document.querySelector('#qrImg').src = res2.data.data.qrimg timer = setInterval(async () => { - const statusRes = await this.checkStatus(key) + const statusRes = await checkStatus(key) if (statusRes.code === 800) { alert('二维码已过期,请重新获取') clearInterval(timer) @@ -53,7 +53,7 @@ // 这一步会返回cookie clearInterval(timer) alert('授权登录成功') - await this.getLoginStatus(statusRes.cookie) + await getLoginStatus(statusRes.cookie) localStorage.setItem('cookie', statusRes.cookie) } }, 3000) diff --git a/public/qrlogin.html b/public/qrlogin.html index 7799b05..9a24ddc 100644 --- a/public/qrlogin.html +++ b/public/qrlogin.html @@ -33,7 +33,7 @@ let timer let timestamp = Date.now() const cookie = localStorage.getItem('cookie') - this.getLoginStatus(cookie) + getLoginStatus(cookie) const res = await axios({ url: `/login/qr/key?timestamp=${Date.now()}`, }) @@ -44,7 +44,7 @@ document.querySelector('#qrImg').src = res2.data.data.qrimg timer = setInterval(async () => { - const statusRes = await this.checkStatus(key) + const statusRes = await checkStatus(key) if (statusRes.code === 800) { alert('二维码已过期,请重新获取') clearInterval(timer) @@ -53,7 +53,7 @@ // 这一步会返回cookie clearInterval(timer) alert('授权登录成功') - await this.getLoginStatus(statusRes.cookie) + await getLoginStatus(statusRes.cookie) localStorage.setItem('cookie', statusRes.cookie) } }, 3000) diff --git a/server.test.js b/server.test.js index e3d28b2..aaf8070 100644 --- a/server.test.js +++ b/server.test.js @@ -1,10 +1,12 @@ const fs = require('fs') const path = require('path') -const serverMod = require('./server') - +const tmpPath = require('os').tmpdir() /** @type {import("express").Express & serverMod.ExpressExtension} */ let app - +if (!fs.existsSync(path.resolve(tmpPath, 'anonymous_token'))) { + fs.writeFileSync(path.resolve(tmpPath, 'anonymous_token'), '', 'utf-8') +} +const serverMod = require('./server') before(async () => { app = await serverMod.serveNcmApi({})