From a26f19f3d5f5574794565e4501821a4fe99f82c7 Mon Sep 17 00:00:00 2001 From: shinya Date: Mon, 4 Aug 2025 18:57:36 +0800 Subject: [PATCH] fix: overwrite categories with file config when in d1 and upstash --- VERSION.txt | 2 +- src/lib/config.ts | 35 ++++++++--------------------------- src/lib/version.ts | 2 +- 3 files changed, 10 insertions(+), 29 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index 7cdd409..ab88645 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -20250801133915 \ No newline at end of file +20250804185737 \ No newline at end of file diff --git a/src/lib/config.ts b/src/lib/config.ts index 9fe8333..71c93a0 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -337,34 +337,15 @@ export async function getConfig(): Promise { // 将 Map 转换回数组 adminConfig.SourceConfig = Array.from(sourceConfigMap.values()); - // 补全 CustomCategories + // 覆盖 CustomCategories const customCategories = fileConfig.custom_category || []; - const customCategoriesMap = new Map( - adminConfig.CustomCategories.map((c) => [c.query + c.type, c]) - ); - - customCategories.forEach((category) => { - customCategoriesMap.set(category.query + category.type, { - name: category.name, - type: category.type, - query: category.query, - from: 'config', - disabled: false, - }); - }); - - // 检查现有 CustomCategories 是否在 fileConfig.custom_categories 中,如果不在则标记为 custom - const customCategoriesKeys = new Set( - customCategories.map((c) => c.query + c.type) - ); - customCategoriesMap.forEach((category) => { - if (!customCategoriesKeys.has(category.query + category.type)) { - category.from = 'custom'; - } - }); - - // 将 Map 转换回数组 - adminConfig.CustomCategories = Array.from(customCategoriesMap.values()); + adminConfig.CustomCategories = customCategories.map((category) => ({ + name: category.name, + type: category.type, + query: category.query, + from: 'config', + disabled: false, + })); const ownerUser = process.env.USERNAME || ''; // 检查配置中的站长用户是否和 USERNAME 匹配,如果不匹配则降级为普通用户 diff --git a/src/lib/version.ts b/src/lib/version.ts index e4d4a38..e452883 100644 --- a/src/lib/version.ts +++ b/src/lib/version.ts @@ -2,7 +2,7 @@ 'use client'; -const CURRENT_VERSION = '20250801133915'; +const CURRENT_VERSION = '20250804185737'; // 版本检查结果枚举 export enum UpdateStatus {