修正观影室管理面板设置

This commit is contained in:
mtvpls
2025-12-08 10:03:25 +08:00
parent 857f7ce73e
commit b99a495a8a
7 changed files with 322 additions and 68 deletions
@@ -0,0 +1,49 @@
/* eslint-disable no-console */
import { NextRequest, NextResponse } from 'next/server';
import { getConfig } from '@/lib/config';
export const runtime = 'nodejs';
export async function GET(request: NextRequest) {
try {
const storageType = process.env.NEXT_PUBLIC_STORAGE_TYPE || 'localstorage';
// 调试信息
const debugInfo = {
storageType,
envVars: {
hasRedisUrl: !!process.env.REDIS_URL,
hasUpstashUrl: !!process.env.UPSTASH_REDIS_REST_URL,
hasUpstashToken: !!process.env.UPSTASH_REDIS_REST_TOKEN,
hasKvrocksUrl: !!process.env.KVROCKS_URL,
},
watchRoomConfig: null as any,
configReadError: null as string | null,
};
// 尝试读取配置
try {
const config = await getConfig();
debugInfo.watchRoomConfig = config.WatchRoomConfig || null;
} catch (error) {
debugInfo.configReadError = (error as Error).message;
}
return NextResponse.json(debugInfo, {
headers: {
'Cache-Control': 'no-store',
},
});
} catch (error) {
console.error('Debug API error:', error);
return NextResponse.json(
{
error: 'Failed to get debug info',
details: (error as Error).message,
},
{ status: 500 }
);
}
}
+28 -1
View File
@@ -10,11 +10,38 @@ export const runtime = 'nodejs';
export async function GET(request: NextRequest) {
console.log('server-config called: ', request.url);
const storageType = process.env.NEXT_PUBLIC_STORAGE_TYPE || 'localstorage';
// 如果使用 localStorage,返回默认配置
if (storageType === 'localstorage') {
return NextResponse.json({
SiteName: process.env.NEXT_PUBLIC_SITE_NAME || 'MoonTV',
StorageType: 'localstorage',
Version: CURRENT_VERSION,
// localStorage 模式下,返回默认观影室配置
// 可以通过环境变量控制是否启用
WatchRoom: {
enabled: process.env.WATCH_ROOM_ENABLED === 'true',
serverType: 'internal',
externalServerUrl: undefined,
externalServerAuth: undefined,
},
});
}
// 非 localStorage 模式,从数据库读取配置
const config = await getConfig();
const result = {
SiteName: config.SiteConfig.SiteName,
StorageType: process.env.NEXT_PUBLIC_STORAGE_TYPE || 'localstorage',
StorageType: storageType,
Version: CURRENT_VERSION,
// 添加观影室配置(供所有用户访问)
WatchRoom: {
enabled: config.WatchRoomConfig?.enabled ?? false,
serverType: config.WatchRoomConfig?.serverType ?? 'internal',
externalServerUrl: config.WatchRoomConfig?.externalServerUrl,
externalServerAuth: config.WatchRoomConfig?.externalServerAuth,
},
};
return NextResponse.json(result);
}