'use client';

import { useEffect } from 'react';
import { useRouter } from 'next/navigation';

export default function RootPage() {
    const router = useRouter();

    useEffect(() => {
        // 检测浏览器语言并重定向到相应的语言路径
        const browserLang = navigator.language;
        let detectedLang = 'zh-CN';

        if (browserLang.startsWith('zh-TW') || browserLang.startsWith('zh-HK')) {
            detectedLang = 'zh-TW';
        } else if (browserLang.startsWith('zh')) {
            detectedLang = 'zh-CN';
        } else {
            detectedLang = 'en';
        }

        router.replace(`/${detectedLang}`);
    }, [router]);

    // 显示加载状态
    return (
        <div className="min-h-screen bg-gray-900 text-white flex items-center justify-center">
            <div className="text-center">
                <div className="w-16 h-16 border-4 border-cyan-400 border-t-transparent rounded-full animate-spin mx-auto mb-4"></div>
                <p className="text-gray-300">正在加载...</p>
            </div>
        </div>
    );
}
