@smart100/spu-web-plugin 1.0.20 → 1.0.22
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/index.d.ts +2 -0
- package/dist/spu-web-plugin.mjs +264 -229
- package/package.json +1 -1
- package/src/axios.ts +30 -0
- package/src/index.ts +3 -0
- package/src/types/index.d.ts +2 -0
package/dist/index.d.ts
CHANGED
|
@@ -128,6 +128,8 @@ export const getUniqueid: () => string
|
|
|
128
128
|
export const getUuid: () => string
|
|
129
129
|
export const functionCheck: (functioncode?: string) => boolean
|
|
130
130
|
export const getServerTime: () => Promise<string>
|
|
131
|
+
export const encrypt: (str: string) => string
|
|
132
|
+
export const decrypt: (str: string) => string
|
|
131
133
|
export const setTitle: (pagetitle?: string) => void
|
|
132
134
|
export const isInApp: () => boolean
|
|
133
135
|
export const AMapLoader: IAMapLoader
|
package/dist/spu-web-plugin.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var version = "1.0.
|
|
1
|
+
var version = "1.0.22";
|
|
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) {
|
|
@@ -16072,6 +15845,18 @@ function byteToString(arr) {
|
|
|
16072
15845
|
return str;
|
|
16073
15846
|
}
|
|
16074
15847
|
var key = byteToString([0x36, 0x31, 0x33, 0x30, 0x32, 0x32, 0x32, 0x32, 0x32]);
|
|
15848
|
+
// 加密算法
|
|
15849
|
+
function encrypt(dataString) {
|
|
15850
|
+
// ENC加密
|
|
15851
|
+
var keyHex = CryptoJS.enc.Utf8.parse(key);
|
|
15852
|
+
var encrypted = CryptoJS.DES.encrypt(dataString, keyHex, {
|
|
15853
|
+
mode: CryptoJS.mode.ECB,
|
|
15854
|
+
padding: CryptoJS.pad.Pkcs7
|
|
15855
|
+
});
|
|
15856
|
+
// base64加密
|
|
15857
|
+
var base64 = encrypted.ciphertext.toString(CryptoJS.enc.Base64);
|
|
15858
|
+
return base64;
|
|
15859
|
+
}
|
|
16075
15860
|
// 解密算法
|
|
16076
15861
|
function decrypt(base64) {
|
|
16077
15862
|
// base64解密
|
|
@@ -16089,6 +15874,256 @@ function decrypt(base64) {
|
|
|
16089
15874
|
return result;
|
|
16090
15875
|
}
|
|
16091
15876
|
|
|
15877
|
+
// _encrydata
|
|
15878
|
+
var normalizeEncryData = function normalizeEncryData(response) {
|
|
15879
|
+
if (response.data && response.data._encrydata && typeof response.data._encrydata === 'string') {
|
|
15880
|
+
var res = decrypt(response.data._encrydata);
|
|
15881
|
+
try {
|
|
15882
|
+
var resJson = JSON.parse(res);
|
|
15883
|
+
response.data = _objectSpread2$1({}, resJson);
|
|
15884
|
+
} catch (e) {
|
|
15885
|
+
response.data = res;
|
|
15886
|
+
}
|
|
15887
|
+
}
|
|
15888
|
+
if (response.body && response.body._encrydata && typeof response.body._encrydata === 'string') {
|
|
15889
|
+
var _res = decrypt(response.body._encrydata);
|
|
15890
|
+
try {
|
|
15891
|
+
var _resJson = JSON.parse(_res);
|
|
15892
|
+
response.body = _objectSpread2$1({}, _resJson);
|
|
15893
|
+
} catch (e) {
|
|
15894
|
+
response.body = _res;
|
|
15895
|
+
}
|
|
15896
|
+
}
|
|
15897
|
+
return response;
|
|
15898
|
+
};
|
|
15899
|
+
var createAxiosInstance$1 = function createAxiosInstance() {
|
|
15900
|
+
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'spu';
|
|
15901
|
+
var options = arguments.length > 1 ? arguments[1] : undefined;
|
|
15902
|
+
var axiosInstance = axios$3.create({
|
|
15903
|
+
baseURL: type === 'spu' ? "/api/".concat(options.modulekey, "/").concat(options.moduleversion) : ''
|
|
15904
|
+
// baseURL: '',
|
|
15905
|
+
// timeout: 36000000
|
|
15906
|
+
// withCredentials: true, // 不能开启 影响ali oss
|
|
15907
|
+
// headers: {
|
|
15908
|
+
// // 'Content-Type': 'application/json;charset=UTF-8',
|
|
15909
|
+
// // 'app_id': '100'
|
|
15910
|
+
// }
|
|
15911
|
+
});
|
|
15912
|
+
|
|
15913
|
+
axiosInstance.interceptors.request.use( /*#__PURE__*/function () {
|
|
15914
|
+
var _ref = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee(config) {
|
|
15915
|
+
var isShowLoading, isSendToken, loginState, token, moduleData, isSendTecode, tecode;
|
|
15916
|
+
return _regeneratorRuntime$1().wrap(function _callee$(_context) {
|
|
15917
|
+
while (1) switch (_context.prev = _context.next) {
|
|
15918
|
+
case 0:
|
|
15919
|
+
// const isShowLoading = typeof config?.isShowLoading !== 'undefined' ? config.isShowLoading : true
|
|
15920
|
+
// console.error(444444)
|
|
15921
|
+
// console.log(config)
|
|
15922
|
+
isShowLoading = get$1(config, 'isShowLoading', true);
|
|
15923
|
+
isShowLoading && loadding$1.open();
|
|
15924
|
+
isSendToken = get$1(config, 'isSendToken', true);
|
|
15925
|
+
if (!isSendToken) {
|
|
15926
|
+
_context.next = 16;
|
|
15927
|
+
break;
|
|
15928
|
+
}
|
|
15929
|
+
// 请求接口前校验是否过期 如果过期先刷新token
|
|
15930
|
+
loginState = getLoginState();
|
|
15931
|
+
if (!(config.url !== '/api/auth/refreshtoken' && !loginState.islogin && loginState.type === 2 && loginState.role !== 'center')) {
|
|
15932
|
+
_context.next = 14;
|
|
15933
|
+
break;
|
|
15934
|
+
}
|
|
15935
|
+
_context.prev = 6;
|
|
15936
|
+
_context.next = 9;
|
|
15937
|
+
return updateToken();
|
|
15938
|
+
case 9:
|
|
15939
|
+
_context.next = 14;
|
|
15940
|
+
break;
|
|
15941
|
+
case 11:
|
|
15942
|
+
_context.prev = 11;
|
|
15943
|
+
_context.t0 = _context["catch"](6);
|
|
15944
|
+
console.error(_context.t0);
|
|
15945
|
+
case 14:
|
|
15946
|
+
token = getToken();
|
|
15947
|
+
if (config !== null && config !== void 0 && config.headers && token) {
|
|
15948
|
+
config.headers.token = token;
|
|
15949
|
+
}
|
|
15950
|
+
case 16:
|
|
15951
|
+
if (!(type === 'spu' && config.modulekey)) {
|
|
15952
|
+
_context.next = 21;
|
|
15953
|
+
break;
|
|
15954
|
+
}
|
|
15955
|
+
_context.next = 19;
|
|
15956
|
+
return core$1.getModuleData(config.modulekey);
|
|
15957
|
+
case 19:
|
|
15958
|
+
moduleData = _context.sent;
|
|
15959
|
+
if (moduleData.data) {
|
|
15960
|
+
config.baseURL = "/api/".concat(config.modulekey, "/").concat(moduleData.data.moduleversion);
|
|
15961
|
+
} else {
|
|
15962
|
+
console.error(moduleData.errorMsg);
|
|
15963
|
+
config.baseURL = "/api/".concat(config.modulekey, "/v?.?");
|
|
15964
|
+
}
|
|
15965
|
+
case 21:
|
|
15966
|
+
// 平台的业务接口开了开发者模式后,header带上debug方便查看接口的ide日志
|
|
15967
|
+
if (type !== 'spu' && urlquery.isdebugger && config.url.indexOf('api/teapi/dy-biz/') > -1) {
|
|
15968
|
+
if (config !== null && config !== void 0 && config.headers) {
|
|
15969
|
+
config.headers.debug = 'true';
|
|
15970
|
+
}
|
|
15971
|
+
}
|
|
15972
|
+
if (type !== 'spu') {
|
|
15973
|
+
isSendTecode = get$1(config, 'isSendTecode', false);
|
|
15974
|
+
if (isSendTecode) {
|
|
15975
|
+
tecode = getTecode();
|
|
15976
|
+
if (config !== null && config !== void 0 && config.headers && tecode) {
|
|
15977
|
+
config.headers.tecode = tecode;
|
|
15978
|
+
}
|
|
15979
|
+
}
|
|
15980
|
+
}
|
|
15981
|
+
return _context.abrupt("return", config);
|
|
15982
|
+
case 24:
|
|
15983
|
+
case "end":
|
|
15984
|
+
return _context.stop();
|
|
15985
|
+
}
|
|
15986
|
+
}, _callee, null, [[6, 11]]);
|
|
15987
|
+
}));
|
|
15988
|
+
return function (_x) {
|
|
15989
|
+
return _ref.apply(this, arguments);
|
|
15990
|
+
};
|
|
15991
|
+
}(), function (error) {
|
|
15992
|
+
return Promise.reject(error);
|
|
15993
|
+
});
|
|
15994
|
+
axiosInstance.interceptors.response.use(function (res) {
|
|
15995
|
+
// debugger
|
|
15996
|
+
var isShowLoading = get$1(res, 'config.isShowLoading', true);
|
|
15997
|
+
isShowLoading && loadding$1.close();
|
|
15998
|
+
normalizeEncryData(res);
|
|
15999
|
+
var realRes = {
|
|
16000
|
+
code: 404,
|
|
16001
|
+
data: '',
|
|
16002
|
+
msg: '',
|
|
16003
|
+
message: ''
|
|
16004
|
+
};
|
|
16005
|
+
if (type === 'spu') {
|
|
16006
|
+
if (res.data.code === 200) {
|
|
16007
|
+
// return res.data
|
|
16008
|
+
realRes = {
|
|
16009
|
+
code: res.data.code,
|
|
16010
|
+
data: res.data.data,
|
|
16011
|
+
msg: res.data.msg,
|
|
16012
|
+
message: res.data.msg
|
|
16013
|
+
};
|
|
16014
|
+
return realRes;
|
|
16015
|
+
} else {
|
|
16016
|
+
realRes = {
|
|
16017
|
+
code: res.data.code,
|
|
16018
|
+
data: res.data.data,
|
|
16019
|
+
msg: res.data.msg || '网络异常,请稍后重试。',
|
|
16020
|
+
message: res.data.msg || '网络异常,请稍后重试。'
|
|
16021
|
+
};
|
|
16022
|
+
// const isShowErrorMessage = get(res, 'config.isShowErrorMessage', true)
|
|
16023
|
+
// isShowErrorMessage && Message.error(realRes.msg)
|
|
16024
|
+
return Promise.reject(realRes);
|
|
16025
|
+
}
|
|
16026
|
+
} else if (type === 'normal') {
|
|
16027
|
+
var _res$data, _res$data2, _res$data3;
|
|
16028
|
+
realRes = {
|
|
16029
|
+
code: res.status || 200,
|
|
16030
|
+
data: ((_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.resp_data) || res.data,
|
|
16031
|
+
msg: ((_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.error_code) || '',
|
|
16032
|
+
message: ((_res$data3 = res.data) === null || _res$data3 === void 0 ? void 0 : _res$data3.error_code) || ''
|
|
16033
|
+
};
|
|
16034
|
+
return realRes;
|
|
16035
|
+
}
|
|
16036
|
+
}, function (err) {
|
|
16037
|
+
// err: AxiosError
|
|
16038
|
+
// console.log(err)
|
|
16039
|
+
// debugger
|
|
16040
|
+
var isShowLoading = get$1(err, 'config.isShowLoading', true);
|
|
16041
|
+
isShowLoading && loadding$1.close();
|
|
16042
|
+
// console.log(err)
|
|
16043
|
+
// debugger
|
|
16044
|
+
var msg = '';
|
|
16045
|
+
if (type === 'spu') {
|
|
16046
|
+
msg = get$1(err, 'response.data.msg', '');
|
|
16047
|
+
} else {
|
|
16048
|
+
msg = get$1(err, 'response.data.error_code', '');
|
|
16049
|
+
}
|
|
16050
|
+
if (msg) {
|
|
16051
|
+
err.message = msg;
|
|
16052
|
+
} else {
|
|
16053
|
+
var _err$response;
|
|
16054
|
+
err.message = ((_err$response = err.response) === null || _err$response === void 0 ? void 0 : _err$response.statusText) || err.message || '网络异常,请稍后重试。';
|
|
16055
|
+
}
|
|
16056
|
+
err.msg = err.message;
|
|
16057
|
+
return Promise.reject(err);
|
|
16058
|
+
});
|
|
16059
|
+
return axiosInstance;
|
|
16060
|
+
};
|
|
16061
|
+
var spuAxios = null;
|
|
16062
|
+
var normalAxios$1 = null;
|
|
16063
|
+
function installAxios(options) {
|
|
16064
|
+
spuAxios = createAxiosInstance$1('spu', options);
|
|
16065
|
+
normalAxios$1 = createAxiosInstance$1('normal', options);
|
|
16066
|
+
}
|
|
16067
|
+
|
|
16068
|
+
var CloudServ = /*#__PURE__*/function () {
|
|
16069
|
+
function CloudServ() {
|
|
16070
|
+
_classCallCheck$1(this, CloudServ);
|
|
16071
|
+
_defineProperty$1(this, "CLOUD_SERVE_KEY", 'cloudserv');
|
|
16072
|
+
_defineProperty$1(this, "cacheStorage", null);
|
|
16073
|
+
}
|
|
16074
|
+
_createClass$1(CloudServ, [{
|
|
16075
|
+
key: "get",
|
|
16076
|
+
value: function get() {
|
|
16077
|
+
var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'storage';
|
|
16078
|
+
if (this.cacheStorage) {
|
|
16079
|
+
return this.cacheStorage[key] || null;
|
|
16080
|
+
}
|
|
16081
|
+
var storageStr = lsProxy.getItem(this.CLOUD_SERVE_KEY);
|
|
16082
|
+
if (!storageStr) {
|
|
16083
|
+
return null;
|
|
16084
|
+
}
|
|
16085
|
+
var storage = JSON.parse(storageStr);
|
|
16086
|
+
this.cacheStorage = storage;
|
|
16087
|
+
return storage[key];
|
|
16088
|
+
}
|
|
16089
|
+
}, {
|
|
16090
|
+
key: "set",
|
|
16091
|
+
value: function set(storage) {
|
|
16092
|
+
if (_typeof(storage) === 'object') {
|
|
16093
|
+
this.cacheStorage = storage;
|
|
16094
|
+
storage = JSON.stringify(storage);
|
|
16095
|
+
}
|
|
16096
|
+
lsProxy.setItem(this.CLOUD_SERVE_KEY, storage);
|
|
16097
|
+
}
|
|
16098
|
+
}, {
|
|
16099
|
+
key: "remove",
|
|
16100
|
+
value: function remove() {
|
|
16101
|
+
lsProxy.removeItem(this.CLOUD_SERVE_KEY);
|
|
16102
|
+
}
|
|
16103
|
+
}, {
|
|
16104
|
+
key: "getProvider",
|
|
16105
|
+
value: function getProvider() {
|
|
16106
|
+
var sign = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'storage';
|
|
16107
|
+
var storage = this.get(sign);
|
|
16108
|
+
if (!storage) {
|
|
16109
|
+
return null;
|
|
16110
|
+
}
|
|
16111
|
+
var name = storage.cloudserv_storage_provider;
|
|
16112
|
+
return {
|
|
16113
|
+
name: name,
|
|
16114
|
+
isAliyun: name === 'aliyun',
|
|
16115
|
+
isAzure: name === 'azure',
|
|
16116
|
+
isAwss3: name === 'awss3',
|
|
16117
|
+
isHuawei: name === 'huawei',
|
|
16118
|
+
isMinio: name === 'minio'
|
|
16119
|
+
};
|
|
16120
|
+
}
|
|
16121
|
+
}]);
|
|
16122
|
+
return CloudServ;
|
|
16123
|
+
}();
|
|
16124
|
+
var cloudServ = new CloudServ();
|
|
16125
|
+
var getCloudServ = cloudServ.get.bind(cloudServ);
|
|
16126
|
+
|
|
16092
16127
|
var TenantSetting = /*#__PURE__*/function () {
|
|
16093
16128
|
function TenantSetting() {
|
|
16094
16129
|
_classCallCheck$1(this, TenantSetting);
|
|
@@ -70442,4 +70477,4 @@ var SPUWebPlugin = {
|
|
|
70442
70477
|
version: version
|
|
70443
70478
|
};
|
|
70444
70479
|
|
|
70445
|
-
export { AMapLoader, Module, normalAxios$1 as apaasAxios, normalAxios$1 as axios, checkLogin, index as components, SPUWebPlugin as default, downloadService, expandexp, functionCheck, getAddress, getCloudServ, getDistance, getLocation, getRefreshToken, getServToken, getServerTime, getToken, getTokenExpires, getUniqueid, getUser, v4 as getUuid, globalConfig, globalOptions, isInApp, isdebugger, isvirtuallocation, lsProxy, mapService, setRefreshToken, setTitle, setToken, setTokenExpires, singleLogin, spuAxios, spuConfig, ssProxy, updateToken, uploadService, wxworkSuite };
|
|
70480
|
+
export { AMapLoader, Module, normalAxios$1 as apaasAxios, normalAxios$1 as axios, checkLogin, index as components, decrypt, SPUWebPlugin as default, downloadService, encrypt, expandexp, functionCheck, getAddress, getCloudServ, getDistance, getLocation, getRefreshToken, getServToken, getServerTime, getToken, getTokenExpires, getUniqueid, getUser, v4 as getUuid, globalConfig, globalOptions, isInApp, isdebugger, isvirtuallocation, lsProxy, mapService, setRefreshToken, setTitle, setToken, setTokenExpires, singleLogin, spuAxios, spuConfig, ssProxy, updateToken, uploadService, wxworkSuite };
|
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,
|
package/src/index.ts
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
isvirtuallocation,
|
|
19
19
|
getServerTime
|
|
20
20
|
} from './utils'
|
|
21
|
+
import { encrypt, decrypt } from './crypt'
|
|
21
22
|
import { installUrlquery } from './urlquery'
|
|
22
23
|
import { mapService } from './map/MapService'
|
|
23
24
|
import AMapLoader from './map/AMapLoader'
|
|
@@ -129,6 +130,8 @@ export {
|
|
|
129
130
|
getUuid,
|
|
130
131
|
functionCheck,
|
|
131
132
|
getServerTime,
|
|
133
|
+
encrypt,
|
|
134
|
+
decrypt,
|
|
132
135
|
setTitle,
|
|
133
136
|
isInApp,
|
|
134
137
|
AMapLoader,
|
package/src/types/index.d.ts
CHANGED
|
@@ -128,6 +128,8 @@ export const getUniqueid: () => string
|
|
|
128
128
|
export const getUuid: () => string
|
|
129
129
|
export const functionCheck: (functioncode?: string) => boolean
|
|
130
130
|
export const getServerTime: () => Promise<string>
|
|
131
|
+
export const encrypt: (str: string) => string
|
|
132
|
+
export const decrypt: (str: string) => string
|
|
131
133
|
export const setTitle: (pagetitle?: string) => void
|
|
132
134
|
export const isInApp: () => boolean
|
|
133
135
|
export const AMapLoader: IAMapLoader
|