Unverified Commit 303c5e43 authored by niko's avatar niko Committed by GitHub

Remove Error Trigger dump code & support static env (#1128)

* remove dump code

* compatibility for static
parent 603bcd7c
import { query403, query401, query404, query500 } from '../services/error'; import { routerRedux } from 'dva/router';
import { query } from '../services/error';
export default { export default {
namespace: 'error', namespace: 'error',
...@@ -9,32 +10,13 @@ export default { ...@@ -9,32 +10,13 @@ export default {
}, },
effects: { effects: {
*query403(_, { call, put }) { *query({ payload }, { call, put }) {
yield call(query403); yield call(query, payload.code);
// redirect on client when network broken
yield put(routerRedux.push(`/exception/${payload.code}`));
yield put({ yield put({
type: 'trigger', type: 'trigger',
payload: '403', payload: payload.code,
});
},
*query401(_, { call, put }) {
yield call(query401);
yield put({
type: 'trigger',
payload: '401',
});
},
*query500(_, { call, put }) {
yield call(query500);
yield put({
type: 'trigger',
payload: '500',
});
},
*query404(_, { call, put }) {
yield call(query404);
yield put({
type: 'trigger',
payload: '404',
}); });
}, },
}, },
......
...@@ -7,55 +7,34 @@ import styles from './style.less'; ...@@ -7,55 +7,34 @@ import styles from './style.less';
isloading: state.error.isloading, isloading: state.error.isloading,
})) }))
export default class TriggerException extends PureComponent { export default class TriggerException extends PureComponent {
state={ state = {
isloading: false, isloading: false,
}
trigger401 = () => {
this.setState({
isloading: true,
});
this.props.dispatch({
type: 'error/query401',
});
};
trigger403 = () => {
this.setState({
isloading: true,
});
this.props.dispatch({
type: 'error/query403',
});
};
trigger500 = () => {
this.setState({
isloading: true,
});
this.props.dispatch({
type: 'error/query500',
});
}; };
trigger404 = () => { triggerError = (code) => {
this.setState({ this.setState({
isloading: true, isloading: true,
}); });
this.props.dispatch({ this.props.dispatch({
type: 'error/query404', type: 'error/query',
payload: {
code,
},
}); });
}; };
render() { render() {
return ( return (
<Card> <Card>
<Spin spinning={this.state.isloading} wrapperClassName={styles.trigger}> <Spin spinning={this.state.isloading} wrapperClassName={styles.trigger}>
<Button type="danger" onClick={this.trigger401}> <Button type="danger" onClick={() => this.triggerError(401)}>
触发401 触发401
</Button> </Button>
<Button type="danger" onClick={this.trigger403}> <Button type="danger" onClick={() => this.triggerError(403)}>
触发403 触发403
</Button> </Button>
<Button type="danger" onClick={this.trigger500}> <Button type="danger" onClick={() => this.triggerError(500)}>
触发500 触发500
</Button> </Button>
<Button type="danger" onClick={this.trigger404}> <Button type="danger" onClick={() => this.triggerError(404)}>
触发404 触发404
</Button> </Button>
</Spin> </Spin>
......
import request from '../utils/request'; import request from '../utils/request';
export async function query404() { export async function query(code) {
return request('/api/404'); return request(`/api/${code}`);
}
export async function query401() {
return request('/api/401');
}
export async function query403() {
return request('/api/403');
}
export async function query500() {
return request('/api/500');
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment