Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
npm
/
glsx-common
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 182f7a1b
authored
Sep 12, 2025
by
张立顺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
v2.10.9 版本
1 parent
a4f80c4a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
2 deletions
dist/glsk-common.js
package.json
src/http.js
dist/glsk-common.js
View file @
182f7a1
...
@@ -547,7 +547,7 @@ eval("\n\nvar GetIntrinsic = __webpack_require__(/*! get-intrinsic */ \"./node_m
...
@@ -547,7 +547,7 @@ eval("\n\nvar GetIntrinsic = __webpack_require__(/*! get-intrinsic */ \"./node_m
/***/
((
__unused_webpack_module
,
__webpack_exports__
,
__webpack_require__
)
=>
{
/***/
((
__unused_webpack_module
,
__webpack_exports__
,
__webpack_require__
)
=>
{
"use strict"
;
"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?"
);
/***/
}),
/***/
}),
...
...
package.json
View file @
182f7a1
{
{
"name"
:
"glsk-common"
,
"name"
:
"glsk-common"
,
"version"
:
"2.10.
7
"
,
"version"
:
"2.10.
9
"
,
"description"
:
"glsk common"
,
"description"
:
"glsk common"
,
"main"
:
"./dist/glsk-common.js"
,
"main"
:
"./dist/glsk-common.js"
,
"private"
:
false
,
"private"
:
false
,
...
...
src/http.js
View file @
182f7a1
...
@@ -45,6 +45,7 @@ Http.prototype.create = function () {
...
@@ -45,6 +45,7 @@ Http.prototype.create = function () {
}
}
const
method
=
config
.
method
.
toLowerCase
()
const
method
=
config
.
method
.
toLowerCase
()
if
(
method
==
'get'
)
{
if
(
method
==
'get'
)
{
// config.data = data
config
.
params
=
data
config
.
params
=
data
}
else
if
(
method
==
'post'
)
{
}
else
if
(
method
==
'post'
)
{
// 将 sdctag
// 将 sdctag
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment