2025-08-12 21:50:58 +08:00
|
|
|
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
|
|
|
|
|
|
|
|
|
|
import type { Metadata, Viewport } from 'next';
|
|
|
|
|
|
import { Inter } from 'next/font/google';
|
|
|
|
|
|
|
|
|
|
|
|
import './globals.css';
|
|
|
|
|
|
|
|
|
|
|
|
import { getConfig } from '@/lib/config';
|
|
|
|
|
|
|
|
|
|
|
|
import { GlobalErrorIndicator } from '../components/GlobalErrorIndicator';
|
|
|
|
|
|
import { SiteProvider } from '../components/SiteProvider';
|
|
|
|
|
|
import { ThemeProvider } from '../components/ThemeProvider';
|
2025-12-06 21:39:37 +08:00
|
|
|
|
import { WatchRoomProvider } from '../components/WatchRoomProvider';
|
|
|
|
|
|
import ChatFloatingWindow from '../components/watch-room/ChatFloatingWindow';
|
2025-12-09 22:31:35 +08:00
|
|
|
|
import { DownloadProvider } from '../contexts/DownloadContext';
|
|
|
|
|
|
import { DownloadBubble } from '../components/DownloadBubble';
|
|
|
|
|
|
import { DownloadPanel } from '../components/DownloadPanel';
|
2025-12-10 00:13:08 +08:00
|
|
|
|
import { DanmakuCacheCleanup } from '../components/DanmakuCacheCleanup';
|
2026-01-04 15:25:53 +08:00
|
|
|
|
import TopProgressBar from '../components/TopProgressBar';
|
2025-08-12 21:50:58 +08:00
|
|
|
|
|
|
|
|
|
|
const inter = Inter({ subsets: ['latin'] });
|
2025-08-18 23:04:27 +08:00
|
|
|
|
export const dynamic = 'force-dynamic';
|
2025-08-12 21:50:58 +08:00
|
|
|
|
|
|
|
|
|
|
// 动态生成 metadata,支持配置更新后的标题变化
|
|
|
|
|
|
export async function generateMetadata(): Promise<Metadata> {
|
2025-08-13 22:07:28 +08:00
|
|
|
|
const storageType = process.env.NEXT_PUBLIC_STORAGE_TYPE || 'localstorage';
|
|
|
|
|
|
const config = await getConfig();
|
2025-12-14 23:25:43 +08:00
|
|
|
|
let siteName = process.env.NEXT_PUBLIC_SITE_NAME || 'MoonTVPlus';
|
2025-08-13 22:07:28 +08:00
|
|
|
|
if (storageType !== 'localstorage') {
|
2025-08-12 21:50:58 +08:00
|
|
|
|
siteName = config.SiteConfig.SiteName;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
title: siteName,
|
|
|
|
|
|
description: '影视聚合',
|
|
|
|
|
|
manifest: '/manifest.json',
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export const viewport: Viewport = {
|
|
|
|
|
|
viewportFit: 'cover',
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export default async function RootLayout({
|
|
|
|
|
|
children,
|
|
|
|
|
|
}: {
|
|
|
|
|
|
children: React.ReactNode;
|
|
|
|
|
|
}) {
|
2025-08-13 00:30:31 +08:00
|
|
|
|
const storageType = process.env.NEXT_PUBLIC_STORAGE_TYPE || 'localstorage';
|
|
|
|
|
|
|
2025-12-14 23:25:43 +08:00
|
|
|
|
let siteName = process.env.NEXT_PUBLIC_SITE_NAME || 'MoonTVPlus';
|
2025-08-12 21:50:58 +08:00
|
|
|
|
let announcement =
|
|
|
|
|
|
process.env.ANNOUNCEMENT ||
|
|
|
|
|
|
'本网站仅提供影视信息搜索服务,所有内容均来自第三方网站。本站不存储任何视频资源,不对任何内容的准确性、合法性、完整性负责。';
|
2025-08-18 23:15:37 +08:00
|
|
|
|
|
2025-08-26 22:53:04 +08:00
|
|
|
|
let doubanProxyType = process.env.NEXT_PUBLIC_DOUBAN_PROXY_TYPE || 'cmliussss-cdn-tencent';
|
2025-08-12 21:50:58 +08:00
|
|
|
|
let doubanProxy = process.env.NEXT_PUBLIC_DOUBAN_PROXY || '';
|
|
|
|
|
|
let doubanImageProxyType =
|
2025-08-26 22:53:04 +08:00
|
|
|
|
process.env.NEXT_PUBLIC_DOUBAN_IMAGE_PROXY_TYPE || 'cmliussss-cdn-tencent';
|
2025-08-12 21:50:58 +08:00
|
|
|
|
let doubanImageProxy = process.env.NEXT_PUBLIC_DOUBAN_IMAGE_PROXY || '';
|
|
|
|
|
|
let disableYellowFilter =
|
|
|
|
|
|
process.env.NEXT_PUBLIC_DISABLE_YELLOW_FILTER === 'true';
|
2025-08-17 17:32:42 +08:00
|
|
|
|
let fluidSearch = process.env.NEXT_PUBLIC_FLUID_SEARCH !== 'false';
|
2025-12-03 18:20:34 +08:00
|
|
|
|
let enableComments = false;
|
2025-12-27 23:45:34 +08:00
|
|
|
|
let recommendationDataSource = 'Mixed';
|
2025-12-14 22:15:38 +08:00
|
|
|
|
let tmdbApiKey = '';
|
2025-12-22 00:42:27 +08:00
|
|
|
|
let openListEnabled = false;
|
2026-01-03 22:21:08 +08:00
|
|
|
|
let embyEnabled = false;
|
2026-01-10 21:21:08 +08:00
|
|
|
|
let xiaoyaEnabled = false;
|
2025-12-28 12:12:11 +08:00
|
|
|
|
let loginBackgroundImage = '';
|
|
|
|
|
|
let registerBackgroundImage = '';
|
|
|
|
|
|
let enableRegistration = false;
|
|
|
|
|
|
let loginRequireTurnstile = false;
|
|
|
|
|
|
let registrationRequireTurnstile = false;
|
|
|
|
|
|
let turnstileSiteKey = '';
|
|
|
|
|
|
let enableOIDCLogin = false;
|
|
|
|
|
|
let enableOIDCRegistration = false;
|
|
|
|
|
|
let oidcButtonText = '';
|
2025-12-29 14:41:59 +08:00
|
|
|
|
let aiEnabled = false;
|
|
|
|
|
|
let aiEnableHomepageEntry = false;
|
|
|
|
|
|
let aiEnableVideoCardEntry = false;
|
|
|
|
|
|
let aiEnablePlayPageEntry = false;
|
2026-01-09 17:34:07 +08:00
|
|
|
|
let aiDefaultMessageNoVideo = '';
|
|
|
|
|
|
let aiDefaultMessageWithVideo = '';
|
2026-01-12 21:06:45 +08:00
|
|
|
|
let enableMovieRequest = true;
|
2026-01-21 00:16:42 +08:00
|
|
|
|
let webLiveEnabled = false;
|
2026-01-23 00:54:08 +08:00
|
|
|
|
let customAdFilterVersion = 0;
|
2025-08-13 22:07:28 +08:00
|
|
|
|
let customCategories = [] as {
|
|
|
|
|
|
name: string;
|
|
|
|
|
|
type: 'movie' | 'tv';
|
|
|
|
|
|
query: string;
|
|
|
|
|
|
}[];
|
|
|
|
|
|
if (storageType !== 'localstorage') {
|
2025-08-12 21:50:58 +08:00
|
|
|
|
const config = await getConfig();
|
|
|
|
|
|
siteName = config.SiteConfig.SiteName;
|
|
|
|
|
|
announcement = config.SiteConfig.Announcement;
|
2025-08-18 23:15:37 +08:00
|
|
|
|
|
2025-08-12 21:50:58 +08:00
|
|
|
|
doubanProxyType = config.SiteConfig.DoubanProxyType;
|
|
|
|
|
|
doubanProxy = config.SiteConfig.DoubanProxy;
|
|
|
|
|
|
doubanImageProxyType = config.SiteConfig.DoubanImageProxyType;
|
|
|
|
|
|
doubanImageProxy = config.SiteConfig.DoubanImageProxy;
|
|
|
|
|
|
disableYellowFilter = config.SiteConfig.DisableYellowFilter;
|
2025-08-13 22:07:28 +08:00
|
|
|
|
customCategories = config.CustomCategories.filter(
|
|
|
|
|
|
(category) => !category.disabled
|
|
|
|
|
|
).map((category) => ({
|
|
|
|
|
|
name: category.name || '',
|
|
|
|
|
|
type: category.type,
|
|
|
|
|
|
query: category.query,
|
|
|
|
|
|
}));
|
2025-08-17 17:32:42 +08:00
|
|
|
|
fluidSearch = config.SiteConfig.FluidSearch;
|
2025-12-03 18:20:34 +08:00
|
|
|
|
enableComments = config.SiteConfig.EnableComments;
|
2025-12-27 23:45:34 +08:00
|
|
|
|
recommendationDataSource = config.SiteConfig.RecommendationDataSource || 'Mixed';
|
2025-12-14 22:15:38 +08:00
|
|
|
|
tmdbApiKey = config.SiteConfig.TMDBApiKey || '';
|
2025-12-28 12:12:11 +08:00
|
|
|
|
loginBackgroundImage = config.ThemeConfig?.loginBackgroundImage || '';
|
|
|
|
|
|
registerBackgroundImage = config.ThemeConfig?.registerBackgroundImage || '';
|
|
|
|
|
|
enableRegistration = config.SiteConfig.EnableRegistration || false;
|
|
|
|
|
|
loginRequireTurnstile = config.SiteConfig.LoginRequireTurnstile || false;
|
|
|
|
|
|
registrationRequireTurnstile = config.SiteConfig.RegistrationRequireTurnstile || false;
|
|
|
|
|
|
turnstileSiteKey = config.SiteConfig.TurnstileSiteKey || '';
|
|
|
|
|
|
enableOIDCLogin = config.SiteConfig.EnableOIDCLogin || false;
|
|
|
|
|
|
enableOIDCRegistration = config.SiteConfig.EnableOIDCRegistration || false;
|
|
|
|
|
|
oidcButtonText = config.SiteConfig.OIDCButtonText || '';
|
2025-12-29 14:41:59 +08:00
|
|
|
|
// AI配置
|
|
|
|
|
|
aiEnabled = config.AIConfig?.Enabled || false;
|
|
|
|
|
|
aiEnableHomepageEntry = config.AIConfig?.EnableHomepageEntry || false;
|
|
|
|
|
|
aiEnableVideoCardEntry = config.AIConfig?.EnableVideoCardEntry || false;
|
|
|
|
|
|
aiEnablePlayPageEntry = config.AIConfig?.EnablePlayPageEntry || false;
|
2026-01-09 17:34:07 +08:00
|
|
|
|
aiDefaultMessageNoVideo = config.AIConfig?.DefaultMessageNoVideo || '';
|
|
|
|
|
|
aiDefaultMessageWithVideo = config.AIConfig?.DefaultMessageWithVideo || '';
|
2026-01-12 21:06:45 +08:00
|
|
|
|
// 求片功能配置
|
|
|
|
|
|
enableMovieRequest = config.SiteConfig.EnableMovieRequest ?? true;
|
2026-01-21 00:16:42 +08:00
|
|
|
|
// 网络直播功能配置
|
|
|
|
|
|
webLiveEnabled = config.WebLiveEnabled ?? false;
|
2026-01-23 00:54:08 +08:00
|
|
|
|
// 自定义去广告代码版本号
|
|
|
|
|
|
customAdFilterVersion = config.SiteConfig?.CustomAdFilterVersion || 0;
|
2025-12-22 23:08:03 +08:00
|
|
|
|
// 检查是否启用了 OpenList 功能
|
2025-12-22 00:42:27 +08:00
|
|
|
|
openListEnabled = !!(
|
2025-12-22 23:08:03 +08:00
|
|
|
|
config.OpenListConfig?.Enabled &&
|
2025-12-22 21:38:51 +08:00
|
|
|
|
config.OpenListConfig?.URL &&
|
|
|
|
|
|
config.OpenListConfig?.Username &&
|
|
|
|
|
|
config.OpenListConfig?.Password
|
2025-12-22 00:42:27 +08:00
|
|
|
|
);
|
2026-01-08 00:14:07 +08:00
|
|
|
|
// 检查是否启用了 Emby 功能(支持多源)
|
2026-01-03 22:21:08 +08:00
|
|
|
|
embyEnabled = !!(
|
2026-01-08 00:14:07 +08:00
|
|
|
|
config.EmbyConfig?.Sources &&
|
|
|
|
|
|
config.EmbyConfig.Sources.length > 0 &&
|
|
|
|
|
|
config.EmbyConfig.Sources.some(s => s.enabled && s.ServerURL)
|
2026-01-03 22:21:08 +08:00
|
|
|
|
);
|
2026-01-10 21:21:08 +08:00
|
|
|
|
// 检查是否启用了小雅功能
|
|
|
|
|
|
xiaoyaEnabled = !!(
|
|
|
|
|
|
config.XiaoyaConfig?.Enabled &&
|
|
|
|
|
|
config.XiaoyaConfig?.ServerURL
|
|
|
|
|
|
);
|
2025-08-12 21:50:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 将运行时配置注入到全局 window 对象,供客户端在运行时读取
|
|
|
|
|
|
const runtimeConfig = {
|
|
|
|
|
|
STORAGE_TYPE: process.env.NEXT_PUBLIC_STORAGE_TYPE || 'localstorage',
|
|
|
|
|
|
DOUBAN_PROXY_TYPE: doubanProxyType,
|
|
|
|
|
|
DOUBAN_PROXY: doubanProxy,
|
|
|
|
|
|
DOUBAN_IMAGE_PROXY_TYPE: doubanImageProxyType,
|
|
|
|
|
|
DOUBAN_IMAGE_PROXY: doubanImageProxy,
|
|
|
|
|
|
DISABLE_YELLOW_FILTER: disableYellowFilter,
|
2025-08-13 22:07:28 +08:00
|
|
|
|
CUSTOM_CATEGORIES: customCategories,
|
2025-08-17 17:32:42 +08:00
|
|
|
|
FLUID_SEARCH: fluidSearch,
|
2025-12-03 18:20:34 +08:00
|
|
|
|
EnableComments: enableComments,
|
2025-12-27 23:45:34 +08:00
|
|
|
|
RecommendationDataSource: recommendationDataSource,
|
2025-12-09 21:33:15 +08:00
|
|
|
|
ENABLE_TVBOX_SUBSCRIBE: process.env.ENABLE_TVBOX_SUBSCRIBE === 'true',
|
2025-12-17 21:24:44 +08:00
|
|
|
|
ENABLE_OFFLINE_DOWNLOAD: process.env.NEXT_PUBLIC_ENABLE_OFFLINE_DOWNLOAD === 'true',
|
|
|
|
|
|
VOICE_CHAT_STRATEGY: process.env.NEXT_PUBLIC_VOICE_CHAT_STRATEGY || 'webrtc-fallback',
|
2025-12-22 00:42:27 +08:00
|
|
|
|
OPENLIST_ENABLED: openListEnabled,
|
2026-01-03 22:21:08 +08:00
|
|
|
|
EMBY_ENABLED: embyEnabled,
|
2026-01-10 21:21:08 +08:00
|
|
|
|
XIAOYA_ENABLED: xiaoyaEnabled,
|
|
|
|
|
|
PRIVATE_LIBRARY_ENABLED: openListEnabled || embyEnabled || xiaoyaEnabled,
|
2025-12-28 12:12:11 +08:00
|
|
|
|
LOGIN_BACKGROUND_IMAGE: loginBackgroundImage,
|
|
|
|
|
|
REGISTER_BACKGROUND_IMAGE: registerBackgroundImage,
|
|
|
|
|
|
ENABLE_REGISTRATION: enableRegistration,
|
|
|
|
|
|
LOGIN_REQUIRE_TURNSTILE: loginRequireTurnstile,
|
|
|
|
|
|
REGISTRATION_REQUIRE_TURNSTILE: registrationRequireTurnstile,
|
|
|
|
|
|
TURNSTILE_SITE_KEY: turnstileSiteKey,
|
|
|
|
|
|
ENABLE_OIDC_LOGIN: enableOIDCLogin,
|
|
|
|
|
|
ENABLE_OIDC_REGISTRATION: enableOIDCRegistration,
|
|
|
|
|
|
OIDC_BUTTON_TEXT: oidcButtonText,
|
2025-12-29 14:41:59 +08:00
|
|
|
|
AI_ENABLED: aiEnabled,
|
|
|
|
|
|
AI_ENABLE_HOMEPAGE_ENTRY: aiEnableHomepageEntry,
|
|
|
|
|
|
AI_ENABLE_VIDEOCARD_ENTRY: aiEnableVideoCardEntry,
|
|
|
|
|
|
AI_ENABLE_PLAYPAGE_ENTRY: aiEnablePlayPageEntry,
|
2026-01-09 17:34:07 +08:00
|
|
|
|
AI_DEFAULT_MESSAGE_NO_VIDEO: aiDefaultMessageNoVideo,
|
|
|
|
|
|
AI_DEFAULT_MESSAGE_WITH_VIDEO: aiDefaultMessageWithVideo,
|
2026-01-12 21:06:45 +08:00
|
|
|
|
ENABLE_MOVIE_REQUEST: enableMovieRequest,
|
2026-01-21 00:16:42 +08:00
|
|
|
|
WEB_LIVE_ENABLED: webLiveEnabled,
|
2026-01-23 00:54:08 +08:00
|
|
|
|
CUSTOM_AD_FILTER_VERSION: customAdFilterVersion,
|
2026-01-23 11:24:18 +08:00
|
|
|
|
FESTIVE_EFFECT_ENABLED:
|
|
|
|
|
|
process.env.FESTIVE_EFFECT_ENABLED === 'true',
|
2025-08-12 21:50:58 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<html lang='zh-CN' suppressHydrationWarning>
|
|
|
|
|
|
<head>
|
|
|
|
|
|
<meta
|
|
|
|
|
|
name='viewport'
|
|
|
|
|
|
content='width=device-width, initial-scale=1.0, viewport-fit=cover'
|
|
|
|
|
|
/>
|
|
|
|
|
|
<link rel='apple-touch-icon' href='/icons/icon-192x192.png' />
|
2025-12-12 18:06:34 +08:00
|
|
|
|
{/* 主题CSS */}
|
|
|
|
|
|
<link rel='stylesheet' href='/api/theme/css' />
|
2025-08-12 21:50:58 +08:00
|
|
|
|
{/* 将配置序列化后直接写入脚本,浏览器端可通过 window.RUNTIME_CONFIG 获取 */}
|
|
|
|
|
|
{/* eslint-disable-next-line @next/next/no-sync-scripts */}
|
|
|
|
|
|
<script
|
|
|
|
|
|
dangerouslySetInnerHTML={{
|
|
|
|
|
|
__html: `window.RUNTIME_CONFIG = ${JSON.stringify(runtimeConfig)};`,
|
|
|
|
|
|
}}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</head>
|
|
|
|
|
|
<body
|
|
|
|
|
|
className={`${inter.className} min-h-screen bg-white text-gray-900 dark:bg-black dark:text-gray-200`}
|
|
|
|
|
|
>
|
|
|
|
|
|
<ThemeProvider
|
|
|
|
|
|
attribute='class'
|
|
|
|
|
|
defaultTheme='system'
|
|
|
|
|
|
enableSystem
|
|
|
|
|
|
disableTransitionOnChange
|
|
|
|
|
|
>
|
2026-01-04 15:25:53 +08:00
|
|
|
|
<TopProgressBar />
|
2025-12-14 22:15:38 +08:00
|
|
|
|
<SiteProvider siteName={siteName} announcement={announcement} tmdbApiKey={tmdbApiKey}>
|
2025-12-06 21:39:37 +08:00
|
|
|
|
<WatchRoomProvider>
|
2025-12-09 22:31:35 +08:00
|
|
|
|
<DownloadProvider>
|
2025-12-10 00:13:08 +08:00
|
|
|
|
<DanmakuCacheCleanup />
|
2025-12-09 22:31:35 +08:00
|
|
|
|
{children}
|
|
|
|
|
|
<GlobalErrorIndicator />
|
|
|
|
|
|
<ChatFloatingWindow />
|
|
|
|
|
|
<DownloadBubble />
|
|
|
|
|
|
<DownloadPanel />
|
|
|
|
|
|
</DownloadProvider>
|
2025-12-06 21:39:37 +08:00
|
|
|
|
</WatchRoomProvider>
|
2025-08-12 21:50:58 +08:00
|
|
|
|
</SiteProvider>
|
|
|
|
|
|
</ThemeProvider>
|
|
|
|
|
|
</body>
|
|
|
|
|
|
</html>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|