mirror of
https://github.com/zuiidea/antd-admin
synced 2026-11-17 21:25:06 +00:00
Merge branch '4.2-dev'
This commit is contained in:
+4073
File diff suppressed because it is too large
Load Diff
+3
-2
@@ -1,12 +1,12 @@
|
||||
module.exports = {
|
||||
name: 'AntD Admin',
|
||||
prefix: 'antdAdmin',
|
||||
footerText: 'Ant Design Admin 版权所有 © 2016 由 zuiidea 支持',
|
||||
footerText: 'Ant Design Admin © 2017 zuiidea',
|
||||
logo: 'https://t.alipayobjects.com/images/T1QUBfXo4fXXXXXXXX.png',
|
||||
iconFontUrl: '//at.alicdn.com/t/font_c4y7asse3q1cq5mi.js',
|
||||
baseURL: 'http://localhost:8000/api/v1',
|
||||
YQL: ['http://www.zuimeitianqi.com'],
|
||||
CORS: ['http://localhost:7001'],
|
||||
CORS: ['http://localhost:7001', 'http://192.168.1.110:8000'],
|
||||
openPages: ['/login'],
|
||||
apiPrefix: '/api/v1',
|
||||
api: {
|
||||
@@ -14,6 +14,7 @@ module.exports = {
|
||||
userLogout: '/user/logout',
|
||||
userInfo: '/userInfo',
|
||||
users: '/users',
|
||||
user: '/user/:id',
|
||||
dashboard: '/dashboard',
|
||||
},
|
||||
}
|
||||
|
||||
+8
-1
@@ -10,7 +10,14 @@ module.exports = [
|
||||
bpid: 1,
|
||||
name: 'User Manage',
|
||||
icon: 'user',
|
||||
router: '/users',
|
||||
router: '/user',
|
||||
},
|
||||
{
|
||||
id: 21,
|
||||
mpid: -1,
|
||||
bpid: 2,
|
||||
name: 'User Detail',
|
||||
router: '/user/:id',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
|
||||
+38
-13
@@ -3,10 +3,11 @@ import qs from 'qs'
|
||||
import { YQL, CORS, baseURL } from './config'
|
||||
import jsonp from 'jsonp'
|
||||
import lodash from 'lodash'
|
||||
import pathToRegexp from 'path-to-regexp'
|
||||
import { message } from 'antd'
|
||||
|
||||
axios.defaults.baseURL = baseURL
|
||||
|
||||
|
||||
const fetch = (options) => {
|
||||
let {
|
||||
method = 'get',
|
||||
@@ -15,6 +16,26 @@ const fetch = (options) => {
|
||||
url,
|
||||
} = options
|
||||
|
||||
const cloneData = lodash.cloneDeep(data)
|
||||
|
||||
try {
|
||||
let domin = ''
|
||||
if (url.match(/[a-zA-z]+:\/\/[^/]*/)) {
|
||||
domin = url.match(/[a-zA-z]+:\/\/[^/]*/)[0]
|
||||
url = url.slice(domin.length)
|
||||
}
|
||||
const match = pathToRegexp.parse(url)
|
||||
url = pathToRegexp.compile(url)(data)
|
||||
for (let item of match) {
|
||||
if (item instanceof Object && item.name in cloneData) {
|
||||
delete cloneData[item.name]
|
||||
}
|
||||
}
|
||||
url = domin + url
|
||||
} catch (e) {
|
||||
message.error(e.message)
|
||||
}
|
||||
|
||||
if (fetchType === 'JSONP') {
|
||||
return new Promise((resolve, reject) => {
|
||||
jsonp(url, {
|
||||
@@ -35,17 +56,19 @@ const fetch = (options) => {
|
||||
|
||||
switch (method.toLowerCase()) {
|
||||
case 'get':
|
||||
return axios.get(`${url}${!lodash.isEmpty(data) ? `?${qs.stringify(data)}` : ''}`)
|
||||
return axios.get(url, {
|
||||
params: cloneData,
|
||||
})
|
||||
case 'delete':
|
||||
return axios.delete(url, { data })
|
||||
case 'head':
|
||||
return axios.head(url, data)
|
||||
return axios.delete(url, {
|
||||
data: cloneData,
|
||||
})
|
||||
case 'post':
|
||||
return axios.post(url, data)
|
||||
return axios.post(url, cloneData)
|
||||
case 'put':
|
||||
return axios.put(url, data)
|
||||
return axios.put(url, cloneData)
|
||||
case 'patch':
|
||||
return axios.patch(url, data)
|
||||
return axios.patch(url, cloneData)
|
||||
default:
|
||||
return axios(options)
|
||||
}
|
||||
@@ -76,16 +99,18 @@ export default function request (options) {
|
||||
}
|
||||
}).catch((error) => {
|
||||
const { response } = error
|
||||
let message
|
||||
let msg
|
||||
let status
|
||||
let otherData = {}
|
||||
if (response) {
|
||||
status = response.status
|
||||
const { data, statusText } = response
|
||||
message = data.message || statusText
|
||||
otherData = data
|
||||
status = response.status
|
||||
msg = data.message || statusText
|
||||
} else {
|
||||
status = 600
|
||||
message = 'Network Error'
|
||||
msg = 'Network Error'
|
||||
}
|
||||
return { success: false, status, message }
|
||||
return { success: false, status, message: msg, ...otherData }
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user