feat: set cached config when import, refactor db

This commit is contained in:
shinya
2025-08-15 18:47:51 +08:00
parent f8c7289d54
commit 8b34f3e403
10 changed files with 56 additions and 98 deletions

View File

@@ -4,7 +4,7 @@ import { NextRequest, NextResponse } from 'next/server';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { getConfig } from '@/lib/config';
import { getStorage } from '@/lib/db';
import { db } from '@/lib/db';
import { IStorage } from '@/lib/types';
export const runtime = 'edge';
@@ -45,7 +45,6 @@ export async function POST(request: NextRequest) {
// 获取配置与存储
const adminConfig = await getConfig();
const storage: IStorage | null = getStorage();
// 权限与身份校验
if (username !== process.env.USERNAME) {
@@ -144,9 +143,7 @@ export async function POST(request: NextRequest) {
}
// 持久化到存储
if (storage && typeof (storage as any).setAdminConfig === 'function') {
await (storage as any).setAdminConfig(adminConfig);
}
await db.saveAdminConfig(adminConfig);
return NextResponse.json(
{ ok: true },