初始化 antd-pro
This commit is contained in:
15
admin-web/src/pages/Exception/403.js
Normal file
15
admin-web/src/pages/Exception/403.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import React from 'react';
|
||||
import { formatMessage } from 'umi/locale';
|
||||
import Link from 'umi/link';
|
||||
import Exception from '@/components/Exception';
|
||||
|
||||
const Exception403 = () => (
|
||||
<Exception
|
||||
type="403"
|
||||
desc={formatMessage({ id: 'app.exception.description.403' })}
|
||||
linkElement={Link}
|
||||
backText={formatMessage({ id: 'app.exception.back' })}
|
||||
/>
|
||||
);
|
||||
|
||||
export default Exception403;
|
||||
15
admin-web/src/pages/Exception/404.js
Normal file
15
admin-web/src/pages/Exception/404.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import React from 'react';
|
||||
import { formatMessage } from 'umi/locale';
|
||||
import Link from 'umi/link';
|
||||
import Exception from '@/components/Exception';
|
||||
|
||||
const Exception404 = () => (
|
||||
<Exception
|
||||
type="404"
|
||||
desc={formatMessage({ id: 'app.exception.description.404' })}
|
||||
linkElement={Link}
|
||||
backText={formatMessage({ id: 'app.exception.back' })}
|
||||
/>
|
||||
);
|
||||
|
||||
export default Exception404;
|
||||
15
admin-web/src/pages/Exception/500.js
Normal file
15
admin-web/src/pages/Exception/500.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import React from 'react';
|
||||
import { formatMessage } from 'umi/locale';
|
||||
import Link from 'umi/link';
|
||||
import Exception from '@/components/Exception';
|
||||
|
||||
const Exception500 = () => (
|
||||
<Exception
|
||||
type="500"
|
||||
desc={formatMessage({ id: 'app.exception.description.500' })}
|
||||
linkElement={Link}
|
||||
backText={formatMessage({ id: 'app.exception.back' })}
|
||||
/>
|
||||
);
|
||||
|
||||
export default Exception500;
|
||||
50
admin-web/src/pages/Exception/TriggerException.js
Normal file
50
admin-web/src/pages/Exception/TriggerException.js
Normal file
@@ -0,0 +1,50 @@
|
||||
import React, { PureComponent } from 'react';
|
||||
import { Button, Spin, Card } from 'antd';
|
||||
import { connect } from 'dva';
|
||||
import styles from './style.less';
|
||||
|
||||
@connect(state => ({
|
||||
isloading: state.error.isloading,
|
||||
}))
|
||||
class TriggerException extends PureComponent {
|
||||
state = {
|
||||
isloading: false,
|
||||
};
|
||||
|
||||
triggerError = code => {
|
||||
this.setState({
|
||||
isloading: true,
|
||||
});
|
||||
const { dispatch } = this.props;
|
||||
dispatch({
|
||||
type: 'error/query',
|
||||
payload: {
|
||||
code,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
render() {
|
||||
const { isloading } = this.state;
|
||||
return (
|
||||
<Card>
|
||||
<Spin spinning={isloading} wrapperClassName={styles.trigger}>
|
||||
<Button type="danger" onClick={() => this.triggerError(401)}>
|
||||
触发401
|
||||
</Button>
|
||||
<Button type="danger" onClick={() => this.triggerError(403)}>
|
||||
触发403
|
||||
</Button>
|
||||
<Button type="danger" onClick={() => this.triggerError(500)}>
|
||||
触发500
|
||||
</Button>
|
||||
<Button type="danger" onClick={() => this.triggerError(404)}>
|
||||
触发404
|
||||
</Button>
|
||||
</Spin>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default TriggerException;
|
||||
28
admin-web/src/pages/Exception/models/error.js
Normal file
28
admin-web/src/pages/Exception/models/error.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import queryError from '@/services/error';
|
||||
|
||||
export default {
|
||||
namespace: 'error',
|
||||
|
||||
state: {
|
||||
error: '',
|
||||
isloading: false,
|
||||
},
|
||||
|
||||
effects: {
|
||||
*query({ payload }, { call, put }) {
|
||||
yield call(queryError, payload.code);
|
||||
yield put({
|
||||
type: 'trigger',
|
||||
payload: payload.code,
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
reducers: {
|
||||
trigger(state, action) {
|
||||
return {
|
||||
error: action.payload,
|
||||
};
|
||||
},
|
||||
},
|
||||
};
|
||||
7
admin-web/src/pages/Exception/style.less
Normal file
7
admin-web/src/pages/Exception/style.less
Normal file
@@ -0,0 +1,7 @@
|
||||
.trigger {
|
||||
background: 'red';
|
||||
:global(.ant-btn) {
|
||||
margin-right: 8px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user