Browse Source

减少属性访问 (#731)

* 减少属性访问

* Update request.js
pull/2676/head
LiuTongTong 8 years ago
committed by ddcat1115
parent
commit
c06d16a1b3
  1. 9
      src/utils/request.js

9
src/utils/request.js

@ -66,21 +66,22 @@ export default function request(url, options) {
}) })
.catch((e) => { .catch((e) => {
const { dispatch } = store; const { dispatch } = store;
if (e.name === 401) { const status = e.name;
if (status === 401) {
dispatch({ dispatch({
type: 'login/logout', type: 'login/logout',
}); });
return; return;
} }
if (e.name === 403) { if (status === 403) {
dispatch(routerRedux.push('/exception/403')); dispatch(routerRedux.push('/exception/403'));
return; return;
} }
if (e.name <= 504 && e.name >= 500) { if (status <= 504 && status >= 500) {
dispatch(routerRedux.push('/exception/500')); dispatch(routerRedux.push('/exception/500'));
return; return;
} }
if (e.name >= 404 && e.name < 422) { if (status >= 404 && status < 422) {
dispatch(routerRedux.push('/exception/404')); dispatch(routerRedux.push('/exception/404'));
} }
}); });

Loading…
Cancel
Save