mirror of https://github.com/msgbyte/tailchat
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import React from 'react';
|
|
import { BrowserRouter, Redirect, Route, Switch } from 'react-router-dom';
|
|
import { useStorage } from 'pawchat-shared';
|
|
import clsx from 'clsx';
|
|
import { Loadable } from './components/Loadable';
|
|
|
|
import './dark.less';
|
|
|
|
const MainRoute = Loadable(() =>
|
|
import('./routes/Main').then((module) => module.MainRoute)
|
|
);
|
|
|
|
const EntryRoute = Loadable(() =>
|
|
import('./routes/Entry').then((module) => module.EntryRoute)
|
|
);
|
|
|
|
const AppProvider: React.FC = React.memo((props) => {
|
|
return <BrowserRouter>{props.children}</BrowserRouter>;
|
|
});
|
|
AppProvider.displayName = 'AppProvider';
|
|
|
|
export const App: React.FC = React.memo(() => {
|
|
const [darkMode] = useStorage('darkMode', true);
|
|
|
|
return (
|
|
<div
|
|
className={clsx('h-screen w-screen min-h-screen', {
|
|
dark: darkMode,
|
|
})}
|
|
>
|
|
<AppProvider>
|
|
<Switch>
|
|
<Route path="/entry" component={EntryRoute} />
|
|
<Route path="/main" component={MainRoute} />
|
|
<Redirect to="/entry" />
|
|
</Switch>
|
|
</AppProvider>
|
|
</div>
|
|
);
|
|
});
|
|
App.displayName = 'App';
|