Commit 281e67d7 authored by 何虹's avatar 何虹 💬

更改构造方式

parent 2a213db5
......@@ -93,10 +93,10 @@ class Root {
request (method, url, data, params, headers = null, config = {}) {
this.filterEmptyValue(data)
// 公共头设置
const aixosCtx = { method, url,...config }
// if (config) {
// Object.assign(aixosCtx, config)
// }
const aixosCtx = { method, url }
if (config) {
Object.assign(aixosCtx, config)
}
params && (aixosCtx.params = params)
if (aixosCtx.params && aixosCtx.params.token) delete aixosCtx.params.token
if (aixosCtx.params && aixosCtx.params._user_info) delete aixosCtx.params._user_info
......
This source diff could not be displayed because it is too large. You can view the blob instead.
import Root from './root'
import Billflow from './packages/modules/billflow'
import WebChartConfig from './packages/modules/webChartConfig'
import Restful from './packages/modules/restful'
import System from './packages/modules/system'
import WebQueryClient from './packages/modules/webQueryClient'
import Ref from './packages/modules/ref'
const root = new Root()
const restful = new Restful(root)
const webQueryClient = new WebQueryClient(root)
const billflow = new Billflow(root)
const system = new System(root, restful)
const webChartConfig = new WebChartConfig(root)
const ref = new Ref(root)
const list = [webQueryClient, billflow, system, webChartConfig, restful, ref]
const api = {
}
list.forEach(item => {
api[item.moduleName] = item
})
const root_prototype = root.__proto__
const root_prototype_keys = Object.getOwnPropertyNames(root_prototype)
root_prototype_keys.forEach(k => {
if (k !== 'constructor') {
api[`${k}`] = root_prototype[k]
}
})
api.init=function(axios){
root.axios=axios
}
export default api
import Root from './root'
import Billflow from './packages/modules/billflow'
import WebChartConfig from './packages/modules/webChartConfig'
import Restful from './packages/modules/restful'
import System from './packages/modules/system'
import WebQueryClient from './packages/modules/webQueryClient'
import Ref from './packages/modules/ref'
class HttpClient {
constructor(axios){
const root = new Root(axios)
const restful = new Restful(root)
const webQueryClient = new WebQueryClient(root)
const billflow = new Billflow(root)
const system = new System(root, restful)
const webChartConfig = new WebChartConfig(root)
const ref = new Ref(root)
const list = [webQueryClient, billflow, system, webChartConfig, restful, ref]
const api = {
}
list.forEach(item => {
api[item.moduleName] = item
})
const root_prototype = root.__proto__
const root_prototype_keys = Object.getOwnPropertyNames(root_prototype)
root_prototype_keys.forEach(k => {
if (k !== 'constructor') {
api[`${k}`] = root_prototype[k]
}
})
}
}
export default HttpClient
......@@ -6,24 +6,29 @@ import Restful from './packages/modules/restful'
import System from './packages/modules/system'
import WebQueryClient from './packages/modules/webQueryClient'
import Ref from './packages/modules/ref'
const root = new Root()
const restful = new Restful(root)
const webQueryClient = new WebQueryClient(root)
const billflow = new Billflow(root)
const system = new System(root, restful)
const webChartConfig = new WebChartConfig(root)
const ref = new Ref(root)
const list = [webQueryClient, billflow, system, webChartConfig, restful, ref]
const api = {
class HttpClient {
constructor(axios){
const root = new Root(axios)
const restful = new Restful(root)
const webQueryClient = new WebQueryClient(root)
const billflow = new Billflow(root)
const system = new System(root, restful)
const webChartConfig = new WebChartConfig(root)
const ref = new Ref(root)
const list = [webQueryClient, billflow, system, webChartConfig, restful, ref]
const api = {
}
list.forEach(item => {
api[item.moduleName] = item
})
const root_prototype = root.__proto__
const root_prototype_keys = Object.getOwnPropertyNames(root_prototype)
root_prototype_keys.forEach(k => {
if (k !== 'constructor') {
api[`${k}`] = root_prototype[k]
}
})
}
}
list.forEach(item => {
api[item.moduleName] = item
})
const root_prototype = root.__proto__
const root_prototype_keys = Object.getOwnPropertyNames(root_prototype)
root_prototype_keys.forEach(k => {
if (k !== 'constructor') {
api[`${k}`] = root_prototype[k]
}
})
export default api
export default HttpClient
import axios from 'axios'
class Root {
constructor(_axios) {
this.axios = _axios || axios
}
filterEmptyValue (obj) {
if (!obj) return
const emptyValues = [null, undefined, 'null', 'undefined', NaN]
......@@ -39,7 +42,7 @@ class Root {
if (aixosCtx.params && aixosCtx.params._user_info) delete aixosCtx.params._user_info
data && (aixosCtx.data = data)
headers && (aixosCtx.headers = headers)
const result = axios(aixosCtx)
const result = this.axios(aixosCtx)
return result
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment