diff --git a/docs/_sidebar.md b/docs/_sidebar.md index 5f4cfb8..96f2071 100644 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -1,6 +1,7 @@ - Getting started - [Quick Start](getting-started.md) - Customization + - [Request](request.md) - [Configuration](configuration.md) - [API Configuration](API-configuration.md) - Guide diff --git a/docs/request.md b/docs/request.md new file mode 100644 index 0000000..69d6607 --- /dev/null +++ b/docs/request.md @@ -0,0 +1,22 @@ +# HTTP request + +this project use axios for http service, file located in src/utils/request.js + +## Custom Header + +As for privilege access or modify cookie, you could add header param by yourself + +``` +axios.defaults.headers.common['Authorization'] = 'token' +``` + +Or + +``` +axios.interceptors.request.use(function (config) { + config.headers.token = window.localStorage.getItem('token'); + return config; +}, function (error) { + return Promise.reject(error); +}); +``` \ No newline at end of file diff --git a/docs/zh-cn/_sidebar.md b/docs/zh-cn/_sidebar.md index 3b2672a..c8efceb 100644 --- a/docs/zh-cn/_sidebar.md +++ b/docs/zh-cn/_sidebar.md @@ -1,6 +1,7 @@ - 入门 - [快速上手](zh-cn/getting-started.md) - 定制化 + - [http请求](zh-cn/request.md) - [配置项](zh-cn/configuration.md) - [接口配置](zh-cn/API-configuration.md) - 指南 diff --git a/docs/zh-cn/request.md b/docs/zh-cn/request.md new file mode 100644 index 0000000..a87022c --- /dev/null +++ b/docs/zh-cn/request.md @@ -0,0 +1,24 @@ +# HTTP请求 + +本项目使用了axios提供http请求服务,文件在src/utils/request.js + +## 自定义Header + +为了提供鉴权、修改cookie等服务,可以手动修改Header + +``` +axios.defaults.headers.common['Authorization'] = 'token' +``` + +或者 + +``` +// 添加请求拦截器 +axios.interceptors.request.use(function (config) { + // 在发送请求之前做些什么 + config.headers.token = window.localStorage.getItem('token'); + return config; +}, function (error) { + return Promise.reject(error); +}); +``` \ No newline at end of file diff --git a/package.json b/package.json index 0d1c6f8..370c04d 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,8 @@ "description": "An admin dashboard application demo built upon Ant Design and UmiJS", "dependencies": { "@lingui/react": "^2.7.0", - "ant-design-pro": "^2.1.0", - "antd": "^3.10.0", + "ant-design-pro": "^2.1.1", + "antd": "^3.10.5", "axios": "^0.18.0", "babel-core": "7.0.0-bridge.0", "classnames": "^2.2.6", @@ -28,14 +28,14 @@ "path-to-regexp": "^2.4.0", "prop-types": "^15.6.2", "qs": "^6.5.2", - "rc-tween-one": "^2.2.8", + "rc-tween-one": "^2.2.16", "react-adsense": "^0.0.6", "react-countup": "^4.0.0-alpha.6", "react-draft-wysiwyg": "^1.12.13", "react-helmet": "^5.2.0", "react-highcharts": "^16.0.2", - "react-perfect-scrollbar": "^1.4.0", - "recharts": "^1.3.0", + "react-perfect-scrollbar": "^1.4.2", + "recharts": "^1.3.6", "store": "^2.0.12" }, "devDependencies": { @@ -48,26 +48,26 @@ "babel-plugin-macros": "^2.4.2", "babel-plugin-module-resolver": "^3.1.1", "cross-env": "^5.2.0", - "eslint": "^5.7.0", - "eslint-config-react-app": "^3.0.4", + "eslint": "^5.9.0", + "eslint-config-react-app": "^3.0.5", "eslint-plugin-flowtype": "^3.0.0", "eslint-plugin-import": "^2.6.0", "eslint-plugin-jsx-a11y": "^6.1.1", "eslint-plugin-react": "^7.1.0", - "husky": "^1.1.1", + "husky": "^1.1.3", "less-vars-to-js": "^1.3.0", - "lint-staged": "^7.3.0", + "lint-staged": "^8.0.4", "mockjs": "^1.0.1-beta3", "module": "^1.2.5", - "prettier": "^1.14.3", - "stylelint": "^9.6.0", + "prettier": "^1.15.1", + "stylelint": "^9.8.0", "stylelint-config-prettier": "^4.0.0", "stylelint-config-standard": "^18.2.0", - "umi": "^2.2.1", - "umi-plugin-react": "^1.2.0" + "umi": "^2.3.0-beta.1", + "umi-plugin-react": "^1.2.3" }, "optionalDependencies": { - "puppeteer": "^1.9.0" + "puppeteer": "^1.10.0" }, "lint-staged": { "src/**/*.js": [ diff --git a/src/pages/user/components/List.js b/src/pages/user/components/List.js index 73c61bf..1e7c45d 100644 --- a/src/pages/user/components/List.js +++ b/src/pages/user/components/List.js @@ -26,13 +26,7 @@ class List extends PureComponent { } render() { - const { - handleMenuClick, - onDeleteItem, - onEditItem, - i18n, - ...tableProps - } = this.props + const { onDeleteItem, onEditItem, i18n, ...tableProps } = this.props const columns = [ { @@ -92,7 +86,7 @@ class List extends PureComponent { render: (text, record) => { return ( handleMenuClick(record, e)} + onMenuClick={e => this.handleMenuClick(record, e)} menuOptions={[ { key: '1', name: i18n.t`Update` }, { key: '2', name: i18n.t`Delete` },