forked from xiaozhou26/icloud-hme
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
39 lines (37 loc) · 1.29 KB
/
Copy pathApp.tsx
File metadata and controls
39 lines (37 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { BrowserRouter, Navigate, Route, Routes } from 'react-router-dom'
import { AuthProvider, useAuth } from './auth/AuthProvider'
import { ToastProvider } from './components/ToastProvider'
import AppShell from './components/AppShell'
import LoginPage from './pages/LoginPage'
import AccountsPage from './pages/AccountsPage'
import AliasesPage from './pages/AliasesPage'
import InboxPage from './pages/InboxPage'
function ProtectedLayout() {
const { status } = useAuth()
if (status === 'checking') {
return <p className="empty-state" aria-busy="true">加载中…</p>
}
if (status === 'anonymous') {
return <Navigate to="/login" replace />
}
return <AppShell />
}
export default function App() {
return (
<BrowserRouter>
<AuthProvider>
<ToastProvider>
<Routes>
<Route path="/login" element={<LoginPage />} />
<Route element={<ProtectedLayout />}>
<Route path="/accounts" element={<AccountsPage />} />
<Route path="/aliases" element={<AliasesPage />} />
<Route path="/inbox" element={<InboxPage />} />
<Route path="*" element={<Navigate to="/accounts" replace />} />
</Route>
</Routes>
</ToastProvider>
</AuthProvider>
</BrowserRouter>
)
}