fix: dynamic site name

This commit is contained in:
shinya
2025-06-30 23:48:35 +08:00
parent 240764e81b
commit 0563f2478e
4 changed files with 30 additions and 12 deletions

View File

@@ -8,11 +8,15 @@ import { ThemeProvider } from '../components/ThemeProvider';
const inter = Inter({ subsets: ['latin'] });
export const metadata: Metadata = {
title: process.env.NEXT_PUBLIC_SITE_NAME || 'MoonTV',
description: '影视聚合',
manifest: '/manifest.json',
};
export const dynamic = 'force-dynamic';
export function generateMetadata(): Metadata {
return {
title: process.env.NEXT_PUBLIC_SITE_NAME || 'MoonTV',
description: '影视聚合',
manifest: '/manifest.json',
};
}
export const viewport: Viewport = {
width: 'device-width',

View File

@@ -5,7 +5,9 @@ import { Suspense, useState } from 'react';
import { ThemeToggle } from '@/components/ThemeToggle';
function LoginPageClient() {
export const dynamic = 'force-dynamic';
function LoginPageClient({ siteName }: { siteName: string }) {
const router = useRouter();
const searchParams = useSearchParams();
const [password, setPassword] = useState('');
@@ -52,7 +54,7 @@ function LoginPageClient() {
</div>
<div className='relative z-10 w-full max-w-md rounded-3xl bg-gradient-to-b from-white/90 via-white/70 to-white/40 dark:from-zinc-900/90 dark:via-zinc-900/70 dark:to-zinc-900/40 backdrop-blur-xl shadow-2xl p-10 dark:border dark:border-zinc-800'>
<h1 className='text-green-600 tracking-tight text-center text-3xl font-extrabold mb-8 bg-clip-text drop-shadow-sm'>
{process.env.NEXT_PUBLIC_SITE_NAME || 'MoonTV'}
{siteName}
</h1>
<form onSubmit={handleSubmit} className='space-y-8'>
<div>
@@ -88,9 +90,10 @@ function LoginPageClient() {
}
export default function LoginPage() {
const siteName = process.env.NEXT_PUBLIC_SITE_NAME || 'MoonTV';
return (
<Suspense>
<LoginPageClient />
<LoginPageClient siteName={siteName} />
</Suspense>
);
}

View File

@@ -4,7 +4,10 @@ import Link from 'next/link';
import { ThemeToggle } from './ThemeToggle';
export const dynamic = 'force-dynamic';
const MobileHeader = () => {
const siteName = process.env.NEXT_PUBLIC_SITE_NAME || 'MoonTV';
return (
<header className='md:hidden relative w-full bg-white/70 backdrop-blur-xl border-b border-gray-200/50 shadow-sm dark:bg-gray-900/70 dark:border-gray-700/50'>
<div className='h-12 flex items-center justify-center'>
@@ -12,7 +15,7 @@ const MobileHeader = () => {
href='/'
className='text-2xl font-bold text-green-600 tracking-tight hover:opacity-80 transition-opacity'
>
{process.env.NEXT_PUBLIC_SITE_NAME || 'MoonTV'}
{siteName}
</Link>
</div>
<div className='absolute top-1/2 right-4 -translate-y-1/2'>

View File

@@ -33,13 +33,17 @@ const SidebarContext = createContext<SidebarContextType>({
export const useSidebar = () => useContext(SidebarContext);
// 可替换为你自己的 logo 图片
const Logo = () => (
interface LogoProps {
siteName: string;
}
const Logo = ({ siteName }: LogoProps) => (
<Link
href='/'
className='flex items-center justify-center h-16 select-none hover:opacity-80 transition-opacity duration-200'
>
<span className='text-2xl font-bold text-green-600 tracking-tight'>
{process.env.NEXT_PUBLIC_SITE_NAME || 'MoonTV'}
{siteName}
</span>
</Link>
);
@@ -56,6 +60,8 @@ declare global {
}
}
export const dynamic = 'force-dynamic';
const Sidebar = ({ onToggle, activePath = '/' }: SidebarProps) => {
const router = useRouter();
const pathname = usePathname();
@@ -158,6 +164,8 @@ const Sidebar = ({ onToggle, activePath = '/' }: SidebarProps) => {
{ icon: VenetianMask, label: '日漫', href: '/douban?type=tv&tag=日本动画' },
];
const siteName = process.env.NEXT_PUBLIC_SITE_NAME || 'MoonTV';
return (
<SidebarContext.Provider value={contextValue}>
{/* 在移动端隐藏侧边栏 */}
@@ -181,7 +189,7 @@ const Sidebar = ({ onToggle, activePath = '/' }: SidebarProps) => {
}`}
>
<div className='w-[calc(100%-4rem)] flex justify-center'>
{!isCollapsed && <Logo />}
{!isCollapsed && <Logo siteName={siteName} />}
</div>
</div>
<button