@smart100/spu-web-plugin 1.0.20 → 1.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/spu-web-plugin.mjs +251 -228
- package/package.json +1 -1
- package/src/axios.ts +30 -0
package/dist/spu-web-plugin.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var version = "1.0.
|
|
1
|
+
var version = "1.0.21";
|
|
2
2
|
|
|
3
3
|
/** Detect free variable `global` from Node.js. */
|
|
4
4
|
var freeGlobal$2 = typeof global == 'object' && global && global.Object === Object && global;
|
|
@@ -8387,233 +8387,6 @@ var Module = {
|
|
|
8387
8387
|
getSpuContainerType: core$1.getSpuContainerType.bind(core$1)
|
|
8388
8388
|
};
|
|
8389
8389
|
|
|
8390
|
-
var createAxiosInstance$1 = function createAxiosInstance() {
|
|
8391
|
-
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'spu';
|
|
8392
|
-
var options = arguments.length > 1 ? arguments[1] : undefined;
|
|
8393
|
-
var axiosInstance = axios$3.create({
|
|
8394
|
-
baseURL: type === 'spu' ? "/api/".concat(options.modulekey, "/").concat(options.moduleversion) : ''
|
|
8395
|
-
// baseURL: '',
|
|
8396
|
-
// timeout: 36000000
|
|
8397
|
-
// withCredentials: true, // 不能开启 影响ali oss
|
|
8398
|
-
// headers: {
|
|
8399
|
-
// // 'Content-Type': 'application/json;charset=UTF-8',
|
|
8400
|
-
// // 'app_id': '100'
|
|
8401
|
-
// }
|
|
8402
|
-
});
|
|
8403
|
-
|
|
8404
|
-
axiosInstance.interceptors.request.use( /*#__PURE__*/function () {
|
|
8405
|
-
var _ref = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee(config) {
|
|
8406
|
-
var isShowLoading, isSendToken, loginState, token, moduleData, isSendTecode, tecode;
|
|
8407
|
-
return _regeneratorRuntime$1().wrap(function _callee$(_context) {
|
|
8408
|
-
while (1) switch (_context.prev = _context.next) {
|
|
8409
|
-
case 0:
|
|
8410
|
-
// const isShowLoading = typeof config?.isShowLoading !== 'undefined' ? config.isShowLoading : true
|
|
8411
|
-
// console.error(444444)
|
|
8412
|
-
// console.log(config)
|
|
8413
|
-
isShowLoading = get$1(config, 'isShowLoading', true);
|
|
8414
|
-
isShowLoading && loadding$1.open();
|
|
8415
|
-
isSendToken = get$1(config, 'isSendToken', true);
|
|
8416
|
-
if (!isSendToken) {
|
|
8417
|
-
_context.next = 16;
|
|
8418
|
-
break;
|
|
8419
|
-
}
|
|
8420
|
-
// 请求接口前校验是否过期 如果过期先刷新token
|
|
8421
|
-
loginState = getLoginState();
|
|
8422
|
-
if (!(config.url !== '/api/auth/refreshtoken' && !loginState.islogin && loginState.type === 2 && loginState.role !== 'center')) {
|
|
8423
|
-
_context.next = 14;
|
|
8424
|
-
break;
|
|
8425
|
-
}
|
|
8426
|
-
_context.prev = 6;
|
|
8427
|
-
_context.next = 9;
|
|
8428
|
-
return updateToken();
|
|
8429
|
-
case 9:
|
|
8430
|
-
_context.next = 14;
|
|
8431
|
-
break;
|
|
8432
|
-
case 11:
|
|
8433
|
-
_context.prev = 11;
|
|
8434
|
-
_context.t0 = _context["catch"](6);
|
|
8435
|
-
console.error(_context.t0);
|
|
8436
|
-
case 14:
|
|
8437
|
-
token = getToken();
|
|
8438
|
-
if (config !== null && config !== void 0 && config.headers && token) {
|
|
8439
|
-
config.headers.token = token;
|
|
8440
|
-
}
|
|
8441
|
-
case 16:
|
|
8442
|
-
if (!(type === 'spu' && config.modulekey)) {
|
|
8443
|
-
_context.next = 21;
|
|
8444
|
-
break;
|
|
8445
|
-
}
|
|
8446
|
-
_context.next = 19;
|
|
8447
|
-
return core$1.getModuleData(config.modulekey);
|
|
8448
|
-
case 19:
|
|
8449
|
-
moduleData = _context.sent;
|
|
8450
|
-
if (moduleData.data) {
|
|
8451
|
-
config.baseURL = "/api/".concat(config.modulekey, "/").concat(moduleData.data.moduleversion);
|
|
8452
|
-
} else {
|
|
8453
|
-
console.error(moduleData.errorMsg);
|
|
8454
|
-
config.baseURL = "/api/".concat(config.modulekey, "/v?.?");
|
|
8455
|
-
}
|
|
8456
|
-
case 21:
|
|
8457
|
-
// 平台的业务接口开了开发者模式后,header带上debug方便查看接口的ide日志
|
|
8458
|
-
if (type !== 'spu' && urlquery.isdebugger && config.url.indexOf('api/teapi/dy-biz/') > -1) {
|
|
8459
|
-
if (config !== null && config !== void 0 && config.headers) {
|
|
8460
|
-
config.headers.debug = 'true';
|
|
8461
|
-
}
|
|
8462
|
-
}
|
|
8463
|
-
if (type !== 'spu') {
|
|
8464
|
-
isSendTecode = get$1(config, 'isSendTecode', false);
|
|
8465
|
-
if (isSendTecode) {
|
|
8466
|
-
tecode = getTecode();
|
|
8467
|
-
if (config !== null && config !== void 0 && config.headers && tecode) {
|
|
8468
|
-
config.headers.tecode = tecode;
|
|
8469
|
-
}
|
|
8470
|
-
}
|
|
8471
|
-
}
|
|
8472
|
-
return _context.abrupt("return", config);
|
|
8473
|
-
case 24:
|
|
8474
|
-
case "end":
|
|
8475
|
-
return _context.stop();
|
|
8476
|
-
}
|
|
8477
|
-
}, _callee, null, [[6, 11]]);
|
|
8478
|
-
}));
|
|
8479
|
-
return function (_x) {
|
|
8480
|
-
return _ref.apply(this, arguments);
|
|
8481
|
-
};
|
|
8482
|
-
}(), function (error) {
|
|
8483
|
-
return Promise.reject(error);
|
|
8484
|
-
});
|
|
8485
|
-
axiosInstance.interceptors.response.use(function (res) {
|
|
8486
|
-
// debugger
|
|
8487
|
-
var isShowLoading = get$1(res, 'config.isShowLoading', true);
|
|
8488
|
-
isShowLoading && loadding$1.close();
|
|
8489
|
-
var realRes = {
|
|
8490
|
-
code: 404,
|
|
8491
|
-
data: '',
|
|
8492
|
-
msg: '',
|
|
8493
|
-
message: ''
|
|
8494
|
-
};
|
|
8495
|
-
if (type === 'spu') {
|
|
8496
|
-
if (res.data.code === 200) {
|
|
8497
|
-
// return res.data
|
|
8498
|
-
realRes = {
|
|
8499
|
-
code: res.data.code,
|
|
8500
|
-
data: res.data.data,
|
|
8501
|
-
msg: res.data.msg,
|
|
8502
|
-
message: res.data.msg
|
|
8503
|
-
};
|
|
8504
|
-
return realRes;
|
|
8505
|
-
} else {
|
|
8506
|
-
realRes = {
|
|
8507
|
-
code: res.data.code,
|
|
8508
|
-
data: res.data.data,
|
|
8509
|
-
msg: res.data.msg || '网络异常,请稍后重试。',
|
|
8510
|
-
message: res.data.msg || '网络异常,请稍后重试。'
|
|
8511
|
-
};
|
|
8512
|
-
// const isShowErrorMessage = get(res, 'config.isShowErrorMessage', true)
|
|
8513
|
-
// isShowErrorMessage && Message.error(realRes.msg)
|
|
8514
|
-
return Promise.reject(realRes);
|
|
8515
|
-
}
|
|
8516
|
-
} else if (type === 'normal') {
|
|
8517
|
-
var _res$data, _res$data2, _res$data3;
|
|
8518
|
-
realRes = {
|
|
8519
|
-
code: res.status || 200,
|
|
8520
|
-
data: ((_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.resp_data) || res.data,
|
|
8521
|
-
msg: ((_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.error_code) || '',
|
|
8522
|
-
message: ((_res$data3 = res.data) === null || _res$data3 === void 0 ? void 0 : _res$data3.error_code) || ''
|
|
8523
|
-
};
|
|
8524
|
-
return realRes;
|
|
8525
|
-
}
|
|
8526
|
-
}, function (err) {
|
|
8527
|
-
// err: AxiosError
|
|
8528
|
-
// console.log(err)
|
|
8529
|
-
// debugger
|
|
8530
|
-
var isShowLoading = get$1(err, 'config.isShowLoading', true);
|
|
8531
|
-
isShowLoading && loadding$1.close();
|
|
8532
|
-
// console.log(err)
|
|
8533
|
-
// debugger
|
|
8534
|
-
var msg = '';
|
|
8535
|
-
if (type === 'spu') {
|
|
8536
|
-
msg = get$1(err, 'response.data.msg', '');
|
|
8537
|
-
} else {
|
|
8538
|
-
msg = get$1(err, 'response.data.error_code', '');
|
|
8539
|
-
}
|
|
8540
|
-
if (msg) {
|
|
8541
|
-
err.message = msg;
|
|
8542
|
-
} else {
|
|
8543
|
-
var _err$response;
|
|
8544
|
-
err.message = ((_err$response = err.response) === null || _err$response === void 0 ? void 0 : _err$response.statusText) || err.message || '网络异常,请稍后重试。';
|
|
8545
|
-
}
|
|
8546
|
-
err.msg = err.message;
|
|
8547
|
-
return Promise.reject(err);
|
|
8548
|
-
});
|
|
8549
|
-
return axiosInstance;
|
|
8550
|
-
};
|
|
8551
|
-
var spuAxios = null;
|
|
8552
|
-
var normalAxios$1 = null;
|
|
8553
|
-
function installAxios(options) {
|
|
8554
|
-
spuAxios = createAxiosInstance$1('spu', options);
|
|
8555
|
-
normalAxios$1 = createAxiosInstance$1('normal', options);
|
|
8556
|
-
}
|
|
8557
|
-
|
|
8558
|
-
var CloudServ = /*#__PURE__*/function () {
|
|
8559
|
-
function CloudServ() {
|
|
8560
|
-
_classCallCheck$1(this, CloudServ);
|
|
8561
|
-
_defineProperty$1(this, "CLOUD_SERVE_KEY", 'cloudserv');
|
|
8562
|
-
_defineProperty$1(this, "cacheStorage", null);
|
|
8563
|
-
}
|
|
8564
|
-
_createClass$1(CloudServ, [{
|
|
8565
|
-
key: "get",
|
|
8566
|
-
value: function get() {
|
|
8567
|
-
var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'storage';
|
|
8568
|
-
if (this.cacheStorage) {
|
|
8569
|
-
return this.cacheStorage[key] || null;
|
|
8570
|
-
}
|
|
8571
|
-
var storageStr = lsProxy.getItem(this.CLOUD_SERVE_KEY);
|
|
8572
|
-
if (!storageStr) {
|
|
8573
|
-
return null;
|
|
8574
|
-
}
|
|
8575
|
-
var storage = JSON.parse(storageStr);
|
|
8576
|
-
this.cacheStorage = storage;
|
|
8577
|
-
return storage[key];
|
|
8578
|
-
}
|
|
8579
|
-
}, {
|
|
8580
|
-
key: "set",
|
|
8581
|
-
value: function set(storage) {
|
|
8582
|
-
if (_typeof(storage) === 'object') {
|
|
8583
|
-
this.cacheStorage = storage;
|
|
8584
|
-
storage = JSON.stringify(storage);
|
|
8585
|
-
}
|
|
8586
|
-
lsProxy.setItem(this.CLOUD_SERVE_KEY, storage);
|
|
8587
|
-
}
|
|
8588
|
-
}, {
|
|
8589
|
-
key: "remove",
|
|
8590
|
-
value: function remove() {
|
|
8591
|
-
lsProxy.removeItem(this.CLOUD_SERVE_KEY);
|
|
8592
|
-
}
|
|
8593
|
-
}, {
|
|
8594
|
-
key: "getProvider",
|
|
8595
|
-
value: function getProvider() {
|
|
8596
|
-
var sign = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'storage';
|
|
8597
|
-
var storage = this.get(sign);
|
|
8598
|
-
if (!storage) {
|
|
8599
|
-
return null;
|
|
8600
|
-
}
|
|
8601
|
-
var name = storage.cloudserv_storage_provider;
|
|
8602
|
-
return {
|
|
8603
|
-
name: name,
|
|
8604
|
-
isAliyun: name === 'aliyun',
|
|
8605
|
-
isAzure: name === 'azure',
|
|
8606
|
-
isAwss3: name === 'awss3',
|
|
8607
|
-
isHuawei: name === 'huawei',
|
|
8608
|
-
isMinio: name === 'minio'
|
|
8609
|
-
};
|
|
8610
|
-
}
|
|
8611
|
-
}]);
|
|
8612
|
-
return CloudServ;
|
|
8613
|
-
}();
|
|
8614
|
-
var cloudServ = new CloudServ();
|
|
8615
|
-
var getCloudServ = cloudServ.get.bind(cloudServ);
|
|
8616
|
-
|
|
8617
8390
|
var cryptoJs = {exports: {}};
|
|
8618
8391
|
|
|
8619
8392
|
function commonjsRequire(path) {
|
|
@@ -16089,6 +15862,256 @@ function decrypt(base64) {
|
|
|
16089
15862
|
return result;
|
|
16090
15863
|
}
|
|
16091
15864
|
|
|
15865
|
+
// _encrydata
|
|
15866
|
+
var normalizeEncryData = function normalizeEncryData(response) {
|
|
15867
|
+
if (response.data && response.data._encrydata && typeof response.data._encrydata === 'string') {
|
|
15868
|
+
var res = decrypt(response.data._encrydata);
|
|
15869
|
+
try {
|
|
15870
|
+
var resJson = JSON.parse(res);
|
|
15871
|
+
response.data = _objectSpread2$1({}, resJson);
|
|
15872
|
+
} catch (e) {
|
|
15873
|
+
response.data = res;
|
|
15874
|
+
}
|
|
15875
|
+
}
|
|
15876
|
+
if (response.body && response.body._encrydata && typeof response.body._encrydata === 'string') {
|
|
15877
|
+
var _res = decrypt(response.body._encrydata);
|
|
15878
|
+
try {
|
|
15879
|
+
var _resJson = JSON.parse(_res);
|
|
15880
|
+
response.body = _objectSpread2$1({}, _resJson);
|
|
15881
|
+
} catch (e) {
|
|
15882
|
+
response.body = _res;
|
|
15883
|
+
}
|
|
15884
|
+
}
|
|
15885
|
+
return response;
|
|
15886
|
+
};
|
|
15887
|
+
var createAxiosInstance$1 = function createAxiosInstance() {
|
|
15888
|
+
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'spu';
|
|
15889
|
+
var options = arguments.length > 1 ? arguments[1] : undefined;
|
|
15890
|
+
var axiosInstance = axios$3.create({
|
|
15891
|
+
baseURL: type === 'spu' ? "/api/".concat(options.modulekey, "/").concat(options.moduleversion) : ''
|
|
15892
|
+
// baseURL: '',
|
|
15893
|
+
// timeout: 36000000
|
|
15894
|
+
// withCredentials: true, // 不能开启 影响ali oss
|
|
15895
|
+
// headers: {
|
|
15896
|
+
// // 'Content-Type': 'application/json;charset=UTF-8',
|
|
15897
|
+
// // 'app_id': '100'
|
|
15898
|
+
// }
|
|
15899
|
+
});
|
|
15900
|
+
|
|
15901
|
+
axiosInstance.interceptors.request.use( /*#__PURE__*/function () {
|
|
15902
|
+
var _ref = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee(config) {
|
|
15903
|
+
var isShowLoading, isSendToken, loginState, token, moduleData, isSendTecode, tecode;
|
|
15904
|
+
return _regeneratorRuntime$1().wrap(function _callee$(_context) {
|
|
15905
|
+
while (1) switch (_context.prev = _context.next) {
|
|
15906
|
+
case 0:
|
|
15907
|
+
// const isShowLoading = typeof config?.isShowLoading !== 'undefined' ? config.isShowLoading : true
|
|
15908
|
+
// console.error(444444)
|
|
15909
|
+
// console.log(config)
|
|
15910
|
+
isShowLoading = get$1(config, 'isShowLoading', true);
|
|
15911
|
+
isShowLoading && loadding$1.open();
|
|
15912
|
+
isSendToken = get$1(config, 'isSendToken', true);
|
|
15913
|
+
if (!isSendToken) {
|
|
15914
|
+
_context.next = 16;
|
|
15915
|
+
break;
|
|
15916
|
+
}
|
|
15917
|
+
// 请求接口前校验是否过期 如果过期先刷新token
|
|
15918
|
+
loginState = getLoginState();
|
|
15919
|
+
if (!(config.url !== '/api/auth/refreshtoken' && !loginState.islogin && loginState.type === 2 && loginState.role !== 'center')) {
|
|
15920
|
+
_context.next = 14;
|
|
15921
|
+
break;
|
|
15922
|
+
}
|
|
15923
|
+
_context.prev = 6;
|
|
15924
|
+
_context.next = 9;
|
|
15925
|
+
return updateToken();
|
|
15926
|
+
case 9:
|
|
15927
|
+
_context.next = 14;
|
|
15928
|
+
break;
|
|
15929
|
+
case 11:
|
|
15930
|
+
_context.prev = 11;
|
|
15931
|
+
_context.t0 = _context["catch"](6);
|
|
15932
|
+
console.error(_context.t0);
|
|
15933
|
+
case 14:
|
|
15934
|
+
token = getToken();
|
|
15935
|
+
if (config !== null && config !== void 0 && config.headers && token) {
|
|
15936
|
+
config.headers.token = token;
|
|
15937
|
+
}
|
|
15938
|
+
case 16:
|
|
15939
|
+
if (!(type === 'spu' && config.modulekey)) {
|
|
15940
|
+
_context.next = 21;
|
|
15941
|
+
break;
|
|
15942
|
+
}
|
|
15943
|
+
_context.next = 19;
|
|
15944
|
+
return core$1.getModuleData(config.modulekey);
|
|
15945
|
+
case 19:
|
|
15946
|
+
moduleData = _context.sent;
|
|
15947
|
+
if (moduleData.data) {
|
|
15948
|
+
config.baseURL = "/api/".concat(config.modulekey, "/").concat(moduleData.data.moduleversion);
|
|
15949
|
+
} else {
|
|
15950
|
+
console.error(moduleData.errorMsg);
|
|
15951
|
+
config.baseURL = "/api/".concat(config.modulekey, "/v?.?");
|
|
15952
|
+
}
|
|
15953
|
+
case 21:
|
|
15954
|
+
// 平台的业务接口开了开发者模式后,header带上debug方便查看接口的ide日志
|
|
15955
|
+
if (type !== 'spu' && urlquery.isdebugger && config.url.indexOf('api/teapi/dy-biz/') > -1) {
|
|
15956
|
+
if (config !== null && config !== void 0 && config.headers) {
|
|
15957
|
+
config.headers.debug = 'true';
|
|
15958
|
+
}
|
|
15959
|
+
}
|
|
15960
|
+
if (type !== 'spu') {
|
|
15961
|
+
isSendTecode = get$1(config, 'isSendTecode', false);
|
|
15962
|
+
if (isSendTecode) {
|
|
15963
|
+
tecode = getTecode();
|
|
15964
|
+
if (config !== null && config !== void 0 && config.headers && tecode) {
|
|
15965
|
+
config.headers.tecode = tecode;
|
|
15966
|
+
}
|
|
15967
|
+
}
|
|
15968
|
+
}
|
|
15969
|
+
return _context.abrupt("return", config);
|
|
15970
|
+
case 24:
|
|
15971
|
+
case "end":
|
|
15972
|
+
return _context.stop();
|
|
15973
|
+
}
|
|
15974
|
+
}, _callee, null, [[6, 11]]);
|
|
15975
|
+
}));
|
|
15976
|
+
return function (_x) {
|
|
15977
|
+
return _ref.apply(this, arguments);
|
|
15978
|
+
};
|
|
15979
|
+
}(), function (error) {
|
|
15980
|
+
return Promise.reject(error);
|
|
15981
|
+
});
|
|
15982
|
+
axiosInstance.interceptors.response.use(function (res) {
|
|
15983
|
+
// debugger
|
|
15984
|
+
var isShowLoading = get$1(res, 'config.isShowLoading', true);
|
|
15985
|
+
isShowLoading && loadding$1.close();
|
|
15986
|
+
normalizeEncryData(res);
|
|
15987
|
+
var realRes = {
|
|
15988
|
+
code: 404,
|
|
15989
|
+
data: '',
|
|
15990
|
+
msg: '',
|
|
15991
|
+
message: ''
|
|
15992
|
+
};
|
|
15993
|
+
if (type === 'spu') {
|
|
15994
|
+
if (res.data.code === 200) {
|
|
15995
|
+
// return res.data
|
|
15996
|
+
realRes = {
|
|
15997
|
+
code: res.data.code,
|
|
15998
|
+
data: res.data.data,
|
|
15999
|
+
msg: res.data.msg,
|
|
16000
|
+
message: res.data.msg
|
|
16001
|
+
};
|
|
16002
|
+
return realRes;
|
|
16003
|
+
} else {
|
|
16004
|
+
realRes = {
|
|
16005
|
+
code: res.data.code,
|
|
16006
|
+
data: res.data.data,
|
|
16007
|
+
msg: res.data.msg || '网络异常,请稍后重试。',
|
|
16008
|
+
message: res.data.msg || '网络异常,请稍后重试。'
|
|
16009
|
+
};
|
|
16010
|
+
// const isShowErrorMessage = get(res, 'config.isShowErrorMessage', true)
|
|
16011
|
+
// isShowErrorMessage && Message.error(realRes.msg)
|
|
16012
|
+
return Promise.reject(realRes);
|
|
16013
|
+
}
|
|
16014
|
+
} else if (type === 'normal') {
|
|
16015
|
+
var _res$data, _res$data2, _res$data3;
|
|
16016
|
+
realRes = {
|
|
16017
|
+
code: res.status || 200,
|
|
16018
|
+
data: ((_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.resp_data) || res.data,
|
|
16019
|
+
msg: ((_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.error_code) || '',
|
|
16020
|
+
message: ((_res$data3 = res.data) === null || _res$data3 === void 0 ? void 0 : _res$data3.error_code) || ''
|
|
16021
|
+
};
|
|
16022
|
+
return realRes;
|
|
16023
|
+
}
|
|
16024
|
+
}, function (err) {
|
|
16025
|
+
// err: AxiosError
|
|
16026
|
+
// console.log(err)
|
|
16027
|
+
// debugger
|
|
16028
|
+
var isShowLoading = get$1(err, 'config.isShowLoading', true);
|
|
16029
|
+
isShowLoading && loadding$1.close();
|
|
16030
|
+
// console.log(err)
|
|
16031
|
+
// debugger
|
|
16032
|
+
var msg = '';
|
|
16033
|
+
if (type === 'spu') {
|
|
16034
|
+
msg = get$1(err, 'response.data.msg', '');
|
|
16035
|
+
} else {
|
|
16036
|
+
msg = get$1(err, 'response.data.error_code', '');
|
|
16037
|
+
}
|
|
16038
|
+
if (msg) {
|
|
16039
|
+
err.message = msg;
|
|
16040
|
+
} else {
|
|
16041
|
+
var _err$response;
|
|
16042
|
+
err.message = ((_err$response = err.response) === null || _err$response === void 0 ? void 0 : _err$response.statusText) || err.message || '网络异常,请稍后重试。';
|
|
16043
|
+
}
|
|
16044
|
+
err.msg = err.message;
|
|
16045
|
+
return Promise.reject(err);
|
|
16046
|
+
});
|
|
16047
|
+
return axiosInstance;
|
|
16048
|
+
};
|
|
16049
|
+
var spuAxios = null;
|
|
16050
|
+
var normalAxios$1 = null;
|
|
16051
|
+
function installAxios(options) {
|
|
16052
|
+
spuAxios = createAxiosInstance$1('spu', options);
|
|
16053
|
+
normalAxios$1 = createAxiosInstance$1('normal', options);
|
|
16054
|
+
}
|
|
16055
|
+
|
|
16056
|
+
var CloudServ = /*#__PURE__*/function () {
|
|
16057
|
+
function CloudServ() {
|
|
16058
|
+
_classCallCheck$1(this, CloudServ);
|
|
16059
|
+
_defineProperty$1(this, "CLOUD_SERVE_KEY", 'cloudserv');
|
|
16060
|
+
_defineProperty$1(this, "cacheStorage", null);
|
|
16061
|
+
}
|
|
16062
|
+
_createClass$1(CloudServ, [{
|
|
16063
|
+
key: "get",
|
|
16064
|
+
value: function get() {
|
|
16065
|
+
var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'storage';
|
|
16066
|
+
if (this.cacheStorage) {
|
|
16067
|
+
return this.cacheStorage[key] || null;
|
|
16068
|
+
}
|
|
16069
|
+
var storageStr = lsProxy.getItem(this.CLOUD_SERVE_KEY);
|
|
16070
|
+
if (!storageStr) {
|
|
16071
|
+
return null;
|
|
16072
|
+
}
|
|
16073
|
+
var storage = JSON.parse(storageStr);
|
|
16074
|
+
this.cacheStorage = storage;
|
|
16075
|
+
return storage[key];
|
|
16076
|
+
}
|
|
16077
|
+
}, {
|
|
16078
|
+
key: "set",
|
|
16079
|
+
value: function set(storage) {
|
|
16080
|
+
if (_typeof(storage) === 'object') {
|
|
16081
|
+
this.cacheStorage = storage;
|
|
16082
|
+
storage = JSON.stringify(storage);
|
|
16083
|
+
}
|
|
16084
|
+
lsProxy.setItem(this.CLOUD_SERVE_KEY, storage);
|
|
16085
|
+
}
|
|
16086
|
+
}, {
|
|
16087
|
+
key: "remove",
|
|
16088
|
+
value: function remove() {
|
|
16089
|
+
lsProxy.removeItem(this.CLOUD_SERVE_KEY);
|
|
16090
|
+
}
|
|
16091
|
+
}, {
|
|
16092
|
+
key: "getProvider",
|
|
16093
|
+
value: function getProvider() {
|
|
16094
|
+
var sign = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'storage';
|
|
16095
|
+
var storage = this.get(sign);
|
|
16096
|
+
if (!storage) {
|
|
16097
|
+
return null;
|
|
16098
|
+
}
|
|
16099
|
+
var name = storage.cloudserv_storage_provider;
|
|
16100
|
+
return {
|
|
16101
|
+
name: name,
|
|
16102
|
+
isAliyun: name === 'aliyun',
|
|
16103
|
+
isAzure: name === 'azure',
|
|
16104
|
+
isAwss3: name === 'awss3',
|
|
16105
|
+
isHuawei: name === 'huawei',
|
|
16106
|
+
isMinio: name === 'minio'
|
|
16107
|
+
};
|
|
16108
|
+
}
|
|
16109
|
+
}]);
|
|
16110
|
+
return CloudServ;
|
|
16111
|
+
}();
|
|
16112
|
+
var cloudServ = new CloudServ();
|
|
16113
|
+
var getCloudServ = cloudServ.get.bind(cloudServ);
|
|
16114
|
+
|
|
16092
16115
|
var TenantSetting = /*#__PURE__*/function () {
|
|
16093
16116
|
function TenantSetting() {
|
|
16094
16117
|
_classCallCheck$1(this, TenantSetting);
|
package/package.json
CHANGED
package/src/axios.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { getToken, updateToken, getLoginState } from './login'
|
|
|
6
6
|
import core from './core'
|
|
7
7
|
import { urlquery } from './urlquery'
|
|
8
8
|
import { getTecode } from './envService'
|
|
9
|
+
import { decrypt } from './crypt'
|
|
9
10
|
|
|
10
11
|
interface Response {
|
|
11
12
|
code: number | string
|
|
@@ -14,6 +15,34 @@ interface Response {
|
|
|
14
15
|
message: string
|
|
15
16
|
}
|
|
16
17
|
|
|
18
|
+
// _encrydata
|
|
19
|
+
const normalizeEncryData = (response: any) => {
|
|
20
|
+
if (response.data && response.data._encrydata && typeof response.data._encrydata === 'string') {
|
|
21
|
+
let res = decrypt(response.data._encrydata)
|
|
22
|
+
try {
|
|
23
|
+
let resJson = JSON.parse(res)
|
|
24
|
+
response.data = {
|
|
25
|
+
...resJson
|
|
26
|
+
}
|
|
27
|
+
} catch (e) {
|
|
28
|
+
response.data = res
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (response.body && response.body._encrydata && typeof response.body._encrydata === 'string') {
|
|
32
|
+
let res = decrypt(response.body._encrydata)
|
|
33
|
+
try {
|
|
34
|
+
let resJson = JSON.parse(res)
|
|
35
|
+
response.body = {
|
|
36
|
+
...resJson
|
|
37
|
+
}
|
|
38
|
+
} catch (e) {
|
|
39
|
+
response.body = res
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return response
|
|
44
|
+
}
|
|
45
|
+
|
|
17
46
|
const createAxiosInstance = (type: 'spu' | 'normal' = 'spu', options: any) => {
|
|
18
47
|
const axiosInstance: AxiosInstance = axios.create({
|
|
19
48
|
baseURL: type === 'spu' ? `/api/${options.modulekey}/${options.moduleversion}` : ''
|
|
@@ -97,6 +126,7 @@ const createAxiosInstance = (type: 'spu' | 'normal' = 'spu', options: any) => {
|
|
|
97
126
|
// debugger
|
|
98
127
|
const isShowLoading = get(res, 'config.isShowLoading', true)
|
|
99
128
|
isShowLoading && loadding.close()
|
|
129
|
+
normalizeEncryData(res)
|
|
100
130
|
|
|
101
131
|
let realRes: Response = {
|
|
102
132
|
code: 404,
|