openlist增加定时扫描

This commit is contained in:
mtvpls
2025-12-22 22:28:54 +08:00
parent 76ee99cda2
commit 6f05f91a80
4 changed files with 89 additions and 1 deletions

View File

@@ -26,7 +26,7 @@ export async function POST(request: NextRequest) {
try {
const body = await request.json();
const { action, URL, Username, Password, RootPath } = body;
const { action, URL, Username, Password, RootPath, ScanInterval } = body;
const authInfo = getAuthInfoFromCookie(request);
if (!authInfo || !authInfo.username) {
@@ -56,6 +56,15 @@ export async function POST(request: NextRequest) {
);
}
// 验证扫描间隔
let scanInterval = parseInt(ScanInterval) || 0;
if (scanInterval > 0 && scanInterval < 60) {
return NextResponse.json(
{ error: '定时扫描间隔最低为 60 分钟' },
{ status: 400 }
);
}
// 验证账号密码是否正确
try {
console.log('[OpenList Config] 验证账号密码');
@@ -76,6 +85,7 @@ export async function POST(request: NextRequest) {
RootPath: RootPath || '/',
LastRefreshTime: adminConfig.OpenListConfig?.LastRefreshTime,
ResourceCount: adminConfig.OpenListConfig?.ResourceCount,
ScanInterval: scanInterval,
};
await db.saveAdminConfig(adminConfig);