import { Routes, Route, Navigate } from 'react-router-dom';
import MainLayout from '../components/Layout/MainLayout';
import Login from '../pages/Login';
import Home from '../pages/Home';
import KnowledgeBaseList from '../pages/KnowledgeBaseList';
import PipelineConfig from '../pages/PipelineConfig';
import Dashboard from '../pages/Dashboard';
import ModelsResources from '../pages/ModelsResources';
import MCP from '../pages/MCP';

const AppRoutes = () => {
  return (
    <Routes>
      <Route path="/login" element={<Login />} />
      
      {/* 使用MainLayout作为受保护路由的布局 */}
      <Route path="/" element={<MainLayout />}>
        <Route index element={<Home />} />
        <Route path="kb-list" element={<KnowledgeBaseList />} />
        <Route path="pipeline-config" element={<PipelineConfig />} />
        <Route path="dashboard" element={<Dashboard />} />
        <Route path="models-resources" element={<ModelsResources />} />
        <Route path="mcp" element={<MCP />} />
      </Route>
      
      {/* 处理未匹配的路由 */}
      <Route path="*" element={<Navigate to="/" replace />} />
    </Routes>
  );
};

export default AppRoutes;