网盘搜索前增加来源筛选

This commit is contained in:
mtvpls
2026-06-06 17:00:23 +08:00
parent c8898bcaea
commit f6db363dcb
3 changed files with 217 additions and 15 deletions
+12 -5
View File
@@ -19,12 +19,15 @@ export async function POST(request: NextRequest) {
const body = await request.json();
const { keyword } = body;
const cloudTypes = Array.isArray(body.cloud_types)
? body.cloud_types.filter(
(item: unknown): item is string =>
typeof item === 'string' && item.trim().length > 0
)
: undefined;
if (!keyword) {
return NextResponse.json(
{ error: '关键词不能为空' },
{ status: 400 }
);
return NextResponse.json({ error: '关键词不能为空' }, { status: 400 });
}
// 从系统配置中获取 Pansou 配置
@@ -37,6 +40,7 @@ export async function POST(request: NextRequest) {
keyword,
apiUrl: apiUrl ? '已配置' : '未配置',
hasAuth: !!(username && password),
cloudTypes: cloudTypes?.length ? cloudTypes : 'all',
});
if (!apiUrl) {
@@ -50,6 +54,7 @@ export async function POST(request: NextRequest) {
const results = await searchPansou(apiUrl, keyword, {
username,
password,
cloudTypes,
});
const rawBlocklist = config.SiteConfig.PansouKeywordBlocklist || '';
@@ -66,7 +71,9 @@ export async function POST(request: NextRequest) {
let total = 0;
const shouldBlock = (link: PansouLink) => {
const content = `${link.note || ''} ${link.url || ''} ${link.source || ''}`.toLowerCase();
const content = `${link.note || ''} ${link.url || ''} ${
link.source || ''
}`.toLowerCase();
return blockedKeywords.some((item) =>
content.includes(item.toLowerCase())
);