Commit 182f7a1b by 张立顺

v2.10.9 版本

1 parent a4f80c4a
......@@ -547,7 +547,7 @@ eval("\n\nvar GetIntrinsic = __webpack_require__(/*! get-intrinsic */ \"./node_m
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util */ \"./src/util.js\");\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! axios */ \"./node_modules/axios/index.js\");\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(axios__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var qs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! qs */ \"./node_modules/qs/lib/index.js\");\n/* harmony import */ var qs__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(qs__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _whiteUrlManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./whiteUrlManager */ \"./src/whiteUrlManager.js\");\n/*\n * @Author: limin\n * @Date: 2018-06-25 10:28:18\n * @Last Modified by: huyue\n * @Last Modified time: 2021-07-16 18:02:05\n */\n\n\n\n // 导入白名单管理器\nfunction Http(options = {}) {\n this.service = axios__WEBPACK_IMPORTED_MODULE_1___default().create({\n withCredentials: true,\n method: 'POST'\n })\n const { response = {}, request = {}, headers = {}, alert, sign, signWay = 'sha1', secret } = options\n this.customer = {\n response,\n alert,\n sign,\n secret,\n signWay,\n sessionId: headers.token\n }\n const { baseURL, timeout = 3000, withCredentials = true, responseType = 'json' } = request\n Object.assign(this.service.defaults, { headers: Object.assign({ 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }, headers) }, { baseURL, timeout, withCredentials, responseType })\n return this.create()\n}\nHttp.prototype.create = function () {\n this.service.interceptors.request.use(\n async config => {\n let { data = {}, sign = true, noSignAttr = [], noSessionId = false } = config\n // 获取白名单并检查接口\n const whiteUrl = await _whiteUrlManager__WEBPACK_IMPORTED_MODULE_3__[\"default\"].getWhiteUrls()\n\n if (whiteUrl.includes(data?.method)) {\n data.sdctag = true\n }\n if (!noSessionId) {\n data.sessionId = this.customer.sessionId || data.sessionId\n }\n if (sign) {\n let _configSign = this.customer.sign || {}\n data = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createSign(Object.assign({}, _configSign, data), this.customer.secret, noSignAttr, this.customer.signWay)\n }\n const method = config.method.toLowerCase()\n if (method == 'get') {\n config.params = data\n } else if (method == 'post') {\n // 将 sdctag\n if (data.sdctag) {\n config.params = { ...config.params, sdctag: data.sdctag }\n }\n if (config.headers['Content-Type'] == 'multipart/form-data') {\n config.data = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].appendFormData(data)\n } else if (config.headers['Content-Type'] == 'application/json') {\n config.data = data\n } else {\n config.data = qs__WEBPACK_IMPORTED_MODULE_2___default().stringify(data)\n }\n }\n return config\n },\n error => Promise.reject(error)\n )\n this.service.interceptors.response.use(\n ({ data: res, config: { returnAll } }) => {\n const {\n response: { code_key, errId = 'errId', code_success_value = '0', data_key = 'data', errId_logout_value, logout_function = 'logout' },\n alert\n } = this.customer\n // if (returnAll || !alert) {\n // return res\n // }\n let codekey = Array.isArray(code_key) ? code_key.find(key => res.hasOwnProperty(key)) : code_key\n let code = res[codekey]\n let errValue = res[errId]\n if (returnAll || !alert) {\n if ((code && code == errId_logout_value) || (errValue && errValue == errId_logout_value)) {\n logout(logout_function)\n }\n return res\n }\n // 特殊的code处理,可以增加\n switch (code + '') {\n case code_success_value + '':\n break\n case errId_logout_value + '':\n logout(logout_function)\n break\n default:\n if (errValue && errValue == errId_logout_value) {\n return logout(logout_function)\n }\n alert(res.message || res.msg || '出错了,请联系管理员')\n break\n }\n return res[data_key]\n },\n error => {\n const { alert } = this.customer\n alert && alert(error.message || '出错了,请联系管理员')\n // 返回接口返回的错误信息\n return Promise.reject(error)\n }\n )\n this.service.axios = (axios__WEBPACK_IMPORTED_MODULE_1___default())\n return this.service\n}\nfunction logout(logout_function) {\n _whiteUrlManager__WEBPACK_IMPORTED_MODULE_3__[\"default\"].clearCache()\n if (window[logout_function]) {\n window[logout_function](window.location.href)\n return\n }\n window.history.pushState({ page: window.location.href }, '', '/login')\n}\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Http);\n\n\n//# sourceURL=webpack://glsk-common/./src/http.js?");
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util */ \"./src/util.js\");\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! axios */ \"./node_modules/axios/index.js\");\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(axios__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var qs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! qs */ \"./node_modules/qs/lib/index.js\");\n/* harmony import */ var qs__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(qs__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _whiteUrlManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./whiteUrlManager */ \"./src/whiteUrlManager.js\");\n/*\n * @Author: limin\n * @Date: 2018-06-25 10:28:18\n * @Last Modified by: huyue\n * @Last Modified time: 2021-07-16 18:02:05\n */\n\n\n\n // 导入白名单管理器\nfunction Http(options = {}) {\n this.service = axios__WEBPACK_IMPORTED_MODULE_1___default().create({\n withCredentials: true,\n method: 'POST'\n })\n const { response = {}, request = {}, headers = {}, alert, sign, signWay = 'sha1', secret } = options\n this.customer = {\n response,\n alert,\n sign,\n secret,\n signWay,\n sessionId: headers.token\n }\n const { baseURL, timeout = 3000, withCredentials = true, responseType = 'json' } = request\n Object.assign(this.service.defaults, { headers: Object.assign({ 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }, headers) }, { baseURL, timeout, withCredentials, responseType })\n return this.create()\n}\nHttp.prototype.create = function () {\n this.service.interceptors.request.use(\n async config => {\n let { data = {}, sign = true, noSignAttr = [], noSessionId = false } = config\n // 获取白名单并检查接口\n const whiteUrl = await _whiteUrlManager__WEBPACK_IMPORTED_MODULE_3__[\"default\"].getWhiteUrls()\n\n if (whiteUrl.includes(data?.method)) {\n data.sdctag = true\n }\n if (!noSessionId) {\n data.sessionId = this.customer.sessionId || data.sessionId\n }\n if (sign) {\n let _configSign = this.customer.sign || {}\n data = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].createSign(Object.assign({}, _configSign, data), this.customer.secret, noSignAttr, this.customer.signWay)\n }\n const method = config.method.toLowerCase()\n if (method == 'get') {\n // config.data = data\n config.params = data\n } else if (method == 'post') {\n // 将 sdctag\n if (data.sdctag) {\n config.params = { ...config.params, sdctag: data.sdctag }\n }\n if (config.headers['Content-Type'] == 'multipart/form-data') {\n config.data = _util__WEBPACK_IMPORTED_MODULE_0__[\"default\"].appendFormData(data)\n } else if (config.headers['Content-Type'] == 'application/json') {\n config.data = data\n } else {\n config.data = qs__WEBPACK_IMPORTED_MODULE_2___default().stringify(data)\n }\n }\n return config\n },\n error => Promise.reject(error)\n )\n this.service.interceptors.response.use(\n ({ data: res, config: { returnAll } }) => {\n const {\n response: { code_key, errId = 'errId', code_success_value = '0', data_key = 'data', errId_logout_value, logout_function = 'logout' },\n alert\n } = this.customer\n // if (returnAll || !alert) {\n // return res\n // }\n let codekey = Array.isArray(code_key) ? code_key.find(key => res.hasOwnProperty(key)) : code_key\n let code = res[codekey]\n let errValue = res[errId]\n if (returnAll || !alert) {\n if ((code && code == errId_logout_value) || (errValue && errValue == errId_logout_value)) {\n logout(logout_function)\n }\n return res\n }\n // 特殊的code处理,可以增加\n switch (code + '') {\n case code_success_value + '':\n break\n case errId_logout_value + '':\n logout(logout_function)\n break\n default:\n if (errValue && errValue == errId_logout_value) {\n return logout(logout_function)\n }\n alert(res.message || res.msg || '出错了,请联系管理员')\n break\n }\n return res[data_key]\n },\n error => {\n const { alert } = this.customer\n alert && alert(error.message || '出错了,请联系管理员')\n // 返回接口返回的错误信息\n return Promise.reject(error)\n }\n )\n this.service.axios = (axios__WEBPACK_IMPORTED_MODULE_1___default())\n return this.service\n}\nfunction logout(logout_function) {\n _whiteUrlManager__WEBPACK_IMPORTED_MODULE_3__[\"default\"].clearCache()\n if (window[logout_function]) {\n window[logout_function](window.location.href)\n return\n }\n window.history.pushState({ page: window.location.href }, '', '/login')\n}\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Http);\n\n\n//# sourceURL=webpack://glsk-common/./src/http.js?");
/***/ }),
......
{
"name": "glsk-common",
"version": "2.10.7",
"version": "2.10.9",
"description": "glsk common",
"main": "./dist/glsk-common.js",
"private": false,
......
......@@ -45,6 +45,7 @@ Http.prototype.create = function () {
}
const method = config.method.toLowerCase()
if (method == 'get') {
// config.data = data
config.params = data
} else if (method == 'post') {
// 将 sdctag
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!