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 {
namespace: 'error',
......@@ -9,32 +10,13 @@ export default {
},
effects: {
*query403(_, { call, put }) {
yield call(query403);
*query({ payload }, { call, put }) {
yield call(query, payload.code);
// redirect on client when network broken
yield put(routerRedux.push(`/exception/${payload.code}`));
yield put({
type: 'trigger',
payload: '403',
});
},
*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',
payload: payload.code,
});
},
},
......
......@@ -7,55 +7,34 @@ import styles from './style.less';
isloading: state.error.isloading,
}))
export default class TriggerException extends PureComponent {
state={
state = {
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({
isloading: true,
});
this.props.dispatch({
type: 'error/query404',
type: 'error/query',
payload: {
code,
},
});
};
render() {
return (
<Card>
<Spin spinning={this.state.isloading} wrapperClassName={styles.trigger}>
<Button type="danger" onClick={this.trigger401}>
<Button type="danger" onClick={() => this.triggerError(401)}>
触发401
</Button>
<Button type="danger" onClick={this.trigger403}>
<Button type="danger" onClick={() => this.triggerError(403)}>
触发403
</Button>
<Button type="danger" onClick={this.trigger500}>
<Button type="danger" onClick={() => this.triggerError(500)}>
触发500
</Button>
<Button type="danger" onClick={this.trigger404}>
<Button type="danger" onClick={() => this.triggerError(404)}>
触发404
</Button>
</Spin>
......
import request from '../utils/request';
export async function query404() {
return request('/api/404');
}
export async function query401() {
return request('/api/401');
}
export async function query403() {
return request('/api/403');
}
export async function query500() {
return request('/api/500');
export async function query(code) {
return request(`/api/${code}`);
}
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