This commit is contained in:
zuiidea
2017-04-13 18:31:48 +08:00
parent a9ff576958
commit 28efa1a67b
12 changed files with 234 additions and 184 deletions
+8 -1
View File
@@ -4,7 +4,14 @@ module.exports = {
footerText: 'Ant Design Admin 版权所有 © 2016 由 zuiidea 支持',
logo: 'https://t.alipayobjects.com/images/T1QUBfXo4fXXXXXXXX.png',
iconFontUrl: '//at.alicdn.com/t/font_c4y7asse3q1cq5mi.js',
baseURL: 'http://47.92.30.98:7001/api',
baseURL: 'http://localhost:8000/api/v1',
YQL: ['http://www.zuimeitianqi.com'],
CORS: ['http://localhost:7001'],
openPages: ['/login'],
apiPrefix: '/api/v1',
api: {
userLogin: '/user/login',
userLogout: '/user/logout',
userInfo: '/userInfo',
},
}
+17 -9
View File
@@ -1,9 +1,11 @@
import axios from 'axios'
import qs from 'qs'
import { YQL, CORS } from './config'
import { YQL, CORS, baseURL } from './config'
import jsonp from 'jsonp'
import lodash from 'lodash'
axios.defaults.baseURL = baseURL
const fetch = (options) => {
let {
method = 'get',
@@ -66,17 +68,23 @@ export default function request (options) {
const { statusText, status } = response
let data = options.fetchType === 'YQL' ? response.data.query.results.json : response.data
return {
code: 0,
status,
success: true,
message: statusText,
status,
...data,
}
}).catch((error) => {
const {
response = {
statusText: error.message || 'Network Error',
},
} = error
return { code: 1, message: response.statusText }
const { response } = error
let message
let status
if (response) {
status = response.status
const { data, statusText } = response
message = data.message || statusText
} else {
status = 600
message = 'Network Error'
}
return { success: false, status, message }
})
}