Merge branch 'master' into release/1.0
Showing
8 changed files
with
22 additions
and
12 deletions
@@ -12,7 +12,7 @@ export default { | @@ -12,7 +12,7 @@ export default { | ||
12 | }, | 12 | }, |
13 | production: { | 13 | production: { |
14 | historyMode: 'history', | 14 | historyMode: 'history', |
15 | - shopsFeDomain: 'http://shops.yohops.com', | 15 | + shopsFeDomain: 'http://shops.yohobuy.com', |
16 | axiosBaseUrl: '/Api', | 16 | axiosBaseUrl: '/Api', |
17 | axiosResponseType: 'json', | 17 | axiosResponseType: 'json', |
18 | homePage: 'home.overview', | 18 | homePage: 'home.overview', |
@@ -4,7 +4,6 @@ | @@ -4,7 +4,6 @@ | ||
4 | import _ from 'lodash'; | 4 | import _ from 'lodash'; |
5 | import axios from 'axios'; | 5 | import axios from 'axios'; |
6 | import userService from 'user-service'; | 6 | import userService from 'user-service'; |
7 | -import iView from 'iview'; | ||
8 | import Rsa from 'rsa'; | 7 | import Rsa from 'rsa'; |
9 | 8 | ||
10 | const plugin = { | 9 | const plugin = { |
@@ -100,15 +99,11 @@ const plugin = { | @@ -100,15 +99,11 @@ const plugin = { | ||
100 | Vue.$router.push('/login.html'); | 99 | Vue.$router.push('/login.html'); |
101 | }; | 100 | }; |
102 | axios.defaults.validateStatus = (status) => { | 101 | axios.defaults.validateStatus = (status) => { |
103 | - if (status >= 200 && status < 300) { | ||
104 | - return true; | ||
105 | - } | ||
106 | if (status === 401) { | 102 | if (status === 401) { |
107 | Vue.logout(); | 103 | Vue.logout(); |
108 | return false; | 104 | return false; |
109 | } | 105 | } |
110 | - iView.Message.error('接口异常'); | ||
111 | - return false; | 106 | + return true; |
112 | }; | 107 | }; |
113 | } | 108 | } |
114 | }; | 109 | }; |
@@ -93,6 +93,16 @@ const plugin = { | @@ -93,6 +93,16 @@ const plugin = { | ||
93 | // 设置axios默认参数 | 93 | // 设置axios默认参数 |
94 | axios.defaults.baseURL = Vue.$config.axiosBaseUrl; | 94 | axios.defaults.baseURL = Vue.$config.axiosBaseUrl; |
95 | axios.defaults.responseType = Vue.$config.axiosResponseType; | 95 | axios.defaults.responseType = Vue.$config.axiosResponseType; |
96 | + | ||
97 | + axios.interceptors.response.use(response => { | ||
98 | + if (response.status >= 200 && response.status < 300) { | ||
99 | + return response; | ||
100 | + } | ||
101 | + iView.Message.error('接口异常'); | ||
102 | + return Promise.reject({response}); | ||
103 | + }, error => { | ||
104 | + return Promise.reject(error); | ||
105 | + }); | ||
96 | } | 106 | } |
97 | }; | 107 | }; |
98 | 108 |
@@ -58,7 +58,13 @@ class Api extends Context { | @@ -58,7 +58,13 @@ class Api extends Context { | ||
58 | 58 | ||
59 | return request(params, (error, response) => { | 59 | return request(params, (error, response) => { |
60 | if (!error) { | 60 | if (!error) { |
61 | - logger.info(`api call ${response.statusCode} [${response.request.method}] ${response.request.href} ${response.request.body}`); // eslint-disable-line | 61 | + if (response && /^20\d/.test(response.statusCode)) { |
62 | + logger.info(`api call ${response.statusCode} [${response.request.method}] ${response.request.href} ${response.request.body}`); // eslint-disable-line | ||
63 | + } else { | ||
64 | + let res = response.toJSON(); | ||
65 | + | ||
66 | + logger.error(`api call ${res.statusCode} [${res.request.method}] ${res.request.uri.href} ${res.body || ''}`); // eslint-disable-line | ||
67 | + } | ||
62 | } | 68 | } |
63 | }); | 69 | }); |
64 | } | 70 | } |
@@ -12,7 +12,7 @@ const apiDomain = require('./api-domain'); | @@ -12,7 +12,7 @@ const apiDomain = require('./api-domain'); | ||
12 | const config = { | 12 | const config = { |
13 | app: 'shop-manage', | 13 | app: 'shop-manage', |
14 | appVersion: '0.0.1', // 调用api的版本 | 14 | appVersion: '0.0.1', // 调用api的版本 |
15 | - platform: 2, | 15 | + platform: 4, |
16 | port: 6007, | 16 | port: 6007, |
17 | siteUrl: '//shop.yohobuy.com', | 17 | siteUrl: '//shop.yohobuy.com', |
18 | assetUrl: '//127.0.0.1:5001', | 18 | assetUrl: '//127.0.0.1:5001', |
@@ -4,6 +4,7 @@ const request = require('request'); | @@ -4,6 +4,7 @@ const request = require('request'); | ||
4 | const env = global.env; | 4 | const env = global.env; |
5 | 5 | ||
6 | let mainProxy = (req, res) => { | 6 | let mainProxy = (req, res) => { |
7 | + res.header('x-version', env.version); | ||
7 | request.get(`http://cdn.yoho.cn/yoho-shop-manage/${env.version}/index.html`).pipe(res); | 8 | request.get(`http://cdn.yoho.cn/yoho-shop-manage/${env.version}/index.html`).pipe(res); |
8 | }; | 9 | }; |
9 | 10 |
-
Please register or login to post a comment