Commit f02c7f20 authored by 何虹's avatar 何虹 💬

编译成es5

parent 8a18c7ac
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"name": "hswebhttpclient", "name": "hswebhttpclient",
"version": "1.0.3", "version": "1.0.3",
"description": "dync中httpClient基础插件", "description": "dync中httpClient基础插件",
"main": "./src/index.js", "main": "./dist/hsWebHttpClient.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack", "build": "webpack",
......
import axios from 'axios' import axios from 'axios'
class Root { class Root {
filterEmptyValue(obj) { filterEmptyValue (obj) {
if (!obj) return if (!obj) return
const emptyValues = [null, undefined, 'null', 'undefined', NaN] const emptyValues = [null, undefined, 'null', 'undefined', NaN]
for (const k in obj) { for (const k in obj) {
...@@ -12,25 +12,28 @@ class Root { ...@@ -12,25 +12,28 @@ class Root {
} }
} }
} }
get(url, params, headers, config) { get (url, params, headers, config) {
return this.request('get', url, null, params, headers, config) return this.request('get', url, null, params, headers, config)
} }
post(url, data, params, headers, config) { post (url, data, params, headers, config) {
return this.request('post', url, data, params, headers, config) return this.request('post', url, data, params, headers, config)
} }
put(url, data, params, headers, config) { put (url, data, params, headers, config) {
return this.request('put', url, data, params, headers, config) return this.request('put', url, data, params, headers, config)
} }
delete(url, data, params, headers, config) { delete (url, data, params, headers, config) {
return this.request('delete', url, data, params, headers, config) return this.request('delete', url, data, params, headers, config)
} }
requestConfig(config) { requestConfig (config) {
return axios(config) return axios(config)
} }
request(method, url, data, params, headers = null, config = {}) { request (method, url, data, params, headers = null, config = {}) {
this.filterEmptyValue(data) this.filterEmptyValue(data)
// 公共头设置 // 公共头设置
const aixosCtx = { method, url, ...config } const aixosCtx = { method, url,...config }
// if (config) {
// Object.assign(aixosCtx, config)
// }
params && (aixosCtx.params = params) params && (aixosCtx.params = params)
if (aixosCtx.params && aixosCtx.params.token) delete aixosCtx.params.token if (aixosCtx.params && aixosCtx.params.token) delete aixosCtx.params.token
if (aixosCtx.params && aixosCtx.params._user_info) delete aixosCtx.params._user_info if (aixosCtx.params && aixosCtx.params._user_info) delete aixosCtx.params._user_info
......
...@@ -2,6 +2,7 @@ const TerserPlugin = require('terser-webpack-plugin') // 引入压缩插件 ...@@ -2,6 +2,7 @@ const TerserPlugin = require('terser-webpack-plugin') // 引入压缩插件
module.exports = { module.exports = {
mode: 'none', // 因为默认是production 默认会进行压缩 mode: 'none', // 因为默认是production 默认会进行压缩
target: ['web', 'es5'],//← ← ←就是这个
entry: { entry: {
"hsWebHttpClient": "./src/index.js", "hsWebHttpClient": "./src/index.js",
"hsWebHttpClient.min": "./src/index.js" "hsWebHttpClient.min": "./src/index.js"
......
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