fix: overwrite categories with file config when in d1 and upstash

This commit is contained in:
shinya
2025-08-04 18:57:36 +08:00
parent 774f047beb
commit a26f19f3d5
3 changed files with 10 additions and 29 deletions

View File

@@ -1 +1 @@
20250801133915
20250804185737

View File

@@ -337,34 +337,15 @@ export async function getConfig(): Promise<AdminConfig> {
// 将 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 匹配,如果不匹配则降级为普通用户

View File

@@ -2,7 +2,7 @@
'use client';
const CURRENT_VERSION = '20250801133915';
const CURRENT_VERSION = '20250804185737';
// 版本检查结果枚举
export enum UpdateStatus {