FIX: All bug in Custom Enemy, UPDATE: Add specical main skill, optimaze ui in custom enemy
All checks were successful
Gitea Auto Deploy / Deploy-Container (push) Successful in 1m39s
All checks were successful
Gitea Auto Deploy / Deploy-Container (push) Successful in 1m39s
This commit is contained in:
18
src/app/api/[locale]/monster/[id]/route.ts
Normal file
18
src/app/api/[locale]/monster/[id]/route.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import { loadMonster } from '@/lib/loader'
|
||||
|
||||
export async function GET(
|
||||
req: NextRequest,
|
||||
{ params }: { params: Promise<{ id: string, locale: string }> }
|
||||
) {
|
||||
|
||||
const { id, locale } = await params
|
||||
const monsterData = await loadMonster([id], locale)
|
||||
const monster = monsterData[id]
|
||||
|
||||
if (!monster) {
|
||||
return NextResponse.json({ error: 'Monster info not found' }, { status: 404 })
|
||||
}
|
||||
|
||||
return NextResponse.json(monster)
|
||||
}
|
||||
20
src/app/api/[locale]/monster/route.ts
Normal file
20
src/app/api/[locale]/monster/route.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { loadMonster } from "@/lib/loader";
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
|
||||
export async function POST(request: NextRequest, { params }: { params: Promise<{ locale: string }> }) {
|
||||
try {
|
||||
const body = await request.json();
|
||||
const monsterIds = body.monsterIds as string[];
|
||||
const { locale } = await params;
|
||||
|
||||
if (!Array.isArray(monsterIds) || monsterIds.some(id => typeof id !== 'string')) {
|
||||
return NextResponse.json({ error: 'Invalid monsterIds' }, { status: 400 });
|
||||
}
|
||||
|
||||
const monsterData = await loadMonster(monsterIds, locale);
|
||||
|
||||
return NextResponse.json(monsterData);
|
||||
} catch {
|
||||
return NextResponse.json({ error: 'Failed to load monster data' }, { status: 500 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user