38 lines
1.3 KiB
TypeScript
38 lines
1.3 KiB
TypeScript
import { NextResponse } from "next/server";
|
|
import { auth } from "@/app/(auth)/auth";
|
|
import { getPointsSystemConfig, getSystemSetting } from "@/lib/db/queries";
|
|
import {
|
|
ENHANCE_PRO_KREA_SETTING_KEY,
|
|
normalizeEnhanceProKreaConfig,
|
|
sanitizeEnhanceProKreaConfigForClient,
|
|
} from "@/lib/enhance-pro/config";
|
|
import { normalizeEnhanceProPointsPricingConfig } from "@/lib/points/config";
|
|
|
|
export async function GET() {
|
|
try {
|
|
const session = await auth();
|
|
if (!session?.user?.id) {
|
|
return NextResponse.json({ error: "未授权,请先登录" }, { status: 401 });
|
|
}
|
|
|
|
const setting = await getSystemSetting({ key: ENHANCE_PRO_KREA_SETTING_KEY });
|
|
const config = normalizeEnhanceProKreaConfig(setting?.value);
|
|
const pointsConfig = await getPointsSystemConfig();
|
|
|
|
return NextResponse.json({
|
|
success: true,
|
|
config: sanitizeEnhanceProKreaConfigForClient(config),
|
|
pointsConfig: {
|
|
enabled: pointsConfig.enabled === true,
|
|
blockOnInsufficient: pointsConfig.blockOnInsufficient !== false,
|
|
enhanceProPricing: normalizeEnhanceProPointsPricingConfig(
|
|
pointsConfig.enhanceProPricing
|
|
),
|
|
},
|
|
});
|
|
} catch (error) {
|
|
console.error("[Enhance Pro Config] 获取配置失败:", error);
|
|
return NextResponse.json({ error: "获取图像增强 Pro 配置失败" }, { status: 500 });
|
|
}
|
|
}
|