增加视频特殊源配置功能
This commit is contained in:
@@ -19,6 +19,8 @@ type Action =
|
||||
| 'batch_enable'
|
||||
| 'batch_delete'
|
||||
| 'toggle_proxy_mode'
|
||||
| 'toggle_special_source'
|
||||
| 'set_special_sources'
|
||||
| 'update_weight'
|
||||
| 'batch_update_weights';
|
||||
|
||||
@@ -58,6 +60,8 @@ export async function POST(request: NextRequest) {
|
||||
'batch_enable',
|
||||
'batch_delete',
|
||||
'toggle_proxy_mode',
|
||||
'toggle_special_source',
|
||||
'set_special_sources',
|
||||
'update_weight',
|
||||
'batch_update_weights',
|
||||
];
|
||||
@@ -146,6 +150,9 @@ export async function POST(request: NextRequest) {
|
||||
return NextResponse.json({ error: '该源不可删除' }, { status: 400 });
|
||||
}
|
||||
adminConfig.SourceConfig.splice(idx, 1);
|
||||
adminConfig.SpecialSourceApis = (adminConfig.SpecialSourceApis || []).filter(
|
||||
(api) => api !== key
|
||||
);
|
||||
|
||||
// 检查并清理用户组和用户的权限数组
|
||||
// 清理用户组权限
|
||||
@@ -226,6 +233,10 @@ export async function POST(request: NextRequest) {
|
||||
}
|
||||
});
|
||||
|
||||
adminConfig.SpecialSourceApis = (adminConfig.SpecialSourceApis || []).filter(
|
||||
(api) => !keysToDelete.includes(api)
|
||||
);
|
||||
|
||||
// 检查并清理用户组和用户的权限数组
|
||||
if (keysToDelete.length > 0) {
|
||||
// 清理用户组权限
|
||||
@@ -290,6 +301,39 @@ export async function POST(request: NextRequest) {
|
||||
entry.proxyMode = !entry.proxyMode;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'toggle_special_source': {
|
||||
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 });
|
||||
|
||||
const specialApis = new Set(adminConfig.SpecialSourceApis || []);
|
||||
if (specialApis.has(key)) {
|
||||
specialApis.delete(key);
|
||||
} else {
|
||||
specialApis.add(key);
|
||||
}
|
||||
adminConfig.SpecialSourceApis = Array.from(specialApis).filter((api) =>
|
||||
adminConfig.SourceConfig.some((source) => source.key === api)
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'set_special_sources': {
|
||||
const { keys } = body as { keys?: string[] };
|
||||
if (!Array.isArray(keys)) {
|
||||
return NextResponse.json({ error: 'keys 参数格式错误' }, { status: 400 });
|
||||
}
|
||||
|
||||
const sourceKeySet = new Set(adminConfig.SourceConfig.map((source) => source.key));
|
||||
adminConfig.SpecialSourceApis = Array.from(new Set(keys)).filter((key) =>
|
||||
sourceKeySet.has(key)
|
||||
);
|
||||
break;
|
||||
}
|
||||
case 'batch_update_weights': {
|
||||
const { weights, order } = body as {
|
||||
weights?: Array<{ key?: string; weight?: number }>;
|
||||
|
||||
Reference in New Issue
Block a user