import React, { lazy, Suspense } from 'react';
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
import LoadingState from './components/ui/LoadingState';

// 使用React.lazy实现组件懒加载
const OperationAgent = lazy(() => import('./pages/OperationAgent'));
const Homepage = lazy(() => import('./pages/Homepage'));
const Pricing = lazy(() => import('./pages/Pricing'));
const CaseStudy = lazy(() => import('./pages/CaseStudy'));
const LoginPage = lazy(() => import('./pages/Auth/LoginPage'));
const RegisterPage = lazy(() => import('./pages/Auth/RegisterPage'));

const AppRouter: React.FC = () => {
  return (
    <Router>
      <Suspense fallback={<LoadingState fullScreen={true} />}>
        <Routes>
          {/* 首页商业化路由 */}
          <Route path="/" element={<Homepage />} />
          <Route path="/pricing" element={<Pricing />} />
          <Route path="/case-study" element={<CaseStudy />} />
          <Route path="/case-study/:id" element={<CaseStudy />} />
          
          {/* 认证路由 */}
          <Route path="/auth/login" element={<LoginPage />} />
          <Route path="/auth/register" element={<RegisterPage />} />
          
          {/* 后台路由 */}
          <Route path="/operation-agent" element={<OperationAgent />} />
          <Route path="/dashboard" element={<OperationAgent />} />
        </Routes>
      </Suspense>
    </Router>
  );
};

export default AppRouter;
