This commit is contained in:
timorls 2022-01-12 22:02:40 +08:00
parent 3e438ff723
commit 8da40f804a
1 changed files with 5 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import Home from '@/pages/home'
import { Provider } from "react-redux" import { Provider } from "react-redux"
import { HashRouter, Switch, Route, Redirect } from 'react-router-dom' import { HashRouter, Switch, Route, Redirect } from 'react-router-dom'
function App() { function App() {
return ( return (
<Provider store={store}> <Provider store={store}>
@ -13,7 +14,10 @@ function App() {
<HashRouter> <HashRouter>
<Switch><Route path='/login' component={User} /></Switch> <Switch><Route path='/login' component={User} /></Switch>
<Switch><Route path='/home' component={Home} /></Switch> <Switch><Route path='/home' component={Home} /></Switch>
<Redirect from="/" to="/home" exact /> <Redirect from="/" to={(() => {
return localStorage.getItem("token") ?
'/home' : '/login'
})()} exact />
</HashRouter> </HashRouter>
</div> </div>
</Provider> </Provider>