File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,11 +7,12 @@ import Login from './views/Login/login';
77import Index from './views/Index' ;
88import PrivateRoute from './router/PrivateRoute' ;
99import NoMatch from './views/NoMatch' ;
10+ import history from './api/history' ;
1011import './App.css' ;
1112function App ( ) {
1213 return (
1314 < Provider store = { store } >
14- < Router basename = "/echo" >
15+ < Router basename = "/echo" history = { history } >
1516 < div className = "entryWrap" >
1617 < CSSTransition
1718 classNames = "fade"
Original file line number Diff line number Diff line change 1+ import { createBrowserHistory } from "history" ;
2+ export default createBrowserHistory ( { forceRefresh :true } ) ;
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import axios from "axios";
22import { fakeAuth } from '../util/fakeAuth' ;
33import { message as Message } from 'antd' ;
44import { timeout , baseURL } from "./config.js" ;
5- import redirect from './redirect ' ;
5+ import history from './history ' ;
66axios . defaults . timeout = timeout ;
77axios . defaults . baseURL = baseURL ;
88axios . interceptors . request . use (
@@ -21,21 +21,15 @@ axios.interceptors.response.use(
2121 return response ;
2222 } ,
2323 error => {
24- fakeAuth . signout ( ) ;
25- redirect ( ) ;
2624 if ( error . response ) {
2725 switch ( error . response . status ) {
2826 case 401 :
2927 fakeAuth . signout ( ) ;
30- redirect ( ) ;
28+ history . push ( '/login' ) ;
3129 break ;
3230 default :
3331 }
34- const message = error . response . data . message ?
35- error . response . data . message :
36- error . response . status === 401 ?
37- "登录过期,请重新登录" :
38- "服务器异常" ;
32+ const message = error . response . data . message ?error . response . data . message :"服务器异常" ;
3933 Message . error ( message ) ;
4034 }
4135 return Promise . reject ( error ) ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11import React , { Component } from 'react' ;
2- import { Layout } from 'antd' ;
2+ import { Layout , Button } from 'antd' ;
33import ContentMain from '../../components/ContentMain' ;
44import SiderNav from '../../components/SiderNav' ;
55import Avatar from '../Avatar'
66import './index.css' ;
7+ import gl_ajax from '../../api/index' ;
78const { Header, Content, Footer} = Layout ;
89export default class Index extends Component {
10+ handleClick ( ) {
11+ gl_ajax ( {
12+ method :'get' ,
13+ url :'/hello' ,
14+ data :{ } ,
15+ success ( res ) {
16+
17+ } ,
18+ error ( err ) {
19+
20+ }
21+ } ) ;
22+ }
923 render ( ) {
1024 return (
1125 < Layout >
@@ -16,6 +30,7 @@ export default class Index extends Component {
1630 </ Header >
1731 < Content style = { { margin : '24px 16px 0' } } >
1832 < ContentMain />
33+ < Button onClick = { this . handleClick . bind ( this ) } > </ Button >
1934 < Footer style = { { textAlign : 'center' } } > admin system ©2019 Created by Harhao</ Footer >
2035 </ Content >
2136 </ Layout >
You can’t perform that action at this time.
0 commit comments