From faa6f0225d84fca7a826d339c5343108c3013e8b Mon Sep 17 00:00:00 2001 From: XiaoZhu Date: Wed, 15 Oct 2025 17:12:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E9=85=8D=E7=BD=AERed?= =?UTF-8?q?is=E6=95=B0=E6=8D=AE=E5=BA=93=E7=B4=A2=E5=BC=95=20fix:=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BE=AE=E5=8D=9A=E7=83=AD=E6=A6=9C=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config.ts | 2 ++ src/router.types.d.ts | 3 ++- src/routes/weibo.ts | 2 +- src/utils/cache.ts | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/config.ts b/src/config.ts index 1147701..33397b8 100644 --- a/src/config.ts +++ b/src/config.ts @@ -15,6 +15,7 @@ export type Config = { REDIS_HOST: string; REDIS_PORT: number; REDIS_PASSWORD: string; + REDIS_DB: number; ZHIHU_COOKIE: string; }; @@ -52,5 +53,6 @@ export const config: Config = { REDIS_HOST: getEnvVariable("REDIS_HOST") || "127.0.0.1", REDIS_PORT: getNumericEnvVariable("REDIS_PORT", 6379), REDIS_PASSWORD: getEnvVariable("REDIS_PASSWORD") || "", + REDIS_DB: getNumericEnvVariable("REDIS_DB", 0), ZHIHU_COOKIE: getEnvVariable("ZHIHU_COOKIE") || "", }; diff --git a/src/router.types.d.ts b/src/router.types.d.ts index bed6b6b..b87ebb7 100644 --- a/src/router.types.d.ts +++ b/src/router.types.d.ts @@ -89,7 +89,8 @@ export type RouterType = { word_scheme: string; note: string; flag_desc: string; - num: number; + // num: number; + desc_extr: number; onboard_time: number; }; zhihu: { diff --git a/src/routes/weibo.ts b/src/routes/weibo.ts index ae8f5b1..54214f0 100644 --- a/src/routes/weibo.ts +++ b/src/routes/weibo.ts @@ -44,7 +44,7 @@ const getList = async (noCache: boolean) => { desc: key, // author: v.flag_desc, timestamp: getTime(v.onboard_time), - // hot: v.num, + hot: v.desc_extr, url: `https://s.weibo.com/weibo?q=${encodeURIComponent(key)}&t=31&band_rank=1&Refer=top`, mobileUrl: v?.scheme, }; diff --git a/src/utils/cache.ts b/src/utils/cache.ts index 958cc87..8c943f5 100644 --- a/src/utils/cache.ts +++ b/src/utils/cache.ts @@ -26,6 +26,7 @@ const redis = new Redis({ host: config.REDIS_HOST, port: config.REDIS_PORT, password: config.REDIS_PASSWORD, + db: config.REDIS_DB, maxRetriesPerRequest: 5, // 重试策略:最小延迟 50ms,最大延迟 2s retryStrategy: (times) => Math.min(times * 50, 2000),