From 51531408fbab562db150c8647bdb26dd27d8afdc Mon Sep 17 00:00:00 2001 From: Yuanzhe Liu <294068487@qq.com> Date: Fri, 8 Sep 2023 05:17:58 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=E6=97=A5=E6=9C=9F?= =?UTF-8?q?=E6=AF=94=E4=B8=BA=E4=B8=80=E4=B8=AA=E6=9C=88=20feat:=20?= =?UTF-8?q?=E8=AE=A2=E9=98=85cache=E5=A2=9E=E5=8A=A0headers=E4=BC=A0?= =?UTF-8?q?=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routes/airportsub.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/routes/airportsub.js b/routes/airportsub.js index f451147..f002287 100644 --- a/routes/airportsub.js +++ b/routes/airportsub.js @@ -21,7 +21,7 @@ function getuserinfo(headers) { dic["use_percent"] = (100.0 * dic.total_use / dic.total).toFixed(2); const now_time = Math.floor(Date.now() / 1000); const end_time = dic.expire; - dic["date_percent"] = (100.0 * (now_time - end_time + 3600 * 24 * 365.0) / (3600 * 24 * 365.0)).toFixed(2); + dic["date_percent"] = (100.0 * (1-(end_time - now_time) / (3600 * 24 * 30.0))).toFixed(2); dic["total_use"] = filesize(dic["total_use"], {base: 2, standard: "jedec"}); dic.total = filesize(dic.total, {base: 2, standard: "jedec"}); @@ -99,11 +99,15 @@ router.get("/cache", async function (req, res) { for (let key in database.suburl) { const url = database.suburl[key].url; const params = database.suburl[key].params; + let headers = database.suburl[key].headers; if (params && params.url) { params.url = [params.url].flat().join("|"); } if (!url) continue; - promises.push(axios.get(url, {params})); + // 修复 Z_BUF_ERROR 的错误 + if (headers) + headers["Accept-Encoding"] = "gzip,deflate,compress"; + promises.push(axios.get(url, {params,headers})); } Promise.all(promises).then(values => { promises = [];