漫画增加推荐页

This commit is contained in:
mtvpls
2026-04-17 21:01:44 +08:00
parent 3890cb138e
commit f289607c36
7 changed files with 567 additions and 206 deletions
+30
View File
@@ -0,0 +1,30 @@
import { NextRequest, NextResponse } from 'next/server';
import { MangaRecommendType } from '@/lib/manga.types';
import { suwayomiClient } from '@/lib/suwayomi.client';
import { getAuthorizedUsername } from '../_utils';
export const runtime = 'nodejs';
export async function GET(request: NextRequest) {
const username = await getAuthorizedUsername(request);
if (username instanceof NextResponse) return username;
try {
const { searchParams } = new URL(request.url);
const sourceId = searchParams.get('sourceId')?.trim();
const page = Number(searchParams.get('page') || '1');
const typeParam = searchParams.get('type')?.trim().toUpperCase();
const type: MangaRecommendType = typeParam === 'LATEST' ? 'LATEST' : 'POPULAR';
if (!sourceId) {
return NextResponse.json({ mangas: [], hasNextPage: false });
}
const result = await suwayomiClient.getRecommendedManga(sourceId, type, page);
return NextResponse.json(result);
} catch (error) {
return NextResponse.json({ error: (error as Error).message }, { status: 500 });
}
}