import {NextResponse} from "next/server"; import {getAllConfig, saveAIConfig, saveExportConfig} from "@/lib/config"; // GET /api/config - 获取完整配置 export async function GET() { try { const config = getAllConfig(); return NextResponse.json({ success: true, data: config, }); } catch (error) { return NextResponse.json( {success: false, error: "读取配置失败"}, {status: 500} ); } } // POST /api/config - 保存配置 // Body 格式: {ai?: AIConfig, export?: ExportConfig } export async function POST(request: Request) { try { const body = await request.json(); const {ai, export: exportConfig} = body; if (ai) { saveAIConfig(ai); } if (exportConfig) { saveExportConfig(exportConfig); } return NextResponse.json({ success: true, message: "配置已保存", }); } catch (error) { return NextResponse.json( {success: false, error: "保存失败"}, {status: 500} ); } }