From 6d552d22d9e513ea70fab2e465bc92f51de445d6 Mon Sep 17 00:00:00 2001 From: Baorong Li Date: Mon, 5 Nov 2018 11:23:43 +0800 Subject: [PATCH 1/5] add doc about custom http header #829 --- docs/_sidebar.md | 1 + docs/request.md | 22 ++++++++++++++++++++++ docs/zh-cn/_sidebar.md | 1 + docs/zh-cn/request.md | 24 ++++++++++++++++++++++++ 4 files changed, 48 insertions(+) create mode 100644 docs/request.md create mode 100644 docs/zh-cn/request.md diff --git a/docs/_sidebar.md b/docs/_sidebar.md index 5a05267..5810e15 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) - Guide - [Deploy](deploy.md) 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 f38aecb..82bea5e 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/deploy.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 From efe7e743752c94b9542ea4be2cc05ecc278732ed Mon Sep 17 00:00:00 2001 From: Baorong Li Date: Wed, 7 Nov 2018 16:23:36 +0800 Subject: [PATCH 2/5] fix #913 handleMenuClick is not defined --- src/pages/user/components/List.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) 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` }, From 63b1ecf79fb32c9d01cc98a6c6e58023c56c5a8d Mon Sep 17 00:00:00 2001 From: Baorong Li Date: Fri, 9 Nov 2018 11:26:19 +0800 Subject: [PATCH 3/5] Upgrade umi@2.2.5 --- package.json | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 0d1c6f8..37cec07 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.4", "axios": "^0.18.0", "babel-core": "7.0.0-bridge.0", "classnames": "^2.2.6", @@ -34,8 +34,8 @@ "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": { @@ -49,25 +49,25 @@ "babel-plugin-module-resolver": "^3.1.1", "cross-env": "^5.2.0", "eslint": "^5.7.0", - "eslint-config-react-app": "^3.0.4", + "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", + "prettier": "^1.15.1", "stylelint": "^9.6.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.2.5", + "umi-plugin-react": "^1.2.2" }, "optionalDependencies": { - "puppeteer": "^1.9.0" + "puppeteer": "^1.10.0" }, "lint-staged": { "src/**/*.js": [ From 08a348090cae97f25372491959b7ff5092a9140b Mon Sep 17 00:00:00 2001 From: Baorong Li Date: Fri, 9 Nov 2018 23:16:42 +0800 Subject: [PATCH 4/5] upgrade umi@2.3.0-beta.1 --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 37cec07..799b9d8 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "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.15", "react-adsense": "^0.0.6", "react-countup": "^4.0.0-alpha.6", "react-draft-wysiwyg": "^1.12.13", @@ -63,8 +63,8 @@ "stylelint": "^9.6.0", "stylelint-config-prettier": "^4.0.0", "stylelint-config-standard": "^18.2.0", - "umi": "^2.2.5", - "umi-plugin-react": "^1.2.2" + "umi": "^2.3.0-beta.1", + "umi-plugin-react": "^1.2.3" }, "optionalDependencies": { "puppeteer": "^1.10.0" From 01abc5ca381b7887948640f84ca7c944c8f35518 Mon Sep 17 00:00:00 2001 From: Baorong Li Date: Sat, 10 Nov 2018 09:50:20 +0800 Subject: [PATCH 5/5] upgrade antd@3.10.5 --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 799b9d8..370c04d 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "dependencies": { "@lingui/react": "^2.7.0", "ant-design-pro": "^2.1.1", - "antd": "^3.10.4", + "antd": "^3.10.5", "axios": "^0.18.0", "babel-core": "7.0.0-bridge.0", "classnames": "^2.2.6", @@ -28,7 +28,7 @@ "path-to-regexp": "^2.4.0", "prop-types": "^15.6.2", "qs": "^6.5.2", - "rc-tween-one": "^2.2.15", + "rc-tween-one": "^2.2.16", "react-adsense": "^0.0.6", "react-countup": "^4.0.0-alpha.6", "react-draft-wysiwyg": "^1.12.13", @@ -48,7 +48,7 @@ "babel-plugin-macros": "^2.4.2", "babel-plugin-module-resolver": "^3.1.1", "cross-env": "^5.2.0", - "eslint": "^5.7.0", + "eslint": "^5.9.0", "eslint-config-react-app": "^3.0.5", "eslint-plugin-flowtype": "^3.0.0", "eslint-plugin-import": "^2.6.0", @@ -60,7 +60,7 @@ "mockjs": "^1.0.1-beta3", "module": "^1.2.5", "prettier": "^1.15.1", - "stylelint": "^9.6.0", + "stylelint": "^9.8.0", "stylelint-config-prettier": "^4.0.0", "stylelint-config-standard": "^18.2.0", "umi": "^2.3.0-beta.1",