|
@@ -5,9 +5,12 @@ import store from '@/store'
|
|
|
import { hasOwnProperty, isEmptyObject, filterNull } from '@/utils/util'
|
|
import { hasOwnProperty, isEmptyObject, filterNull } from '@/utils/util'
|
|
|
import request from './request'
|
|
import request from './request'
|
|
|
import Config from '@/core/config'
|
|
import Config from '@/core/config'
|
|
|
|
|
+import { addSnakeAliases } from '@/utils/fieldAlias'
|
|
|
|
|
|
|
|
// 后端api地址
|
|
// 后端api地址
|
|
|
const apiUrl = Config.get('apiUrl')
|
|
const apiUrl = Config.get('apiUrl')
|
|
|
|
|
+// 联调期:为驼峰字段补充下划线别名,兼容按 PHP 接口写的页面(详见 utils/fieldAlias.js)
|
|
|
|
|
+const enableFieldAlias = Config.get('enableFieldAlias', true)
|
|
|
|
|
|
|
|
// 可以new多个request来支持多个域名请求
|
|
// 可以new多个request来支持多个域名请求
|
|
|
const $http = new request({
|
|
const $http = new request({
|
|
@@ -135,6 +138,9 @@ $http.dataFactory = async res => {
|
|
|
// result.status [ 200正常 500有错误 401未登录 403没有权限访问 ]
|
|
// result.status [ 200正常 500有错误 401未登录 403没有权限访问 ]
|
|
|
if (httpData.status == 200) {
|
|
if (httpData.status == 200) {
|
|
|
// 返回正确的结果(then接受数据)
|
|
// 返回正确的结果(then接受数据)
|
|
|
|
|
+ if (enableFieldAlias) {
|
|
|
|
|
+ addSnakeAliases(httpData)
|
|
|
|
|
+ }
|
|
|
return Promise.resolve(httpData)
|
|
return Promise.resolve(httpData)
|
|
|
}
|
|
}
|
|
|
|
|
|