tmdb增加代理支持
This commit is contained in:
@@ -298,6 +298,7 @@ interface SiteConfig {
|
||||
DanmakuApiBase: string;
|
||||
DanmakuApiToken: string;
|
||||
TMDBApiKey?: string;
|
||||
TMDBProxy?: string;
|
||||
EnableComments: boolean;
|
||||
EnableRegistration?: boolean;
|
||||
RegistrationRequireTurnstile?: boolean;
|
||||
@@ -4601,6 +4602,7 @@ const SiteConfigComponent = ({
|
||||
DanmakuApiBase: 'http://localhost:9321',
|
||||
DanmakuApiToken: '87654321',
|
||||
TMDBApiKey: '',
|
||||
TMDBProxy: '',
|
||||
EnableComments: false,
|
||||
EnableRegistration: false,
|
||||
RegistrationRequireTurnstile: false,
|
||||
@@ -4684,6 +4686,7 @@ const SiteConfigComponent = ({
|
||||
config.SiteConfig.DanmakuApiBase || 'http://localhost:9321',
|
||||
DanmakuApiToken: config.SiteConfig.DanmakuApiToken || '87654321',
|
||||
TMDBApiKey: config.SiteConfig.TMDBApiKey || '',
|
||||
TMDBProxy: config.SiteConfig.TMDBProxy || '',
|
||||
EnableComments: config.SiteConfig.EnableComments || false,
|
||||
});
|
||||
}
|
||||
@@ -5242,6 +5245,28 @@ const SiteConfigComponent = ({
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* TMDB Proxy */}
|
||||
<div>
|
||||
<label className='block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2'>
|
||||
TMDB 代理
|
||||
</label>
|
||||
<input
|
||||
type='text'
|
||||
placeholder='请输入代理地址(可选)'
|
||||
value={siteSettings.TMDBProxy}
|
||||
onChange={(e) =>
|
||||
setSiteSettings((prev) => ({
|
||||
...prev,
|
||||
TMDBProxy: e.target.value,
|
||||
}))
|
||||
}
|
||||
className='w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-green-500 focus:border-transparent'
|
||||
/>
|
||||
<p className='mt-1 text-xs text-gray-500 dark:text-gray-400'>
|
||||
配置代理服务器地址,用于访问 TMDB API(可选)
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 评论功能配置 */}
|
||||
|
||||
@@ -42,6 +42,7 @@ export async function POST(request: NextRequest) {
|
||||
DanmakuApiBase,
|
||||
DanmakuApiToken,
|
||||
TMDBApiKey,
|
||||
TMDBProxy,
|
||||
EnableComments,
|
||||
CustomAdFilterCode,
|
||||
CustomAdFilterVersion,
|
||||
@@ -74,6 +75,7 @@ export async function POST(request: NextRequest) {
|
||||
DanmakuApiBase: string;
|
||||
DanmakuApiToken: string;
|
||||
TMDBApiKey?: string;
|
||||
TMDBProxy?: string;
|
||||
EnableComments: boolean;
|
||||
CustomAdFilterCode?: string;
|
||||
CustomAdFilterVersion?: number;
|
||||
@@ -109,6 +111,7 @@ export async function POST(request: NextRequest) {
|
||||
typeof DanmakuApiBase !== 'string' ||
|
||||
typeof DanmakuApiToken !== 'string' ||
|
||||
(TMDBApiKey !== undefined && typeof TMDBApiKey !== 'string') ||
|
||||
(TMDBProxy !== undefined && typeof TMDBProxy !== 'string') ||
|
||||
typeof EnableComments !== 'boolean' ||
|
||||
(CustomAdFilterCode !== undefined && typeof CustomAdFilterCode !== 'string') ||
|
||||
(CustomAdFilterVersion !== undefined && typeof CustomAdFilterVersion !== 'number') ||
|
||||
@@ -159,6 +162,7 @@ export async function POST(request: NextRequest) {
|
||||
DanmakuApiBase,
|
||||
DanmakuApiToken,
|
||||
TMDBApiKey,
|
||||
TMDBProxy,
|
||||
EnableComments,
|
||||
CustomAdFilterCode,
|
||||
CustomAdFilterVersion,
|
||||
|
||||
@@ -27,6 +27,7 @@ export async function GET(request: NextRequest) {
|
||||
// 缓存不存在或已过期,获取新数据
|
||||
const config = await getConfig();
|
||||
const tmdbApiKey = config.SiteConfig?.TMDBApiKey;
|
||||
const tmdbProxy = config.SiteConfig?.TMDBProxy;
|
||||
|
||||
if (!tmdbApiKey) {
|
||||
return NextResponse.json(
|
||||
@@ -36,7 +37,7 @@ export async function GET(request: NextRequest) {
|
||||
}
|
||||
|
||||
// 调用TMDB API获取数据
|
||||
const result = await getTMDBUpcomingContent(tmdbApiKey);
|
||||
const result = await getTMDBUpcomingContent(tmdbApiKey, tmdbProxy);
|
||||
|
||||
if (result.code !== 200) {
|
||||
return NextResponse.json(
|
||||
|
||||
Reference in New Issue
Block a user