feat: add localization and site settings

This commit is contained in:
rucky
2026-05-12 09:58:25 +08:00
parent 9dc6c0dcce
commit fa7aedb8e7
67 changed files with 5221 additions and 888 deletions

View File

@@ -1,15 +1,24 @@
import { NextRequest, NextResponse } from "next/server";
import { auth } from "@/lib/auth";
import { prisma } from "@/lib/db";
import { getApiLang, pickText } from "@/lib/api-locale";
export async function GET(request: NextRequest) {
const enabledOnly = request.nextUrl.searchParams.get("enabled") === "1";
const lang = getApiLang(request);
const where = enabledOnly ? { enabled: true } : {};
const images = await prisma.galleryImage.findMany({
where,
orderBy: { sortOrder: "asc" },
});
return NextResponse.json(images);
return NextResponse.json(
images.map((img) => ({
...img,
title: pickText(img.title, img.titleEn, lang),
titleZh: img.title,
titleEn: img.titleEn,
}))
);
}
export async function POST(request: NextRequest) {
@@ -23,6 +32,7 @@ export async function POST(request: NextRequest) {
data: {
imageUrl: body.imageUrl,
title: body.title ?? "",
titleEn: body.titleEn ?? "",
sortOrder: body.sortOrder ?? 0,
enabled: body.enabled ?? true,
},