frontend/src/App.js

36 lines
992 B
JavaScript
Raw Normal View History

import ReactDOM from 'react-dom';
import React, { Component } from 'react';
2021-11-16 14:35:18 +08:00
import { HashRouter as Router, Route, Link } from "react-router-dom";
import "./App.css"
import "./assets/comm.css"
2021-10-29 14:47:23 +08:00
import {Redirect} from "react-router-dom";
2021-12-03 15:03:49 +08:00
2021-10-29 14:47:23 +08:00
import login from './pages/login/login';
import home from './pages/home/home';
2021-12-02 19:34:28 +08:00
import errpage from "./pages/errpage/errpage"
export default class App extends Component {
state = {
pathname:'',
};
componentWillMount(){
const pathname=window.location.href.lastIndexOf('\/');
const pathnamestr=window.location.href.substr(pathname);
this.setState({pathname:`${pathnamestr}`});
}
render() {
return (
2021-10-29 14:47:23 +08:00
<Router>
2021-11-02 09:32:55 +08:00
<Route path="/login" exact={true} component={login} />
<Route path="/home" component={home} />
2021-11-02 09:32:55 +08:00
<Route exact={true} path="/" render={
2021-10-29 14:47:23 +08:00
()=> (
<Redirect to="/login"/>)}>
</Route>
2021-12-02 19:34:28 +08:00
<Route component={errpage} />
</Router>
);
}
2021-10-25 11:49:03 +08:00
}