增加盘搜

This commit is contained in:
mtvpls
2025-12-23 00:47:24 +08:00
parent ac3e68ec10
commit bca4e773c4
9 changed files with 813 additions and 5 deletions

View File

@@ -43,6 +43,9 @@ export async function POST(request: NextRequest) {
DanmakuApiToken,
TMDBApiKey,
TMDBProxy,
PansouApiUrl,
PansouUsername,
PansouPassword,
EnableComments,
CustomAdFilterCode,
CustomAdFilterVersion,
@@ -76,6 +79,9 @@ export async function POST(request: NextRequest) {
DanmakuApiToken: string;
TMDBApiKey?: string;
TMDBProxy?: string;
PansouApiUrl?: string;
PansouUsername?: string;
PansouPassword?: string;
EnableComments: boolean;
CustomAdFilterCode?: string;
CustomAdFilterVersion?: number;
@@ -163,6 +169,9 @@ export async function POST(request: NextRequest) {
DanmakuApiToken,
TMDBApiKey,
TMDBProxy,
PansouApiUrl,
PansouUsername,
PansouPassword,
EnableComments,
CustomAdFilterCode,
CustomAdFilterVersion,

View File

@@ -0,0 +1,61 @@
/* eslint-disable @typescript-eslint/no-explicit-any,no-console */
import { NextRequest, NextResponse } from 'next/server';
import { getConfig } from '@/lib/config';
import { searchPansou } from '@/lib/pansou.client';
export const runtime = 'nodejs';
export async function POST(request: NextRequest) {
try {
const body = await request.json();
const { keyword } = body;
if (!keyword) {
return NextResponse.json(
{ error: '关键词不能为空' },
{ status: 400 }
);
}
// 从系统配置中获取 Pansou 配置
const config = await getConfig();
const apiUrl = config.SiteConfig.PansouApiUrl;
const username = config.SiteConfig.PansouUsername;
const password = config.SiteConfig.PansouPassword;
console.log('Pansou 搜索请求:', {
keyword,
apiUrl: apiUrl ? '已配置' : '未配置',
hasAuth: !!(username && password),
});
if (!apiUrl) {
return NextResponse.json(
{ error: '未配置 Pansou API 地址,请在管理面板配置' },
{ status: 400 }
);
}
// 调用 Pansou 搜索
const results = await searchPansou(apiUrl, keyword, {
username,
password,
});
console.log('Pansou 搜索结果:', {
total: results.total,
hasData: !!results.merged_by_type,
types: results.merged_by_type ? Object.keys(results.merged_by_type) : [],
});
return NextResponse.json(results);
} catch (error: any) {
console.error('Pansou 搜索失败:', error);
return NextResponse.json(
{ error: error.message || '搜索失败' },
{ status: 500 }
);
}
}

View File

@@ -46,6 +46,10 @@ export async function GET(request: NextRequest) {
EnableOIDCLogin: config.SiteConfig.EnableOIDCLogin || false,
EnableOIDCRegistration: config.SiteConfig.EnableOIDCRegistration || false,
OIDCButtonText: config.SiteConfig.OIDCButtonText || '',
SiteConfig: {
PansouApiUrl: config.SiteConfig.PansouApiUrl || '',
// 不暴露用户名和密码,认证在后端处理
},
};
return NextResponse.json(result);
}