import React, { useEffect, Suspense } from 'react'; import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import Navbar from './components/layout/Navbar'; import Hero from './components/layout/Hero'; import Footer from './components/layout/Footer'; import FeaturesSection from './components/home/FeaturesSection'; import TestimonialsSection from './components/home/TestimonialsSection'; import CTASection from './components/home/CTASection'; import FAQSection from './components/home/FAQSection'; import Loading from './components/common/Loading'; import { getFirebaseAuthInfo } from './services/userService'; import { ThemeProvider } from './contexts/ThemeContext'; import { NotificationProvider } from './contexts/NotificationContext'; import { PointsProvider } from './contexts/PointsContext'; import { ProgressProvider } from './contexts/ProgressContext'; import NotificationToast from './components/notification/NotificationToast'; import PointsChangeDetector from './components/points/PointsChangeDetector'; import ApiOperationWrapper from './utils/api/wrapper'; import { Link } from 'react-router-dom'; // Lazy load components const VideoDownloader = React.lazy(() => import('./components/workspace/VideoDownloader')); const Login = React.lazy(() => import('./components/auth/Login')); const Demo = React.lazy(() => import('./components/Demo')); const GetStarted = React.lazy(() => import('./components/GetStarted')); const SubscriptionSimple = React.lazy(() => import('./components/subscription/SubscriptionSimple')); const ProtectedRoute = React.lazy(() => import('./components/auth/ProtectedRoute')); const EmailVerification = React.lazy(() => import('./components/auth/EmailVerification')); const AuthDebug = React.lazy(() => import('./components/auth/AuthDebug')); const Workspace = React.lazy(() => import('./components/workspace/index')); const ProjectEditor = React.lazy(() => import('./components/project-editor/index')); const CheckOutStripe = React.lazy(() => import('./components/payment/CheckOutStripe')); const SubscriptionSuccess = React.lazy(() => import('./pages/SubscriptionSuccess')); const SubscriptionCancel = React.lazy(() => import('./pages/SubscriptionCancel')); const TermsOfService = React.lazy(() => import('./pages/TermsOfService')); const PrivacyPolicy = React.lazy(() => import('./pages/PrivacyPolicy')); const RefundPolicy = React.lazy(() => import('./pages/RefundPolicy')); const About = React.lazy(() => import('./pages/About')); const Contact = React.lazy(() => import('./pages/Contact')); const SubscriptionManagement = React.lazy(() => import('./components/subscription/SubscriptionManagement')); const PointsCenter = React.lazy(() => import('./components/points/PointsCenter')); // Home component to display the landing page content const Home = () => { // Lazy-load the component wrapper const LazyComponentWrapper = React.lazy(() => import('./components/common/LazyComponent').then(m => ({ default: m.LazyComponent }))); return ( <> {/* Hero is above the fold, render immediately */} {/* Below-the-fold sections: lazy load when entering viewport */} }> }> }> }> }> }> > ); }; // Layout component for consistent UI across protected routes const MainLayout = ({ children, hideFooter = false }: { children: React.ReactNode, hideFooter?: boolean }) => { return ( <> {children} {!hideFooter && } > ); }; // Workspace layout that hides the footer const WorkspaceLayoutWithNavbar = ({ children }: { children: React.ReactNode }) => { return ( <> {children} > ); }; // 创建一个使用翻译的成功页面组件 const PointsPurchaseSuccessPage = () => { const { t } = useTranslation('common'); return ( {t('points_center.payment_success')} {t('points_center.points_purchase_successful')} {t('points_center.return_to_points_center')} ); }; // 创建一个使用翻译的取消页面组件 const PointsPurchaseCancelPage = () => { const { t } = useTranslation('common'); return ( {t('points_center.payment_cancelled')} {t('points_center.cancel_points_purchase_warning')} {t('points_center.return_to_points_center')} ); }; function App() { // 移除阻塞式初始化,改为后台异步检查(仅用于开发调试) useEffect(() => { // 非阻塞式检查,仅在开发环境下输出日志 if (import.meta.env.DEV) { getFirebaseAuthInfo() .then(authInfo => { if (authInfo.project_id !== 'rescene-ai') { console.warn('[App Debug] Project ID mismatch: Frontend uses "rescene-ai" but backend returned:', authInfo.project_id); } }) .catch(error => { console.warn('[App Debug] Failed to get Firebase auth info (non-blocking):', error); }); } }, []); return ( }> {/* Public routes */} } /> {/* Email verification route */} } /> {/* Routes with Navbar and Footer */} } /> } /> } /> } /> {/* Legal and Information Pages */} } /> } /> } /> } /> } /> {/* 订阅管理路由 */} } /> {/* Debug route */} } /> {/* Protected routes (require authentication) */} } /> } /> } /> } /> } /> } /> } /> } /> {/* Checkout route */} } /> } /> } /> {/* Points Center Route */} } /> } /> } /> {/* Fallback route for any unmatched paths */} } /> ); } export default App;
{t('points_center.points_purchase_successful')}
{t('points_center.cancel_points_purchase_warning')}