// App.tsx
import React from 'react';
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
import BasicLayout from '../../layouts/BasicLayout';
import HomePage from './HomePage';
import AboutPage from './AboutPage';
import Login from '@/pages/security/Login';
import AppInitializer from './AppInitializer';

// 登录判断组件
const AppContent: React.FC = () => {
  const [initialized, setInitialized] = React.useState(false);

  if (!initialized) {
    return <AppInitializer onInitialized={() => setInitialized(true)} />;
  }

  return (
    <Router>
      <Login />
      <BasicLayout>
        <Routes>
          <Route path="/" element={<HomePage />} />
          <Route path="/about" element={<AboutPage />} />
        </Routes>
      </BasicLayout>
    </Router>
  );
};

const App: React.FC = () => {
  console.log('App component rendered');
  return <AppContent />;
};

export default App;
