39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
import { NextResponse } from "next/server";
|
|
import { auth } from "@/app/(auth)/auth";
|
|
import {
|
|
getStyleProImageModelDisplayEntries,
|
|
toPublicStyleProModelOption,
|
|
} from "@/lib/style-pro/model-options";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
export async function GET() {
|
|
try {
|
|
const session = await auth();
|
|
if (!session?.user?.id) {
|
|
return NextResponse.json(
|
|
{ success: false, error: "未登录" },
|
|
{ status: 401 }
|
|
);
|
|
}
|
|
|
|
const entries = await getStyleProImageModelDisplayEntries({
|
|
includeHidden: false,
|
|
});
|
|
const defaultEntry =
|
|
entries.find((entry) => entry.model.isDefault) || entries[0] || null;
|
|
|
|
return NextResponse.json({
|
|
success: true,
|
|
defaultModelId: defaultEntry?.model.id || null,
|
|
models: entries.map(toPublicStyleProModelOption),
|
|
});
|
|
} catch (error) {
|
|
console.error("[AI Wash Model Options] Failed:", error);
|
|
return NextResponse.json(
|
|
{ success: false, error: "获取 AI洗图 生图模型失败" },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|