metacubexd/src/App.tsx

47 lines
1.4 KiB
TypeScript
Raw Normal View History

2023-08-27 22:25:41 +08:00
import { Route, Routes, useNavigate } from '@solidjs/router'
import { Show, lazy, onMount } from 'solid-js'
2023-08-24 04:20:53 +08:00
import { Header } from '~/components/Header'
2023-08-27 22:25:41 +08:00
import { curTheme, selectedEndpoint } from '~/signals'
2023-08-24 04:20:53 +08:00
const Setup = lazy(() => import('~/pages/Setup'))
const Overview = lazy(() => import('~/pages/Overview'))
const Connections = lazy(() => import('~/pages/Connections'))
const Logs = lazy(() => import('~/pages/Logs'))
const Proxies = lazy(() => import('~/pages/Proxies'))
const Rules = lazy(() => import('~/pages/Rules'))
const Config = lazy(() => import('~/pages/Config'))
2023-08-24 04:20:53 +08:00
export const App = () => {
const navigate = useNavigate()
onMount(() => {
if (!selectedEndpoint()) {
navigate('/setup')
}
})
return (
<div
2023-08-29 00:03:32 +08:00
class="relative flex h-screen flex-col subpixel-antialiased"
data-theme={curTheme()}
>
2023-08-27 22:25:41 +08:00
<Header />
2023-08-24 04:20:53 +08:00
2023-08-29 00:03:32 +08:00
<div class="flex-1 overflow-y-auto p-4">
2023-08-24 04:20:53 +08:00
<Routes>
<Show when={selectedEndpoint()}>
<Route path="/" component={Overview} />
<Route path="/proxies" component={Proxies} />
<Route path="/rules" component={Rules} />
<Route path="/conns" component={Connections} />
<Route path="/logs" component={Logs} />
<Route path="/config" component={Config} />
</Show>
<Route path="/setup" component={Setup} />
</Routes>
</div>
</div>
)
}