32 lines
962 B
TypeScript
32 lines
962 B
TypeScript
|
|
import React from 'react';
|
||
|
|
import { Routes, Route, Navigate } from 'react-router-dom';
|
||
|
|
import { apiClient } from './lib/api';
|
||
|
|
import Layout from './components/Layout';
|
||
|
|
import Login from './pages/Login';
|
||
|
|
import Dashboard from './pages/Dashboard';
|
||
|
|
import Articles from './pages/Articles';
|
||
|
|
import Feeds from './pages/Feeds';
|
||
|
|
import Settings from './pages/Settings';
|
||
|
|
|
||
|
|
function App() {
|
||
|
|
const isAuthenticated = apiClient.isAuthenticated();
|
||
|
|
|
||
|
|
if (!isAuthenticated) {
|
||
|
|
return <Login />;
|
||
|
|
}
|
||
|
|
|
||
|
|
return (
|
||
|
|
<Layout>
|
||
|
|
<Routes>
|
||
|
|
<Route path="/" element={<Navigate to="/dashboard" replace />} />
|
||
|
|
<Route path="/dashboard" element={<Dashboard />} />
|
||
|
|
<Route path="/articles" element={<Articles />} />
|
||
|
|
<Route path="/feeds" element={<Feeds />} />
|
||
|
|
<Route path="/settings" element={<Settings />} />
|
||
|
|
<Route path="*" element={<Navigate to="/dashboard" replace />} />
|
||
|
|
</Routes>
|
||
|
|
</Layout>
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
export default App;
|