frontend/src/App.js

38 lines
1.1 KiB
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';
import edittemplate from './pages/exchangepage/edittemplate/main.js'
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="/edittemplate" exact={true} component={edittemplate} />
<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
}