视频源增加代理开关

This commit is contained in:
mtvpls
2025-12-28 21:01:49 +08:00
parent dd6d2e802c
commit d821c0bd7e
11 changed files with 518 additions and 4 deletions

View File

@@ -9,7 +9,7 @@ import { db } from '@/lib/db';
export const runtime = 'nodejs';
// 支持的操作类型
type Action = 'add' | 'disable' | 'enable' | 'delete' | 'sort' | 'batch_disable' | 'batch_enable' | 'batch_delete';
type Action = 'add' | 'disable' | 'enable' | 'delete' | 'sort' | 'batch_disable' | 'batch_enable' | 'batch_delete' | 'toggle_proxy_mode';
interface BaseBody {
action?: Action;
@@ -37,7 +37,7 @@ export async function POST(request: NextRequest) {
const username = authInfo.username;
// 基础校验
const ACTIONS: Action[] = ['add', 'disable', 'enable', 'delete', 'sort', 'batch_disable', 'batch_enable', 'batch_delete'];
const ACTIONS: Action[] = ['add', 'disable', 'enable', 'delete', 'sort', 'batch_disable', 'batch_enable', 'batch_delete', 'toggle_proxy_mode'];
if (!username || !action || !ACTIONS.includes(action)) {
return NextResponse.json({ error: '参数格式错误' }, { status: 400 });
}
@@ -226,6 +226,16 @@ export async function POST(request: NextRequest) {
adminConfig.SourceConfig = newList;
break;
}
case 'toggle_proxy_mode': {
const { key } = body as { key?: string };
if (!key)
return NextResponse.json({ error: '缺少 key 参数' }, { status: 400 });
const entry = adminConfig.SourceConfig.find((s) => s.key === key);
if (!entry)
return NextResponse.json({ error: '源不存在' }, { status: 404 });
entry.proxyMode = !entry.proxyMode;
break;
}
default:
return NextResponse.json({ error: '未知操作' }, { status: 400 });
}