增加弹幕内置源
This commit is contained in:
+93
-45
@@ -341,6 +341,7 @@ interface SiteConfig {
|
|||||||
DoubanImageProxy: string;
|
DoubanImageProxy: string;
|
||||||
DisableYellowFilter: boolean;
|
DisableYellowFilter: boolean;
|
||||||
FluidSearch: boolean;
|
FluidSearch: boolean;
|
||||||
|
DanmakuSourceType?: 'builtin' | 'custom';
|
||||||
DanmakuApiBase: string;
|
DanmakuApiBase: string;
|
||||||
DanmakuApiToken: string;
|
DanmakuApiToken: string;
|
||||||
TMDBApiKey?: string;
|
TMDBApiKey?: string;
|
||||||
@@ -7923,7 +7924,8 @@ const SiteConfigComponent = ({
|
|||||||
DoubanImageProxy: '',
|
DoubanImageProxy: '',
|
||||||
DisableYellowFilter: false,
|
DisableYellowFilter: false,
|
||||||
FluidSearch: true,
|
FluidSearch: true,
|
||||||
DanmakuApiBase: 'http://localhost:9321',
|
DanmakuSourceType: 'builtin',
|
||||||
|
DanmakuApiBase: 'https://mtvpls-danmu.netlify.app/87654321',
|
||||||
DanmakuApiToken: '87654321',
|
DanmakuApiToken: '87654321',
|
||||||
TMDBApiKey: '',
|
TMDBApiKey: '',
|
||||||
TMDBProxy: '',
|
TMDBProxy: '',
|
||||||
@@ -8018,6 +8020,7 @@ const SiteConfigComponent = ({
|
|||||||
DoubanImageProxy: config.SiteConfig.DoubanImageProxy || '',
|
DoubanImageProxy: config.SiteConfig.DoubanImageProxy || '',
|
||||||
DisableYellowFilter: config.SiteConfig.DisableYellowFilter || false,
|
DisableYellowFilter: config.SiteConfig.DisableYellowFilter || false,
|
||||||
FluidSearch: config.SiteConfig.FluidSearch || true,
|
FluidSearch: config.SiteConfig.FluidSearch || true,
|
||||||
|
DanmakuSourceType: config.SiteConfig.DanmakuSourceType || 'custom',
|
||||||
DanmakuApiBase:
|
DanmakuApiBase:
|
||||||
config.SiteConfig.DanmakuApiBase || 'http://localhost:9321',
|
config.SiteConfig.DanmakuApiBase || 'http://localhost:9321',
|
||||||
DanmakuApiToken: config.SiteConfig.DanmakuApiToken || '87654321',
|
DanmakuApiToken: config.SiteConfig.DanmakuApiToken || '87654321',
|
||||||
@@ -8567,57 +8570,102 @@ const SiteConfigComponent = ({
|
|||||||
弹幕配置
|
弹幕配置
|
||||||
</summary>
|
</summary>
|
||||||
<div className='mt-4 space-y-4'>
|
<div className='mt-4 space-y-4'>
|
||||||
{/* 弹幕 API 地址 */}
|
<div className='inline-flex rounded-lg bg-gray-100 p-1 dark:bg-gray-800'>
|
||||||
<div>
|
<button
|
||||||
<label className='block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2'>
|
type='button'
|
||||||
弹幕 API 地址
|
onClick={() =>
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
type='text'
|
|
||||||
placeholder='http://localhost:9321'
|
|
||||||
value={siteSettings.DanmakuApiBase}
|
|
||||||
onChange={(e) =>
|
|
||||||
setSiteSettings((prev) => ({
|
setSiteSettings((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
DanmakuApiBase: e.target.value,
|
DanmakuSourceType: 'builtin',
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
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'
|
className={`rounded-md px-3 py-1.5 text-sm transition-colors ${
|
||||||
/>
|
siteSettings.DanmakuSourceType !== 'custom'
|
||||||
<p className='mt-1 text-xs text-gray-500 dark:text-gray-400'>
|
? 'bg-white text-green-600 shadow-sm dark:bg-gray-700 dark:text-green-400'
|
||||||
弹幕服务器的 API 地址,默认为 http://localhost:9321。API部署参考
|
: 'text-gray-600 hover:text-gray-900 dark:text-gray-300 dark:hover:text-white'
|
||||||
<a
|
}`}
|
||||||
href='https://github.com/huangxd-/danmu_api.git'
|
>
|
||||||
target='_blank'
|
内置源
|
||||||
rel='noopener noreferrer'
|
</button>
|
||||||
className='text-blue-500 hover:text-blue-600 dark:text-blue-400 dark:hover:text-blue-300'
|
<button
|
||||||
>
|
type='button'
|
||||||
danmu_api
|
onClick={() =>
|
||||||
</a>
|
setSiteSettings((prev) => ({
|
||||||
</p>
|
...prev,
|
||||||
|
DanmakuSourceType: 'custom',
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
className={`rounded-md px-3 py-1.5 text-sm transition-colors ${
|
||||||
|
siteSettings.DanmakuSourceType === 'custom'
|
||||||
|
? 'bg-white text-green-600 shadow-sm dark:bg-gray-700 dark:text-green-400'
|
||||||
|
: 'text-gray-600 hover:text-gray-900 dark:text-gray-300 dark:hover:text-white'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
自定义源
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* 弹幕 API Token */}
|
{siteSettings.DanmakuSourceType !== 'custom' && (
|
||||||
<div>
|
<p className='text-xs text-amber-600 dark:text-amber-400'>
|
||||||
<label className='block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2'>
|
⚠️ 内置弹幕源为多人共享服务,稳定性可能受使用高峰影响,建议自行部署后使用自定义源。
|
||||||
弹幕 API Token
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
type='text'
|
|
||||||
placeholder='87654321'
|
|
||||||
value={siteSettings.DanmakuApiToken}
|
|
||||||
onChange={(e) =>
|
|
||||||
setSiteSettings((prev) => ({
|
|
||||||
...prev,
|
|
||||||
DanmakuApiToken: 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'>
|
|
||||||
弹幕服务器的访问令牌,默认为 87654321
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
)}
|
||||||
|
|
||||||
|
{siteSettings.DanmakuSourceType === 'custom' && (
|
||||||
|
<>
|
||||||
|
{/* 弹幕 API 地址 */}
|
||||||
|
<div>
|
||||||
|
<label className='block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2'>
|
||||||
|
弹幕 API 地址
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type='text'
|
||||||
|
placeholder='http://localhost:9321'
|
||||||
|
value={siteSettings.DanmakuApiBase}
|
||||||
|
onChange={(e) =>
|
||||||
|
setSiteSettings((prev) => ({
|
||||||
|
...prev,
|
||||||
|
DanmakuApiBase: 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'>
|
||||||
|
自定义弹幕服务器的 API 地址。API部署参考
|
||||||
|
<a
|
||||||
|
href='https://github.com/huangxd-/danmu_api.git'
|
||||||
|
target='_blank'
|
||||||
|
rel='noopener noreferrer'
|
||||||
|
className='ml-1 text-blue-500 hover:text-blue-600 dark:text-blue-400 dark:hover:text-blue-300'
|
||||||
|
>
|
||||||
|
danmu_api
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 弹幕 API Token */}
|
||||||
|
<div>
|
||||||
|
<label className='block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2'>
|
||||||
|
弹幕 API Token
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type='text'
|
||||||
|
placeholder='87654321'
|
||||||
|
value={siteSettings.DanmakuApiToken}
|
||||||
|
onChange={(e) =>
|
||||||
|
setSiteSettings((prev) => ({
|
||||||
|
...prev,
|
||||||
|
DanmakuApiToken: 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'>
|
||||||
|
自定义弹幕服务器的访问令牌,默认为 87654321
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ export async function POST(request: NextRequest) {
|
|||||||
DoubanImageProxy,
|
DoubanImageProxy,
|
||||||
DisableYellowFilter,
|
DisableYellowFilter,
|
||||||
FluidSearch,
|
FluidSearch,
|
||||||
|
DanmakuSourceType,
|
||||||
DanmakuApiBase,
|
DanmakuApiBase,
|
||||||
DanmakuApiToken,
|
DanmakuApiToken,
|
||||||
TMDBApiKey,
|
TMDBApiKey,
|
||||||
@@ -86,6 +87,7 @@ export async function POST(request: NextRequest) {
|
|||||||
DoubanImageProxy: string;
|
DoubanImageProxy: string;
|
||||||
DisableYellowFilter: boolean;
|
DisableYellowFilter: boolean;
|
||||||
FluidSearch: boolean;
|
FluidSearch: boolean;
|
||||||
|
DanmakuSourceType?: 'builtin' | 'custom';
|
||||||
DanmakuApiBase: string;
|
DanmakuApiBase: string;
|
||||||
DanmakuApiToken: string;
|
DanmakuApiToken: string;
|
||||||
TMDBApiKey?: string;
|
TMDBApiKey?: string;
|
||||||
@@ -136,6 +138,9 @@ export async function POST(request: NextRequest) {
|
|||||||
typeof DoubanImageProxy !== 'string' ||
|
typeof DoubanImageProxy !== 'string' ||
|
||||||
typeof DisableYellowFilter !== 'boolean' ||
|
typeof DisableYellowFilter !== 'boolean' ||
|
||||||
typeof FluidSearch !== 'boolean' ||
|
typeof FluidSearch !== 'boolean' ||
|
||||||
|
(DanmakuSourceType !== undefined &&
|
||||||
|
DanmakuSourceType !== 'builtin' &&
|
||||||
|
DanmakuSourceType !== 'custom') ||
|
||||||
typeof DanmakuApiBase !== 'string' ||
|
typeof DanmakuApiBase !== 'string' ||
|
||||||
typeof DanmakuApiToken !== 'string' ||
|
typeof DanmakuApiToken !== 'string' ||
|
||||||
(TMDBApiKey !== undefined && typeof TMDBApiKey !== 'string') ||
|
(TMDBApiKey !== undefined && typeof TMDBApiKey !== 'string') ||
|
||||||
@@ -195,6 +200,7 @@ export async function POST(request: NextRequest) {
|
|||||||
DoubanImageProxy,
|
DoubanImageProxy,
|
||||||
DisableYellowFilter,
|
DisableYellowFilter,
|
||||||
FluidSearch,
|
FluidSearch,
|
||||||
|
DanmakuSourceType,
|
||||||
DanmakuApiBase,
|
DanmakuApiBase,
|
||||||
DanmakuApiToken,
|
DanmakuApiToken,
|
||||||
TMDBApiKey,
|
TMDBApiKey,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import { NextRequest, NextResponse } from 'next/server';
|
import { NextRequest, NextResponse } from 'next/server';
|
||||||
|
|
||||||
import { getConfig } from '@/lib/config';
|
import { getConfig } from '@/lib/config';
|
||||||
|
import { getDanmakuApiBaseUrl } from '@/lib/danmaku/config';
|
||||||
|
|
||||||
export const runtime = 'nodejs';
|
export const runtime = 'nodejs';
|
||||||
|
|
||||||
@@ -50,13 +51,7 @@ export async function GET(request: NextRequest) {
|
|||||||
|
|
||||||
// 从数据库读取弹幕配置
|
// 从数据库读取弹幕配置
|
||||||
const config = await getConfig();
|
const config = await getConfig();
|
||||||
const { DanmakuApiBase, DanmakuApiToken } = config.SiteConfig;
|
const baseUrl = getDanmakuApiBaseUrl(config.SiteConfig);
|
||||||
|
|
||||||
// 构建 API URL
|
|
||||||
const baseUrl =
|
|
||||||
DanmakuApiToken === '87654321'
|
|
||||||
? DanmakuApiBase
|
|
||||||
: `${DanmakuApiBase}/${DanmakuApiToken}`;
|
|
||||||
|
|
||||||
let apiUrl: string;
|
let apiUrl: string;
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import { NextRequest, NextResponse } from 'next/server';
|
import { NextRequest, NextResponse } from 'next/server';
|
||||||
|
|
||||||
import { getConfig } from '@/lib/config';
|
import { getConfig } from '@/lib/config';
|
||||||
|
import { getDanmakuApiBaseUrl } from '@/lib/danmaku/config';
|
||||||
|
|
||||||
export const runtime = 'nodejs';
|
export const runtime = 'nodejs';
|
||||||
|
|
||||||
@@ -28,13 +29,7 @@ export async function GET(request: NextRequest) {
|
|||||||
|
|
||||||
// 从数据库读取弹幕配置
|
// 从数据库读取弹幕配置
|
||||||
const config = await getConfig();
|
const config = await getConfig();
|
||||||
const { DanmakuApiBase, DanmakuApiToken } = config.SiteConfig;
|
const baseUrl = getDanmakuApiBaseUrl(config.SiteConfig);
|
||||||
|
|
||||||
// 构建 API URL
|
|
||||||
const baseUrl =
|
|
||||||
DanmakuApiToken === '87654321'
|
|
||||||
? DanmakuApiBase
|
|
||||||
: `${DanmakuApiBase}/${DanmakuApiToken}`;
|
|
||||||
|
|
||||||
const apiUrl = `${baseUrl}/api/v2/bangumi/${animeId}`;
|
const apiUrl = `${baseUrl}/api/v2/bangumi/${animeId}`;
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import { NextRequest, NextResponse } from 'next/server';
|
import { NextRequest, NextResponse } from 'next/server';
|
||||||
|
|
||||||
import { getConfig } from '@/lib/config';
|
import { getConfig } from '@/lib/config';
|
||||||
|
import { getDanmakuApiBaseUrl } from '@/lib/danmaku/config';
|
||||||
|
|
||||||
export const runtime = 'nodejs';
|
export const runtime = 'nodejs';
|
||||||
|
|
||||||
@@ -25,13 +26,7 @@ export async function POST(request: NextRequest) {
|
|||||||
|
|
||||||
// 从数据库读取弹幕配置
|
// 从数据库读取弹幕配置
|
||||||
const config = await getConfig();
|
const config = await getConfig();
|
||||||
const { DanmakuApiBase, DanmakuApiToken } = config.SiteConfig;
|
const baseUrl = getDanmakuApiBaseUrl(config.SiteConfig);
|
||||||
|
|
||||||
// 构建 API URL
|
|
||||||
const baseUrl =
|
|
||||||
DanmakuApiToken === '87654321'
|
|
||||||
? DanmakuApiBase
|
|
||||||
: `${DanmakuApiBase}/${DanmakuApiToken}`;
|
|
||||||
|
|
||||||
const apiUrl = `${baseUrl}/api/v2/match`;
|
const apiUrl = `${baseUrl}/api/v2/match`;
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import { NextRequest, NextResponse } from 'next/server';
|
import { NextRequest, NextResponse } from 'next/server';
|
||||||
|
|
||||||
import { getConfig } from '@/lib/config';
|
import { getConfig } from '@/lib/config';
|
||||||
|
import { getDanmakuApiBaseUrl } from '@/lib/danmaku/config';
|
||||||
|
|
||||||
export const runtime = 'nodejs';
|
export const runtime = 'nodejs';
|
||||||
|
|
||||||
@@ -24,13 +25,7 @@ export async function GET(request: NextRequest) {
|
|||||||
|
|
||||||
// 从数据库读取弹幕配置
|
// 从数据库读取弹幕配置
|
||||||
const config = await getConfig();
|
const config = await getConfig();
|
||||||
const { DanmakuApiBase, DanmakuApiToken } = config.SiteConfig;
|
const baseUrl = getDanmakuApiBaseUrl(config.SiteConfig);
|
||||||
|
|
||||||
// 构建 API URL
|
|
||||||
const baseUrl =
|
|
||||||
DanmakuApiToken === '87654321'
|
|
||||||
? DanmakuApiBase
|
|
||||||
: `${DanmakuApiBase}/${DanmakuApiToken}`;
|
|
||||||
|
|
||||||
const apiUrl = `${baseUrl}/api/v2/search/anime?keyword=${encodeURIComponent(keyword)}`;
|
const apiUrl = `${baseUrl}/api/v2/search/anime?keyword=${encodeURIComponent(keyword)}`;
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ export interface AdminConfig {
|
|||||||
DisableYellowFilter: boolean;
|
DisableYellowFilter: boolean;
|
||||||
FluidSearch: boolean;
|
FluidSearch: boolean;
|
||||||
// 弹幕配置
|
// 弹幕配置
|
||||||
|
DanmakuSourceType?: 'builtin' | 'custom';
|
||||||
DanmakuApiBase: string;
|
DanmakuApiBase: string;
|
||||||
DanmakuApiToken: string;
|
DanmakuApiToken: string;
|
||||||
// TMDB配置
|
// TMDB配置
|
||||||
|
|||||||
+18
-3
@@ -4,6 +4,8 @@ import { db } from '@/lib/db';
|
|||||||
|
|
||||||
import { AdminConfig } from './admin.types';
|
import { AdminConfig } from './admin.types';
|
||||||
|
|
||||||
|
const BUILTIN_DANMAKU_API_BASE = 'https://mtvpls-danmu.netlify.app/87654321';
|
||||||
|
|
||||||
export interface ApiSite {
|
export interface ApiSite {
|
||||||
key: string;
|
key: string;
|
||||||
api: string;
|
api: string;
|
||||||
@@ -223,6 +225,9 @@ async function getInitConfig(configFile: string, subConfig: {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
cfgFile = {} as ConfigFileStruct;
|
cfgFile = {} as ConfigFileStruct;
|
||||||
}
|
}
|
||||||
|
const hasCustomDanmakuEnv = Boolean(
|
||||||
|
process.env.DANMAKU_API_BASE || process.env.DANMAKU_API_TOKEN
|
||||||
|
);
|
||||||
const adminConfig: AdminConfig = {
|
const adminConfig: AdminConfig = {
|
||||||
ConfigFile: configSource,
|
ConfigFile: configSource,
|
||||||
ConfigSubscribtion: subConfig,
|
ConfigSubscribtion: subConfig,
|
||||||
@@ -245,7 +250,10 @@ async function getInitConfig(configFile: string, subConfig: {
|
|||||||
FluidSearch:
|
FluidSearch:
|
||||||
process.env.NEXT_PUBLIC_FLUID_SEARCH !== 'false',
|
process.env.NEXT_PUBLIC_FLUID_SEARCH !== 'false',
|
||||||
// 弹幕配置
|
// 弹幕配置
|
||||||
DanmakuApiBase: process.env.DANMAKU_API_BASE || 'http://localhost:9321',
|
DanmakuSourceType: hasCustomDanmakuEnv ? 'custom' : 'builtin',
|
||||||
|
DanmakuApiBase:
|
||||||
|
process.env.DANMAKU_API_BASE ||
|
||||||
|
(hasCustomDanmakuEnv ? 'http://localhost:9321' : BUILTIN_DANMAKU_API_BASE),
|
||||||
DanmakuApiToken: process.env.DANMAKU_API_TOKEN || '87654321',
|
DanmakuApiToken: process.env.DANMAKU_API_TOKEN || '87654321',
|
||||||
// TMDB配置
|
// TMDB配置
|
||||||
TMDBApiKey: process.env.TMDB_API_KEY || '',
|
TMDBApiKey: process.env.TMDB_API_KEY || '',
|
||||||
@@ -439,7 +447,8 @@ export function configSelfCheck(adminConfig: AdminConfig): AdminConfig {
|
|||||||
DoubanImageProxy: '',
|
DoubanImageProxy: '',
|
||||||
DisableYellowFilter: false,
|
DisableYellowFilter: false,
|
||||||
FluidSearch: true,
|
FluidSearch: true,
|
||||||
DanmakuApiBase: 'http://localhost:9321',
|
DanmakuSourceType: 'builtin',
|
||||||
|
DanmakuApiBase: BUILTIN_DANMAKU_API_BASE,
|
||||||
DanmakuApiToken: '87654321',
|
DanmakuApiToken: '87654321',
|
||||||
PansouApiUrl: '',
|
PansouApiUrl: '',
|
||||||
PansouUsername: '',
|
PansouUsername: '',
|
||||||
@@ -461,8 +470,14 @@ export function configSelfCheck(adminConfig: AdminConfig): AdminConfig {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
// 确保弹幕配置存在
|
// 确保弹幕配置存在
|
||||||
|
if (adminConfig.SiteConfig.DanmakuSourceType === undefined) {
|
||||||
|
adminConfig.SiteConfig.DanmakuSourceType = 'custom';
|
||||||
|
}
|
||||||
if (!adminConfig.SiteConfig.DanmakuApiBase) {
|
if (!adminConfig.SiteConfig.DanmakuApiBase) {
|
||||||
adminConfig.SiteConfig.DanmakuApiBase = 'http://localhost:9321';
|
adminConfig.SiteConfig.DanmakuApiBase =
|
||||||
|
adminConfig.SiteConfig.DanmakuSourceType === 'builtin'
|
||||||
|
? BUILTIN_DANMAKU_API_BASE
|
||||||
|
: 'http://localhost:9321';
|
||||||
}
|
}
|
||||||
if (!adminConfig.SiteConfig.DanmakuApiToken) {
|
if (!adminConfig.SiteConfig.DanmakuApiToken) {
|
||||||
adminConfig.SiteConfig.DanmakuApiToken = '87654321';
|
adminConfig.SiteConfig.DanmakuApiToken = '87654321';
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import type { AdminConfig } from '@/lib/admin.types';
|
||||||
|
|
||||||
|
export const BUILTIN_DANMAKU_API_BASE = 'https://mtvpls-danmu.netlify.app/87654321';
|
||||||
|
export const BUILTIN_DANMAKU_API_TOKEN = '87654321';
|
||||||
|
|
||||||
|
function trimTrailingSlash(value: string) {
|
||||||
|
return value.replace(/\/+$/, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getDanmakuApiBaseUrl(siteConfig: AdminConfig['SiteConfig']) {
|
||||||
|
if (siteConfig.DanmakuSourceType === 'builtin') {
|
||||||
|
return BUILTIN_DANMAKU_API_BASE;
|
||||||
|
}
|
||||||
|
|
||||||
|
const base = trimTrailingSlash(siteConfig.DanmakuApiBase || 'http://localhost:9321');
|
||||||
|
const token = (siteConfig.DanmakuApiToken || BUILTIN_DANMAKU_API_TOKEN).trim();
|
||||||
|
|
||||||
|
return token === BUILTIN_DANMAKU_API_TOKEN ? base : `${base}/${token}`;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user