openlist多目录支持

This commit is contained in:
mtvpls
2026-01-10 10:25:14 +08:00
parent afdf0b7af5
commit 00a5055817
17 changed files with 212 additions and 66 deletions

View File

@@ -26,7 +26,7 @@ export async function POST(request: NextRequest) {
try {
const body = await request.json();
const { action, Enabled, URL, Username, Password, RootPath, OfflineDownloadPath, ScanInterval, ScanMode } = body;
const { action, Enabled, URL, Username, Password, RootPaths, OfflineDownloadPath, ScanInterval, ScanMode } = body;
const authInfo = getAuthInfoFromCookie(request);
if (!authInfo || !authInfo.username) {
@@ -53,7 +53,7 @@ export async function POST(request: NextRequest) {
URL: URL || '',
Username: Username || '',
Password: Password || '',
RootPath: RootPath || '/',
RootPaths: RootPaths || ['/'],
OfflineDownloadPath: OfflineDownloadPath || '/',
LastRefreshTime: adminConfig.OpenListConfig?.LastRefreshTime,
ResourceCount: adminConfig.OpenListConfig?.ResourceCount,
@@ -77,6 +77,14 @@ export async function POST(request: NextRequest) {
);
}
// 验证 RootPaths
if (!Array.isArray(RootPaths) || RootPaths.length === 0) {
return NextResponse.json(
{ error: '请至少提供一个根目录' },
{ status: 400 }
);
}
// 验证扫描间隔
let scanInterval = parseInt(ScanInterval) || 0;
if (scanInterval > 0 && scanInterval < 60) {
@@ -104,7 +112,7 @@ export async function POST(request: NextRequest) {
URL,
Username,
Password,
RootPath: RootPath || '/',
RootPaths,
OfflineDownloadPath: OfflineDownloadPath || '/',
LastRefreshTime: adminConfig.OpenListConfig?.LastRefreshTime,
ResourceCount: adminConfig.OpenListConfig?.ResourceCount,