From 9b335da4cecd9f9572f6c4b42baf43c9c2e4f378 Mon Sep 17 00:00:00 2001 From: mtvpls Date: Mon, 26 Jan 2026 00:00:46 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E9=94=99=E5=AD=97=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG | 2 +- src/lib/changelog.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ef5cd60..35d1465 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,7 +2,7 @@ ### Added - 新增网络直播功能 - 动漫磁力搜索增加蜜柑 -- 弹幕磁力搜索增加动漫花园 +- 动漫磁力搜索增加动漫花园 - pansou增加关键词过滤 - cloudflare workers部署支持 diff --git a/src/lib/changelog.ts b/src/lib/changelog.ts index a8f1f0b..3e6bf21 100644 --- a/src/lib/changelog.ts +++ b/src/lib/changelog.ts @@ -16,7 +16,7 @@ export const changelog: ChangelogEntry[] = [ added: [ "新增网络直播功能", "动漫磁力搜索增加蜜柑", - "弹幕磁力搜索增加动漫花园", + "动漫磁力搜索增加动漫花园", "pansou增加关键词过滤", "cloudflare workers部署支持", ], From b3764a793806dd7ee366b4e3ab6bce5a103b7822 Mon Sep 17 00:00:00 2001 From: mtvpls Date: Mon, 26 Jan 2026 08:58:04 +0800 Subject: [PATCH 2/2] =?UTF-8?q?middleware=E6=87=92=E5=8A=A0=E8=BD=BDstorag?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/refresh-token.ts | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/lib/refresh-token.ts b/src/lib/refresh-token.ts index ee7b580..ada24ca 100644 --- a/src/lib/refresh-token.ts +++ b/src/lib/refresh-token.ts @@ -1,6 +1,15 @@ /* eslint-disable no-console */ -import { getStorage } from './db'; +// Lazy import to avoid Edge Runtime issues in middleware +let getStorage: (() => any) | null = null; + +async function loadStorage() { + if (!getStorage) { + const db = await import('./db'); + getStorage = db.getStorage; + } + return getStorage(); +} // Token 配置 export const TOKEN_CONFIG = { @@ -38,7 +47,7 @@ export async function storeRefreshToken( tokenData: TokenData ): Promise { const hashKey = `user_tokens:${username}`; - const storage = getStorage(); + const storage = await loadStorage(); if (!storage || typeof (storage as any).adapter?.hSet !== 'function') { console.warn('Redis Hash not supported, skipping token storage'); @@ -65,7 +74,7 @@ export async function verifyRefreshToken( refreshToken: string ): Promise { const hashKey = `user_tokens:${username}`; - const storage = getStorage(); + const storage = await loadStorage(); if (!storage || typeof (storage as any).adapter?.hGet !== 'function') { console.warn('Redis Hash not supported'); @@ -114,7 +123,7 @@ export async function revokeRefreshToken( tokenId: string ): Promise { const hashKey = `user_tokens:${username}`; - const storage = getStorage(); + const storage = await loadStorage(); if (!storage || typeof (storage as any).adapter?.hDel !== 'function') { console.warn('Redis Hash not supported'); @@ -138,7 +147,7 @@ export async function getUserDevices(username: string): Promise> { const hashKey = `user_tokens:${username}`; - const storage = getStorage(); + const storage = await loadStorage(); if (!storage || typeof (storage as any).adapter?.hGetAll !== 'function') { console.warn('Redis Hash not supported'); @@ -188,7 +197,7 @@ export async function getUserDevices(username: string): Promise { const hashKey = `user_tokens:${username}`; - const storage = getStorage(); + const storage = await loadStorage(); if (!storage || typeof (storage as any).adapter?.del !== 'function') { console.warn('Redis Hash not supported'); @@ -206,7 +215,7 @@ export async function revokeAllRefreshTokens(username: string): Promise { // 清理过期的 Token(定期任务) export async function cleanupExpiredTokens(username: string): Promise { const hashKey = `user_tokens:${username}`; - const storage = getStorage(); + const storage = await loadStorage(); if (!storage || typeof (storage as any).adapter?.hGetAll !== 'function') { return 0;