import { NextResponse } from "next/server"; import { getSystemSetting } from "@/lib/db/queries"; import { STYLE_PRO_CONFIG_KEY, normalizeStyleProConfig, toPublicStyleProConfig, } from "@/lib/style-pro/config"; import { findStyleProImageModelByRef, getStyleProImageModelEntries, } from "@/lib/style-pro/model-options"; export const dynamic = "force-dynamic"; export async function GET() { try { const setting = await getSystemSetting({ key: STYLE_PRO_CONFIG_KEY }).catch( () => null ); const config = normalizeStyleProConfig(setting?.value); const realisticModelEntries = ( await getStyleProImageModelEntries({ includeHidden: true }).catch( () => [] ) ); const publicConfig = toPublicStyleProConfig(config); return NextResponse.json({ success: true, config: { ...publicConfig, realisticModeAvailable: Boolean( findStyleProImageModelByRef( realisticModelEntries, config.realisticFirstModelId ) && findStyleProImageModelByRef( realisticModelEntries, config.realisticSecondModelId ) ), }, }); } catch (error) { console.error("[Style Pro Config] Failed:", error); return NextResponse.json( { success: false, error: "获取风格化 PRO 配置失败" }, { status: 500 } ); } }