移动云盘在线播放

This commit is contained in:
mtvpls
2026-04-26 17:41:56 +08:00
parent d8d7e57eab
commit c877397682
16 changed files with 984 additions and 104 deletions
+24 -2
View File
@@ -5,6 +5,10 @@ import { NextRequest, NextResponse } from 'next/server';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { getConfig, setCachedConfig } from '@/lib/config';
import { db } from '@/lib/db';
import {
assertMobileAuthorizationHeaderSafe,
normalizeMobileAuthorization,
} from '@/lib/netdisk/mobile.client';
import {
assertQuarkCookieHeaderSafe,
normalizeQuarkCookie,
@@ -40,11 +44,14 @@ export async function POST(request: NextRequest) {
}
const body = await request.json();
const { action, Quark } = body;
const { action, Quark, Mobile, provider } = body;
const adminConfig = await getConfig();
if (action === 'save') {
const normalizedCookie = Quark?.Cookie ? assertQuarkCookieHeaderSafe(Quark.Cookie) : '';
const normalizedMobileAuthorization = Mobile?.Authorization
? assertMobileAuthorizationHeaderSafe(Mobile.Authorization)
: '';
adminConfig.NetDiskConfig = adminConfig.NetDiskConfig || {};
adminConfig.NetDiskConfig.Quark = {
@@ -54,6 +61,10 @@ export async function POST(request: NextRequest) {
PlayTempSavePath: Quark?.PlayTempSavePath || '/',
OpenListTempPath: Quark?.OpenListTempPath || '/',
};
adminConfig.NetDiskConfig.Mobile = {
Enabled: Boolean(Mobile?.Enabled),
Authorization: normalizedMobileAuthorization,
};
await db.saveAdminConfig(adminConfig);
await setCachedConfig(adminConfig);
@@ -62,10 +73,21 @@ export async function POST(request: NextRequest) {
}
if (action === 'validate') {
if (provider === 'mobile') {
if (!Mobile?.Authorization) {
return NextResponse.json({ error: '请先填写移动云盘 Authorization' }, { status: 400 });
}
normalizeMobileAuthorization(Mobile.Authorization);
return NextResponse.json({
success: true,
message: '移动云盘 Authorization 格式正常',
});
}
if (!Quark?.Cookie) {
return NextResponse.json({ error: '请先填写夸克 Cookie' }, { status: 400 });
}
await validateQuarkCookieReadable(normalizeQuarkCookie(Quark.Cookie));
return NextResponse.json({