@smart100/spu-web-plugin 0.0.33 → 0.0.35
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 +3 -2
- package/dist/spu-web-plugin.mjs +1237 -1113
- package/package.json +1 -1
- package/src/axios.ts +17 -2
- package/src/index.ts +12 -11
- package/src/location.ts +1 -1
- package/src/login.ts +83 -22
- package/src/types/index.d.ts +3 -2
- package/src/utils.ts +20 -3
package/dist/spu-web-plugin.mjs
CHANGED
|
@@ -708,7 +708,7 @@ function _toPropertyKey$1(arg) {
|
|
|
708
708
|
return typeof key === "symbol" ? key : String(key);
|
|
709
709
|
}
|
|
710
710
|
|
|
711
|
-
var version = "0.0.
|
|
711
|
+
var version = "0.0.35";
|
|
712
712
|
|
|
713
713
|
/** Detect free variable `global` from Node.js. */
|
|
714
714
|
var freeGlobal$2 = typeof global == 'object' && global && global.Object === Object && global;
|
|
@@ -14071,7 +14071,7 @@ var getSpuLocation = /*#__PURE__*/function () {
|
|
|
14071
14071
|
var isload = false;
|
|
14072
14072
|
setTimeout(function () {
|
|
14073
14073
|
if (!isload) {
|
|
14074
|
-
console.error('getSpuLocation timeout
|
|
14074
|
+
console.error('getSpuLocation timeout 10000');
|
|
14075
14075
|
resolve(null);
|
|
14076
14076
|
}
|
|
14077
14077
|
}, 10000);
|
|
@@ -17661,514 +17661,1264 @@ var Loadding = /*#__PURE__*/function () {
|
|
|
17661
17661
|
}();
|
|
17662
17662
|
var loadding = new Loadding();
|
|
17663
17663
|
|
|
17664
|
-
var
|
|
17665
|
-
var hostname = url.split('://')[1].split(':')[0].split('/')[0];
|
|
17666
|
-
var arr = hostname.split('.');
|
|
17667
|
-
if (arr.length !== 4) return false;
|
|
17668
|
-
var flag = true;
|
|
17669
|
-
for (var i = 0, len = arr.length; i < len; i++) {
|
|
17670
|
-
if (!Number.isInteger(Number(arr[i]))) {
|
|
17671
|
-
flag = false;
|
|
17672
|
-
break;
|
|
17673
|
-
}
|
|
17674
|
-
}
|
|
17675
|
-
return flag;
|
|
17676
|
-
};
|
|
17664
|
+
function e(e){this.message=e;}e.prototype=new Error,e.prototype.name="InvalidCharacterError";var r="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(r){var t=String(r).replace(/=+$/,"");if(t.length%4==1)throw new e("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,o,a=0,i=0,c="";o=t.charAt(i++);~o&&(n=a%4?64*n+o:o,a++%4)?c+=String.fromCharCode(255&n>>(-2*a&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return c};function t(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw "Illegal base64url string!"}try{return function(e){return decodeURIComponent(r(e).replace(/(.)/g,(function(e,r){var t=r.charCodeAt(0).toString(16).toUpperCase();return t.length<2&&(t="0"+t),"%"+t})))}(t)}catch(e){return r(t)}}function n(e){this.message=e;}function o(e,r){if("string"!=typeof e)throw new n("Invalid token specified");var o=!0===(r=r||{}).header?0:1;try{return JSON.parse(t(e.split(".")[o]))}catch(e){throw new n("Invalid token specified: "+e.message)}}n.prototype=new Error,n.prototype.name="InvalidTokenError";
|
|
17677
17665
|
|
|
17678
|
-
|
|
17679
|
-
|
|
17680
|
-
|
|
17681
|
-
|
|
17682
|
-
|
|
17683
|
-
var arr = res.split('//');
|
|
17684
|
-
arr[0] = location.protocol;
|
|
17685
|
-
res = arr.join('//');
|
|
17686
|
-
}
|
|
17687
|
-
}
|
|
17688
|
-
return res;
|
|
17689
|
-
};
|
|
17690
|
-
var Core = /*#__PURE__*/function () {
|
|
17691
|
-
function Core() {
|
|
17692
|
-
_classCallCheck$1(this, Core);
|
|
17693
|
-
_defineProperty$1(this, "loadStatus", 0);
|
|
17694
|
-
// 0未开始 1正在加载 2加载完成
|
|
17695
|
-
_defineProperty$1(this, "cache", {
|
|
17696
|
-
envName: '',
|
|
17697
|
-
envData: null,
|
|
17698
|
-
tenantCode: '',
|
|
17699
|
-
webDefineData: null
|
|
17700
|
-
});
|
|
17701
|
-
_defineProperty$1(this, "requestDataPromise", null);
|
|
17666
|
+
var CloudServ = /*#__PURE__*/function () {
|
|
17667
|
+
function CloudServ() {
|
|
17668
|
+
_classCallCheck$1(this, CloudServ);
|
|
17669
|
+
_defineProperty$1(this, "CLOUD_SERVE_KEY", 'cloudserv');
|
|
17670
|
+
_defineProperty$1(this, "cacheStorage", null);
|
|
17702
17671
|
}
|
|
17703
|
-
_createClass$1(
|
|
17704
|
-
key: "
|
|
17705
|
-
value: function
|
|
17706
|
-
|
|
17707
|
-
this.
|
|
17708
|
-
|
|
17709
|
-
|
|
17710
|
-
|
|
17711
|
-
|
|
17712
|
-
|
|
17713
|
-
|
|
17672
|
+
_createClass$1(CloudServ, [{
|
|
17673
|
+
key: "get",
|
|
17674
|
+
value: function get() {
|
|
17675
|
+
var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'storage';
|
|
17676
|
+
if (this.cacheStorage) {
|
|
17677
|
+
return this.cacheStorage[key] || null;
|
|
17678
|
+
}
|
|
17679
|
+
var storageStr = lsProxy.getItem(this.CLOUD_SERVE_KEY);
|
|
17680
|
+
if (!storageStr) {
|
|
17681
|
+
return null;
|
|
17682
|
+
}
|
|
17683
|
+
var storage = JSON.parse(storageStr);
|
|
17684
|
+
this.cacheStorage = storage;
|
|
17685
|
+
return storage[key];
|
|
17714
17686
|
}
|
|
17715
|
-
|
|
17716
|
-
// 请求实时G3数据
|
|
17717
17687
|
}, {
|
|
17718
|
-
key: "
|
|
17719
|
-
value: function () {
|
|
17720
|
-
|
|
17721
|
-
|
|
17722
|
-
|
|
17723
|
-
while (1) switch (_context.prev = _context.next) {
|
|
17724
|
-
case 0:
|
|
17725
|
-
_context.next = 2;
|
|
17726
|
-
return Module.getEnvname();
|
|
17727
|
-
case 2:
|
|
17728
|
-
nowEnvname = _context.sent;
|
|
17729
|
-
nowTenantCode = getUser('tenantcode') || '';
|
|
17730
|
-
this.cache.envName = nowEnvname;
|
|
17731
|
-
this.cache.tenantCode = nowTenantCode;
|
|
17732
|
-
_context.next = 8;
|
|
17733
|
-
return this.requestEnvData(nowEnvname);
|
|
17734
|
-
case 8:
|
|
17735
|
-
this.cache.envData = _context.sent;
|
|
17736
|
-
_context.next = 11;
|
|
17737
|
-
return this.requestWebDefineData();
|
|
17738
|
-
case 11:
|
|
17739
|
-
this.cache.webDefineData = _context.sent;
|
|
17740
|
-
return _context.abrupt("return", this.cache);
|
|
17741
|
-
case 13:
|
|
17742
|
-
case "end":
|
|
17743
|
-
return _context.stop();
|
|
17744
|
-
}
|
|
17745
|
-
}, _callee, this);
|
|
17746
|
-
}));
|
|
17747
|
-
function requestData() {
|
|
17748
|
-
return _requestData.apply(this, arguments);
|
|
17688
|
+
key: "set",
|
|
17689
|
+
value: function set(storage) {
|
|
17690
|
+
if (_typeof(storage) === 'object') {
|
|
17691
|
+
this.cacheStorage = storage;
|
|
17692
|
+
storage = JSON.stringify(storage);
|
|
17749
17693
|
}
|
|
17750
|
-
|
|
17751
|
-
}
|
|
17694
|
+
lsProxy.setItem(this.CLOUD_SERVE_KEY, storage);
|
|
17695
|
+
}
|
|
17752
17696
|
}, {
|
|
17753
|
-
key: "
|
|
17697
|
+
key: "remove",
|
|
17698
|
+
value: function remove() {
|
|
17699
|
+
lsProxy.removeItem(this.CLOUD_SERVE_KEY);
|
|
17700
|
+
}
|
|
17701
|
+
}, {
|
|
17702
|
+
key: "getProvider",
|
|
17703
|
+
value: function getProvider() {
|
|
17704
|
+
var sign = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'storage';
|
|
17705
|
+
var storage = this.get(sign);
|
|
17706
|
+
if (!storage) {
|
|
17707
|
+
return false;
|
|
17708
|
+
}
|
|
17709
|
+
return storage.cloudserv_storage_provider;
|
|
17710
|
+
}
|
|
17711
|
+
}, {
|
|
17712
|
+
key: "isAliyun",
|
|
17713
|
+
value: function isAliyun() {
|
|
17714
|
+
var sign = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'storage';
|
|
17715
|
+
return this.getProvider(sign) === 'aliyun';
|
|
17716
|
+
}
|
|
17717
|
+
}, {
|
|
17718
|
+
key: "isAzure",
|
|
17719
|
+
value: function isAzure() {
|
|
17720
|
+
var sign = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'storage';
|
|
17721
|
+
return this.getProvider(sign) === 'azure';
|
|
17722
|
+
}
|
|
17723
|
+
}, {
|
|
17724
|
+
key: "isAwss3",
|
|
17725
|
+
value: function isAwss3() {
|
|
17726
|
+
var sign = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'storage';
|
|
17727
|
+
return this.getProvider(sign) === 'awss3';
|
|
17728
|
+
}
|
|
17729
|
+
}, {
|
|
17730
|
+
key: "isHuawei",
|
|
17731
|
+
value: function isHuawei() {
|
|
17732
|
+
var sign = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'storage';
|
|
17733
|
+
return this.getProvider(sign) === 'huawei';
|
|
17734
|
+
}
|
|
17735
|
+
}]);
|
|
17736
|
+
return CloudServ;
|
|
17737
|
+
}();
|
|
17738
|
+
var CloudServ$1 = new CloudServ();
|
|
17739
|
+
|
|
17740
|
+
var Login = /*#__PURE__*/function () {
|
|
17741
|
+
function Login() {
|
|
17742
|
+
_classCallCheck$1(this, Login);
|
|
17743
|
+
_defineProperty$1(this, "cache", {});
|
|
17744
|
+
_defineProperty$1(this, "refreshtokenTimer", null);
|
|
17745
|
+
}
|
|
17746
|
+
_createClass$1(Login, [{
|
|
17747
|
+
key: "getData",
|
|
17748
|
+
value: function getData(key) {
|
|
17749
|
+
if (this.cache[key]) {
|
|
17750
|
+
return this.cache[key];
|
|
17751
|
+
} else {
|
|
17752
|
+
var data = lsProxy.getItem(key);
|
|
17753
|
+
this.cache[key] = data;
|
|
17754
|
+
return data;
|
|
17755
|
+
}
|
|
17756
|
+
}
|
|
17757
|
+
}, {
|
|
17758
|
+
key: "setData",
|
|
17759
|
+
value: function setData(key, value) {
|
|
17760
|
+
this.cache[key] = value;
|
|
17761
|
+
lsProxy.setItem(key, value);
|
|
17762
|
+
}
|
|
17763
|
+
}, {
|
|
17764
|
+
key: "removeData",
|
|
17765
|
+
value: function removeData(key) {
|
|
17766
|
+
delete this.cache[key];
|
|
17767
|
+
lsProxy.removeItem(key);
|
|
17768
|
+
}
|
|
17769
|
+
}, {
|
|
17770
|
+
key: "getEnvname",
|
|
17754
17771
|
value: function () {
|
|
17755
|
-
var
|
|
17756
|
-
var
|
|
17757
|
-
|
|
17772
|
+
var _getEnvname = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
|
|
17773
|
+
var _context, _window, _window2;
|
|
17774
|
+
var envname, context, contextEnvname, queryEnvname;
|
|
17775
|
+
return _regeneratorRuntime$1().wrap(function _callee$(_context2) {
|
|
17758
17776
|
while (1) switch (_context2.prev = _context2.next) {
|
|
17759
17777
|
case 0:
|
|
17760
|
-
|
|
17761
|
-
|
|
17762
|
-
|
|
17763
|
-
|
|
17778
|
+
envname = ''; // web 查 context 的 envname
|
|
17779
|
+
context = lsProxy.getItem('context');
|
|
17780
|
+
context && (context = JSON.parse(context));
|
|
17781
|
+
contextEnvname = ((_context = context) === null || _context === void 0 ? void 0 : _context.envname) || ''; // 链接有些spu可能会传 envname
|
|
17782
|
+
queryEnvname = this.getQueryEnvname();
|
|
17783
|
+
if (!contextEnvname) {
|
|
17784
|
+
_context2.next = 9;
|
|
17764
17785
|
break;
|
|
17765
17786
|
}
|
|
17766
|
-
|
|
17767
|
-
_context2.
|
|
17768
|
-
_context2.next = 6;
|
|
17769
|
-
return normalAxios.get("".concat(hostsRoot, "/multiplatconfig/env/").concat(envName), {
|
|
17770
|
-
isShowLoading: false,
|
|
17771
|
-
isSendToken: false
|
|
17772
|
-
});
|
|
17773
|
-
case 6:
|
|
17774
|
-
response = _context2.sent;
|
|
17775
|
-
// console.log(response)
|
|
17776
|
-
// debugger
|
|
17777
|
-
result = get$1(response, 'data.0');
|
|
17778
|
-
|
|
17779
|
-
// 如果是非ip地址 则切换为与主页面一样的 location.protocol 前缀
|
|
17780
|
-
((_result = result) === null || _result === void 0 ? void 0 : _result.business) && (result.business = toggleHttpOrHttps(result.business));
|
|
17781
|
-
((_result2 = result) === null || _result2 === void 0 ? void 0 : _result2.smartcenter) && (result.smartcenter = toggleHttpOrHttps(result.smartcenter));
|
|
17782
|
-
_context2.next = 15;
|
|
17787
|
+
envname = contextEnvname;
|
|
17788
|
+
_context2.next = 17;
|
|
17783
17789
|
break;
|
|
17784
|
-
case
|
|
17785
|
-
|
|
17786
|
-
|
|
17787
|
-
console.error(_context2.t0);
|
|
17788
|
-
case 15:
|
|
17789
|
-
return _context2.abrupt("return", result);
|
|
17790
|
-
case 16:
|
|
17791
|
-
case "end":
|
|
17792
|
-
return _context2.stop();
|
|
17793
|
-
}
|
|
17794
|
-
}, _callee2, null, [[3, 12]]);
|
|
17795
|
-
}));
|
|
17796
|
-
function requestEnvData(_x) {
|
|
17797
|
-
return _requestEnvData.apply(this, arguments);
|
|
17798
|
-
}
|
|
17799
|
-
return requestEnvData;
|
|
17800
|
-
}()
|
|
17801
|
-
}, {
|
|
17802
|
-
key: "requestWebDefineData",
|
|
17803
|
-
value: function () {
|
|
17804
|
-
var _requestWebDefineData = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee3() {
|
|
17805
|
-
var _this$cache$envData, _this$cache;
|
|
17806
|
-
var envId, tenantCode, smartcenter, result, _res, res, list, usedList;
|
|
17807
|
-
return _regeneratorRuntime$1().wrap(function _callee3$(_context3) {
|
|
17808
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
17809
|
-
case 0:
|
|
17810
|
-
envId = (_this$cache$envData = this.cache.envData) === null || _this$cache$envData === void 0 ? void 0 : _this$cache$envData.envid;
|
|
17811
|
-
tenantCode = this.cache.tenantCode;
|
|
17812
|
-
smartcenter = (_this$cache = this.cache) === null || _this$cache === void 0 || (_this$cache = _this$cache.envData) === null || _this$cache === void 0 ? void 0 : _this$cache.smartcenter;
|
|
17813
|
-
result = null;
|
|
17814
|
-
if (!(envId && tenantCode && smartcenter)) {
|
|
17815
|
-
_context3.next = 16;
|
|
17790
|
+
case 9:
|
|
17791
|
+
if (!queryEnvname) {
|
|
17792
|
+
_context2.next = 13;
|
|
17816
17793
|
break;
|
|
17817
17794
|
}
|
|
17818
|
-
|
|
17819
|
-
|
|
17820
|
-
return normalAxios.post("".concat(smartcenter, "/api/smartcenter/biz/getTenantWebAndApiDefined"), {
|
|
17821
|
-
envid: envId,
|
|
17822
|
-
tenantcode: tenantCode
|
|
17823
|
-
}, {
|
|
17824
|
-
isShowLoading: false
|
|
17825
|
-
});
|
|
17826
|
-
case 8:
|
|
17827
|
-
res = _context3.sent;
|
|
17828
|
-
_context3.next = 14;
|
|
17795
|
+
envname = queryEnvname;
|
|
17796
|
+
_context2.next = 17;
|
|
17829
17797
|
break;
|
|
17830
|
-
case
|
|
17831
|
-
|
|
17832
|
-
|
|
17833
|
-
|
|
17834
|
-
case 14:
|
|
17835
|
-
// console.log(res)
|
|
17836
|
-
// debugger
|
|
17837
|
-
list = ((_res = res) === null || _res === void 0 || (_res = _res.data) === null || _res === void 0 ? void 0 : _res.list) || [];
|
|
17838
|
-
if (list && list.length) {
|
|
17839
|
-
usedList = list.filter(function (item) {
|
|
17840
|
-
return item.status === 1;
|
|
17841
|
-
});
|
|
17842
|
-
usedList.forEach(function (item) {
|
|
17843
|
-
if (item.protocol) {
|
|
17844
|
-
try {
|
|
17845
|
-
item.protocol = JSON.parse(item.protocol);
|
|
17846
|
-
} catch (err) {
|
|
17847
|
-
console.error(err);
|
|
17848
|
-
}
|
|
17849
|
-
}
|
|
17850
|
-
if (item.apiprotocol) {
|
|
17851
|
-
try {
|
|
17852
|
-
item.apiprotocol = JSON.parse(item.apiprotocol);
|
|
17853
|
-
} catch (err) {
|
|
17854
|
-
console.error(err);
|
|
17855
|
-
}
|
|
17856
|
-
}
|
|
17857
|
-
});
|
|
17858
|
-
result = usedList;
|
|
17798
|
+
case 13:
|
|
17799
|
+
if (!((_window = window) !== null && _window !== void 0 && (_window = _window.aPaaS) !== null && _window !== void 0 && _window.getWebInitParams && (_window2 = window) !== null && _window2 !== void 0 && (_window2 = _window2.Native) !== null && _window2 !== void 0 && _window2.setNavigationBarReturnButton)) {
|
|
17800
|
+
_context2.next = 17;
|
|
17801
|
+
break;
|
|
17859
17802
|
}
|
|
17803
|
+
_context2.next = 16;
|
|
17804
|
+
return new Promise(function (resolve, reject) {
|
|
17805
|
+
window.aPaaS.getWebInitParams(function (params) {
|
|
17806
|
+
resolve((params === null || params === void 0 ? void 0 : params.envname) || '');
|
|
17807
|
+
});
|
|
17808
|
+
});
|
|
17860
17809
|
case 16:
|
|
17861
|
-
|
|
17810
|
+
envname = _context2.sent;
|
|
17862
17811
|
case 17:
|
|
17812
|
+
return _context2.abrupt("return", envname);
|
|
17813
|
+
case 18:
|
|
17863
17814
|
case "end":
|
|
17864
|
-
return
|
|
17815
|
+
return _context2.stop();
|
|
17865
17816
|
}
|
|
17866
|
-
},
|
|
17817
|
+
}, _callee, this);
|
|
17867
17818
|
}));
|
|
17868
|
-
function
|
|
17869
|
-
return
|
|
17819
|
+
function getEnvname() {
|
|
17820
|
+
return _getEnvname.apply(this, arguments);
|
|
17870
17821
|
}
|
|
17871
|
-
return
|
|
17822
|
+
return getEnvname;
|
|
17872
17823
|
}()
|
|
17873
17824
|
}, {
|
|
17874
|
-
key: "
|
|
17875
|
-
value: function () {
|
|
17876
|
-
|
|
17877
|
-
|
|
17878
|
-
|
|
17879
|
-
|
|
17880
|
-
|
|
17881
|
-
|
|
17882
|
-
|
|
17883
|
-
|
|
17884
|
-
|
|
17885
|
-
|
|
17886
|
-
|
|
17887
|
-
|
|
17888
|
-
|
|
17889
|
-
|
|
17890
|
-
|
|
17891
|
-
|
|
17892
|
-
|
|
17893
|
-
|
|
17894
|
-
|
|
17895
|
-
|
|
17896
|
-
|
|
17897
|
-
|
|
17898
|
-
|
|
17899
|
-
|
|
17900
|
-
|
|
17901
|
-
|
|
17902
|
-
|
|
17903
|
-
|
|
17904
|
-
|
|
17905
|
-
|
|
17906
|
-
|
|
17907
|
-
|
|
17908
|
-
|
|
17909
|
-
|
|
17910
|
-
|
|
17911
|
-
|
|
17912
|
-
|
|
17825
|
+
key: "setQueryEnvname",
|
|
17826
|
+
value: function setQueryEnvname(value) {
|
|
17827
|
+
this.setData('envname', value);
|
|
17828
|
+
}
|
|
17829
|
+
}, {
|
|
17830
|
+
key: "getQueryEnvname",
|
|
17831
|
+
value: function getQueryEnvname() {
|
|
17832
|
+
return this.getData('envname') || '';
|
|
17833
|
+
}
|
|
17834
|
+
}, {
|
|
17835
|
+
key: "removeQueryEnvname",
|
|
17836
|
+
value: function removeQueryEnvname() {
|
|
17837
|
+
this.removeData('envname');
|
|
17838
|
+
}
|
|
17839
|
+
}, {
|
|
17840
|
+
key: "getToken",
|
|
17841
|
+
value: function getToken() {
|
|
17842
|
+
return this.getData('token');
|
|
17843
|
+
// return lsProxy.getItem('token') as string
|
|
17844
|
+
}
|
|
17845
|
+
}, {
|
|
17846
|
+
key: "setToken",
|
|
17847
|
+
value: function setToken(value) {
|
|
17848
|
+
this.setData('token', value);
|
|
17849
|
+
}
|
|
17850
|
+
}, {
|
|
17851
|
+
key: "removeToken",
|
|
17852
|
+
value: function removeToken() {
|
|
17853
|
+
this.removeData('token');
|
|
17854
|
+
}
|
|
17855
|
+
}, {
|
|
17856
|
+
key: "getTokenExpires",
|
|
17857
|
+
value: function getTokenExpires() {
|
|
17858
|
+
return this.getData('tokenexpires');
|
|
17859
|
+
}
|
|
17860
|
+
}, {
|
|
17861
|
+
key: "setTokenExpires",
|
|
17862
|
+
value: function setTokenExpires(value) {
|
|
17863
|
+
this.setData('tokenexpires', value);
|
|
17864
|
+
}
|
|
17865
|
+
}, {
|
|
17866
|
+
key: "removeTokenExpires",
|
|
17867
|
+
value: function removeTokenExpires() {
|
|
17868
|
+
this.removeData('tokenexpires');
|
|
17869
|
+
}
|
|
17870
|
+
}, {
|
|
17871
|
+
key: "getRefreshToken",
|
|
17872
|
+
value: function getRefreshToken() {
|
|
17873
|
+
return this.getData('refreshtoken');
|
|
17874
|
+
// return lsProxy.getItem('refreshtoken') as string
|
|
17875
|
+
}
|
|
17876
|
+
}, {
|
|
17877
|
+
key: "setRefreshToken",
|
|
17878
|
+
value: function setRefreshToken(value) {
|
|
17879
|
+
this.setData('refreshtoken', value);
|
|
17880
|
+
}
|
|
17881
|
+
}, {
|
|
17882
|
+
key: "removeRefreshToken",
|
|
17883
|
+
value: function removeRefreshToken() {
|
|
17884
|
+
this.removeData('refreshtoken');
|
|
17885
|
+
}
|
|
17886
|
+
}, {
|
|
17887
|
+
key: "updateToken",
|
|
17888
|
+
value: function updateToken() {
|
|
17889
|
+
var _this = this;
|
|
17890
|
+
// 如果是产品运营中心 则不走刷新token流程
|
|
17891
|
+
if (this.checkLogin() && this.getRole() === 'center') {
|
|
17892
|
+
console.warn('当前登录为产品运营中心用户,不支持自动刷新token。');
|
|
17893
|
+
return false;
|
|
17913
17894
|
}
|
|
17914
|
-
|
|
17915
|
-
|
|
17895
|
+
var token = this.getToken();
|
|
17896
|
+
var refreshtoken = this.getRefreshToken();
|
|
17897
|
+
var sendToken = this.checkLoginByToken(token) ? token : refreshtoken;
|
|
17898
|
+
return normalAxios.get('/api/auth/refreshtoken', {
|
|
17899
|
+
params: {
|
|
17900
|
+
refreshtoken: sendToken
|
|
17901
|
+
},
|
|
17902
|
+
isShowLoadding: false,
|
|
17903
|
+
isShowErrorMessage: false,
|
|
17904
|
+
isSendToken: false,
|
|
17905
|
+
headers: {
|
|
17906
|
+
token: sendToken
|
|
17907
|
+
}
|
|
17908
|
+
}).then(function (res) {
|
|
17909
|
+
// console.log(res)
|
|
17910
|
+
var data = res === null || res === void 0 ? void 0 : res.data;
|
|
17911
|
+
if (data) {
|
|
17912
|
+
_this.setToken(data.token);
|
|
17913
|
+
_this.setRefreshToken(data.refreshtoken);
|
|
17914
|
+
_this.setTokenExpires(data.tokenexpires);
|
|
17915
|
+
}
|
|
17916
|
+
});
|
|
17917
|
+
}
|
|
17916
17918
|
}, {
|
|
17917
|
-
key: "
|
|
17918
|
-
value: function () {
|
|
17919
|
-
var
|
|
17920
|
-
|
|
17921
|
-
|
|
17922
|
-
|
|
17923
|
-
|
|
17924
|
-
|
|
17925
|
-
|
|
17926
|
-
|
|
17927
|
-
|
|
17928
|
-
|
|
17929
|
-
|
|
17930
|
-
|
|
17931
|
-
|
|
17932
|
-
|
|
17933
|
-
|
|
17934
|
-
|
|
17935
|
-
|
|
17936
|
-
|
|
17937
|
-
|
|
17938
|
-
|
|
17939
|
-
return _context5.abrupt("return", res);
|
|
17940
|
-
case 6:
|
|
17941
|
-
case "end":
|
|
17942
|
-
return _context5.stop();
|
|
17919
|
+
key: "startRefreshtoken",
|
|
17920
|
+
value: function startRefreshtoken() {
|
|
17921
|
+
var _this2 = this;
|
|
17922
|
+
// 如果是产品运营中心 则不走刷新token流程
|
|
17923
|
+
if (this.checkLogin() && this.getRole() === 'center') {
|
|
17924
|
+
console.warn('当前登录为产品运营中心用户,不支持自动刷新token。');
|
|
17925
|
+
return false;
|
|
17926
|
+
}
|
|
17927
|
+
this.stopRefreshtoken();
|
|
17928
|
+
// 如果有登录 但 refreshtoken 不是完整 token 则10秒后【需要等单点登录走完后才刷新不然会被覆盖】刷新一次取到完整 token
|
|
17929
|
+
// 如果有登录 且 refreshtoken 是完整 token 如果剩余时间大于10分钟 则每隔10分钟刷一次 否则过期前15秒更新 token
|
|
17930
|
+
// 如果没登录 每隔1分钟走token更新逻辑(如果刚开始没登录 后面才登录【不需要再在登陆后写刷新token逻辑】)
|
|
17931
|
+
var time = 0;
|
|
17932
|
+
if (this.checkLogin()) {
|
|
17933
|
+
var user = this.getUserByToken(this.getRefreshToken());
|
|
17934
|
+
if (user !== null && user !== void 0 && user.tokenId) {
|
|
17935
|
+
time = Number(this.getTokenExpires()) - Date.now() - 1000 * 15;
|
|
17936
|
+
// 如果剩余时间大于10分钟 则每隔10分钟刷一次
|
|
17937
|
+
if (time > 600000) {
|
|
17938
|
+
time = 600000;
|
|
17939
|
+
} else if (time < 0) {
|
|
17940
|
+
time = 0;
|
|
17943
17941
|
}
|
|
17944
|
-
}
|
|
17945
|
-
|
|
17946
|
-
|
|
17947
|
-
|
|
17942
|
+
} else {
|
|
17943
|
+
time = 10000;
|
|
17944
|
+
}
|
|
17945
|
+
} else {
|
|
17946
|
+
time = 60000;
|
|
17948
17947
|
}
|
|
17949
|
-
|
|
17950
|
-
|
|
17951
|
-
|
|
17952
|
-
|
|
17953
|
-
value: function () {
|
|
17954
|
-
var _getEnvBusiness = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee6() {
|
|
17955
|
-
var business, envData;
|
|
17956
|
-
return _regeneratorRuntime$1().wrap(function _callee6$(_context6) {
|
|
17957
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
17948
|
+
// time = 5000
|
|
17949
|
+
this.refreshtokenTimer = window.setTimeout( /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee2() {
|
|
17950
|
+
return _regeneratorRuntime$1().wrap(function _callee2$(_context3) {
|
|
17951
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
17958
17952
|
case 0:
|
|
17959
|
-
|
|
17960
|
-
|
|
17961
|
-
|
|
17962
|
-
case 3:
|
|
17963
|
-
envData = _context6.sent;
|
|
17964
|
-
if (envData.data) {
|
|
17965
|
-
business = envData.data.business;
|
|
17953
|
+
if (!_this2.checkLogin()) {
|
|
17954
|
+
_context3.next = 3;
|
|
17955
|
+
break;
|
|
17966
17956
|
}
|
|
17967
|
-
|
|
17968
|
-
|
|
17957
|
+
_context3.next = 3;
|
|
17958
|
+
return _this2.updateToken();
|
|
17959
|
+
case 3:
|
|
17960
|
+
_this2.startRefreshtoken();
|
|
17961
|
+
case 4:
|
|
17969
17962
|
case "end":
|
|
17970
|
-
return
|
|
17963
|
+
return _context3.stop();
|
|
17971
17964
|
}
|
|
17972
|
-
},
|
|
17973
|
-
}));
|
|
17974
|
-
|
|
17975
|
-
|
|
17965
|
+
}, _callee2);
|
|
17966
|
+
})), time);
|
|
17967
|
+
}
|
|
17968
|
+
}, {
|
|
17969
|
+
key: "stopRefreshtoken",
|
|
17970
|
+
value: function stopRefreshtoken() {
|
|
17971
|
+
clearTimeout(this.refreshtokenTimer);
|
|
17972
|
+
this.refreshtokenTimer = null;
|
|
17973
|
+
}
|
|
17974
|
+
}, {
|
|
17975
|
+
key: "getUser",
|
|
17976
|
+
value: function getUser(key) {
|
|
17977
|
+
var user = this.getData('user');
|
|
17978
|
+
var userObj = user ? JSON.parse(user) : null;
|
|
17979
|
+
if (!key) {
|
|
17980
|
+
return userObj;
|
|
17981
|
+
} else {
|
|
17982
|
+
return userObj ? userObj[key] || '' : '';
|
|
17976
17983
|
}
|
|
17977
|
-
|
|
17978
|
-
}()
|
|
17984
|
+
}
|
|
17979
17985
|
}, {
|
|
17980
|
-
key: "
|
|
17981
|
-
value: function () {
|
|
17982
|
-
var
|
|
17983
|
-
|
|
17984
|
-
|
|
17985
|
-
|
|
17986
|
-
|
|
17987
|
-
|
|
17988
|
-
|
|
17989
|
-
|
|
17990
|
-
|
|
17991
|
-
|
|
17992
|
-
|
|
17993
|
-
|
|
17994
|
-
|
|
17995
|
-
|
|
17996
|
-
|
|
17997
|
-
|
|
17998
|
-
|
|
17999
|
-
|
|
18000
|
-
|
|
18001
|
-
|
|
18002
|
-
|
|
18003
|
-
|
|
18004
|
-
|
|
18005
|
-
|
|
18006
|
-
|
|
18007
|
-
|
|
18008
|
-
|
|
18009
|
-
|
|
18010
|
-
|
|
18011
|
-
|
|
18012
|
-
|
|
18013
|
-
|
|
18014
|
-
|
|
18015
|
-
|
|
18016
|
-
|
|
18017
|
-
|
|
18018
|
-
|
|
18019
|
-
|
|
17986
|
+
key: "setUser",
|
|
17987
|
+
value: function setUser(value) {
|
|
17988
|
+
var res;
|
|
17989
|
+
if (typeof value === 'string') {
|
|
17990
|
+
res = JSON.parse(value);
|
|
17991
|
+
} else {
|
|
17992
|
+
res = cloneDeep$1(value);
|
|
17993
|
+
}
|
|
17994
|
+
for (var x in res) {
|
|
17995
|
+
res[x.toLowerCase()] = res[x];
|
|
17996
|
+
}
|
|
17997
|
+
this.setData('user', JSON.stringify(res));
|
|
17998
|
+
}
|
|
17999
|
+
}, {
|
|
18000
|
+
key: "setUserByToken",
|
|
18001
|
+
value: function setUserByToken(token) {
|
|
18002
|
+
var user = this.getUserByToken(token);
|
|
18003
|
+
if (user) {
|
|
18004
|
+
this.setUser(user);
|
|
18005
|
+
} else {
|
|
18006
|
+
this.removeUser();
|
|
18007
|
+
}
|
|
18008
|
+
}
|
|
18009
|
+
}, {
|
|
18010
|
+
key: "getUserByToken",
|
|
18011
|
+
value: function getUserByToken(token) {
|
|
18012
|
+
var jwtInfo = this.jwtDecode(token);
|
|
18013
|
+
if (jwtInfo && jwtInfo.LoginUser) {
|
|
18014
|
+
return jwtInfo.LoginUser;
|
|
18015
|
+
} else {
|
|
18016
|
+
return null;
|
|
18017
|
+
}
|
|
18018
|
+
}
|
|
18019
|
+
}, {
|
|
18020
|
+
key: "removeUser",
|
|
18021
|
+
value: function removeUser() {
|
|
18022
|
+
this.removeData('user');
|
|
18023
|
+
}
|
|
18024
|
+
}, {
|
|
18025
|
+
key: "jwtDecode",
|
|
18026
|
+
value: function jwtDecode(token) {
|
|
18027
|
+
if (!token) {
|
|
18028
|
+
console.error('token为空 jwt解析token出错');
|
|
18029
|
+
return null;
|
|
18030
|
+
}
|
|
18031
|
+
try {
|
|
18032
|
+
return o(token);
|
|
18033
|
+
} catch (e) {
|
|
18034
|
+
console.error('jwt解析token出错', token, e);
|
|
18035
|
+
return null;
|
|
18036
|
+
}
|
|
18037
|
+
}
|
|
18038
|
+
// // 产品运营中心token
|
|
18039
|
+
// {
|
|
18040
|
+
// "LoginUser": {
|
|
18041
|
+
// "appId": "100",
|
|
18042
|
+
// "tenantCode": "1656652",
|
|
18043
|
+
// "productCode": "100000000000000000",
|
|
18044
|
+
// "productVersionCode": null,
|
|
18045
|
+
// "clientTypeCode": null,
|
|
18046
|
+
// "userCode": "6",
|
|
18047
|
+
// "accountCode": "6",
|
|
18048
|
+
// "username": "庄焕滨",
|
|
18049
|
+
// "tokenId": "bd69b4a4-5376-47cd-91c3-f1e1576440e5",
|
|
18050
|
+
// "appCodes": null,
|
|
18051
|
+
// "appCode": null,
|
|
18052
|
+
// "platRoleCodes": ["1637696814759153664"],
|
|
18053
|
+
// "metamodeltype": 2,
|
|
18054
|
+
// "orgCode": "1751852081616130048",
|
|
18055
|
+
// "centerRole": true
|
|
18056
|
+
// },
|
|
18057
|
+
// "TwoFactorAuthCode": "6f56da978dffe31a3b03a56c446f9467",
|
|
18058
|
+
// "exp": 1751694745
|
|
18059
|
+
// }
|
|
18060
|
+
// // 租户token
|
|
18061
|
+
// {
|
|
18062
|
+
// "exp": 1720161305,
|
|
18063
|
+
// "LoginUser": {
|
|
18064
|
+
// "accountInfoCode": "1803686723986010112",
|
|
18065
|
+
// "accountCode": "1803686724107644928",
|
|
18066
|
+
// "tenantCode": "3000911",
|
|
18067
|
+
// "productCode": "100000000000000000",
|
|
18068
|
+
// "productVersionCode": "30000000000000911",
|
|
18069
|
+
// "clientTypeCode": 1,
|
|
18070
|
+
// "tokenId": "8614059e-69a5-4e1e-a948-f2ef680d0dd5",
|
|
18071
|
+
// "orgCode": "1803686397149065216",
|
|
18072
|
+
// "userInfoId": "1806591894588108800",
|
|
18073
|
+
// "userInfoName": "woOUQJEAAAn4r5-7jffaxad6yotbEZ5A",
|
|
18074
|
+
// "positionCode": "1803686397304254473",
|
|
18075
|
+
// "positionName": "系统管理员-勿删",
|
|
18076
|
+
// "memberCode": "1806591894659411968",
|
|
18077
|
+
// "refPositionCode": "1300728614534385664",
|
|
18078
|
+
// "categoryCode": "",
|
|
18079
|
+
// "orgStructTypeId": "1",
|
|
18080
|
+
// "userName": null,
|
|
18081
|
+
// "userName1": "woOUQJEAAAn4r5-7jffaxad6yotbEZ5A",
|
|
18082
|
+
// "userName2": null,
|
|
18083
|
+
// "userName3": null,
|
|
18084
|
+
// "tenantName": "智慧100-企微版-V9.1.1开发租户",
|
|
18085
|
+
// "appCode": "sales",
|
|
18086
|
+
// "appCodes": [
|
|
18087
|
+
// "promotion",
|
|
18088
|
+
// "distribution",
|
|
18089
|
+
// "sales"
|
|
18090
|
+
// ],
|
|
18091
|
+
// "subPdCodes": [
|
|
18092
|
+
// "sfa",
|
|
18093
|
+
// "dms",
|
|
18094
|
+
// "pmm",
|
|
18095
|
+
// "tpm",
|
|
18096
|
+
// "ai"
|
|
18097
|
+
// ],
|
|
18098
|
+
// "codepath": "1.1803686395634921472.1803686397149065216.",
|
|
18099
|
+
// "isleaforg": "true",
|
|
18100
|
+
// "metamodeltype": 1,
|
|
18101
|
+
// "isSmsLogin": false
|
|
18102
|
+
// }
|
|
18103
|
+
// }
|
|
18104
|
+
// 查询token所属登录角色
|
|
18105
|
+
// tenant: 普通租户登录 默认
|
|
18106
|
+
// center: 产品运营中心登录 单点登录时只带 token 没带 refreshtoken 和 tokenexpires
|
|
18107
|
+
}, {
|
|
18108
|
+
key: "getRoleByToken",
|
|
18109
|
+
value: function getRoleByToken(token) {
|
|
18110
|
+
var loginRole = 'tenant'; // center | tenant
|
|
18111
|
+
if (token) {
|
|
18112
|
+
var _jwtInfo$LoginUser, _jwtInfo$LoginUser2;
|
|
18113
|
+
var jwtInfo = this.jwtDecode(token);
|
|
18114
|
+
if (jwtInfo !== null && jwtInfo !== void 0 && (_jwtInfo$LoginUser = jwtInfo.LoginUser) !== null && _jwtInfo$LoginUser !== void 0 && _jwtInfo$LoginUser.centerRole || (jwtInfo === null || jwtInfo === void 0 || (_jwtInfo$LoginUser2 = jwtInfo.LoginUser) === null || _jwtInfo$LoginUser2 === void 0 ? void 0 : _jwtInfo$LoginUser2.appId) === '100') {
|
|
18115
|
+
// 产品运营中心登录
|
|
18116
|
+
loginRole = 'center';
|
|
18117
|
+
}
|
|
18118
|
+
}
|
|
18119
|
+
return loginRole;
|
|
18120
|
+
}
|
|
18121
|
+
}, {
|
|
18122
|
+
key: "getRole",
|
|
18123
|
+
value: function getRole() {
|
|
18124
|
+
return this.getRoleByToken(this.getToken());
|
|
18125
|
+
}
|
|
18126
|
+
// 检测当前用户是否登录状态
|
|
18127
|
+
}, {
|
|
18128
|
+
key: "checkLogin",
|
|
18129
|
+
value: function checkLogin() {
|
|
18130
|
+
var haslogged = false;
|
|
18131
|
+
var token = this.getToken();
|
|
18132
|
+
if (token) {
|
|
18133
|
+
if (this.getRole() === 'center') {
|
|
18134
|
+
haslogged = this.checkLoginByToken(token);
|
|
18135
|
+
} else {
|
|
18136
|
+
var refreshtoken = this.getRefreshToken();
|
|
18137
|
+
var tokenexpires = this.getTokenExpires();
|
|
18138
|
+
var now = Date.now();
|
|
18139
|
+
if (token && refreshtoken && tokenexpires && Number(tokenexpires) > now) {
|
|
18140
|
+
haslogged = this.checkLoginByToken(token);
|
|
18020
18141
|
}
|
|
18021
|
-
}
|
|
18022
|
-
}));
|
|
18023
|
-
function getModuleData(_x2) {
|
|
18024
|
-
return _getModuleData.apply(this, arguments);
|
|
18142
|
+
}
|
|
18025
18143
|
}
|
|
18026
|
-
return
|
|
18027
|
-
}
|
|
18144
|
+
return haslogged;
|
|
18145
|
+
}
|
|
18146
|
+
// 检测token是否过期
|
|
18028
18147
|
}, {
|
|
18029
|
-
key: "
|
|
18148
|
+
key: "checkLoginByToken",
|
|
18149
|
+
value: function checkLoginByToken(token) {
|
|
18150
|
+
var haslogged = false;
|
|
18151
|
+
if (token) {
|
|
18152
|
+
var now = Date.now();
|
|
18153
|
+
var jwtInfo = this.jwtDecode(token);
|
|
18154
|
+
if (jwtInfo !== null && jwtInfo !== void 0 && jwtInfo.exp) {
|
|
18155
|
+
haslogged = Number(jwtInfo.exp + '000') > now;
|
|
18156
|
+
} else {
|
|
18157
|
+
haslogged = false;
|
|
18158
|
+
}
|
|
18159
|
+
}
|
|
18160
|
+
return haslogged;
|
|
18161
|
+
}
|
|
18162
|
+
// 接口请求回来的 userInfo 有 functioncodes 以便做权限校验
|
|
18163
|
+
// 有可能是中心角色请求失败 兼容不报错
|
|
18164
|
+
}, {
|
|
18165
|
+
key: "getAndSetUserInfo",
|
|
18030
18166
|
value: function () {
|
|
18031
|
-
var
|
|
18032
|
-
var
|
|
18033
|
-
return _regeneratorRuntime$1().wrap(function
|
|
18034
|
-
while (1) switch (
|
|
18167
|
+
var _getAndSetUserInfo = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee3() {
|
|
18168
|
+
var accountinfo;
|
|
18169
|
+
return _regeneratorRuntime$1().wrap(function _callee3$(_context4) {
|
|
18170
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
18035
18171
|
case 0:
|
|
18036
|
-
|
|
18037
|
-
|
|
18038
|
-
|
|
18039
|
-
|
|
18040
|
-
|
|
18172
|
+
_context4.prev = 0;
|
|
18173
|
+
_context4.next = 3;
|
|
18174
|
+
return normalAxios.post('/api/teapi/rolepermission/account/getaccountinfo', {
|
|
18175
|
+
positionid: this.getUser('positioncode') || '',
|
|
18176
|
+
deviceinfo: '',
|
|
18177
|
+
sysversion: '',
|
|
18178
|
+
clientversion: ''
|
|
18179
|
+
}).then(function (res) {
|
|
18180
|
+
if (res.code === 200 && res.data) {
|
|
18181
|
+
return res.data;
|
|
18182
|
+
} else {
|
|
18183
|
+
return null;
|
|
18184
|
+
}
|
|
18185
|
+
});
|
|
18041
18186
|
case 3:
|
|
18042
|
-
|
|
18043
|
-
if (
|
|
18044
|
-
|
|
18045
|
-
envid: moduleData.envid || '',
|
|
18046
|
-
envname: this.cache.envName || '',
|
|
18047
|
-
tenantcode: moduleData.tenantcode || '',
|
|
18048
|
-
modulecode: moduleData.modulecode || '',
|
|
18049
|
-
modulekey: moduleData.modulekey || '',
|
|
18050
|
-
modulename: moduleData.modulename || '',
|
|
18051
|
-
moduleversion: moduleData.moduleversion || '',
|
|
18052
|
-
versioncode: moduleData.versioncode || '',
|
|
18053
|
-
versionnum: moduleData.moduleversion || ''
|
|
18054
|
-
};
|
|
18187
|
+
accountinfo = _context4.sent;
|
|
18188
|
+
if (accountinfo) {
|
|
18189
|
+
this.setUser(accountinfo);
|
|
18055
18190
|
}
|
|
18056
|
-
|
|
18057
|
-
|
|
18191
|
+
_context4.next = 11;
|
|
18192
|
+
break;
|
|
18193
|
+
case 7:
|
|
18194
|
+
_context4.prev = 7;
|
|
18195
|
+
_context4.t0 = _context4["catch"](0);
|
|
18196
|
+
console.error(_context4.t0);
|
|
18197
|
+
console.warn('获取用户信息失败,当前您登录的帐号可能为非标准租户帐号。');
|
|
18198
|
+
case 11:
|
|
18058
18199
|
case "end":
|
|
18059
|
-
return
|
|
18200
|
+
return _context4.stop();
|
|
18060
18201
|
}
|
|
18061
|
-
},
|
|
18202
|
+
}, _callee3, this, [[0, 7]]);
|
|
18062
18203
|
}));
|
|
18063
|
-
function
|
|
18064
|
-
return
|
|
18204
|
+
function getAndSetUserInfo() {
|
|
18205
|
+
return _getAndSetUserInfo.apply(this, arguments);
|
|
18065
18206
|
}
|
|
18066
|
-
return
|
|
18207
|
+
return getAndSetUserInfo;
|
|
18067
18208
|
}()
|
|
18068
18209
|
}, {
|
|
18069
|
-
key: "
|
|
18210
|
+
key: "formatTenant",
|
|
18211
|
+
value: function formatTenant(tenant) {
|
|
18212
|
+
if (!tenant) {
|
|
18213
|
+
return null;
|
|
18214
|
+
}
|
|
18215
|
+
var cloundTagMap = ['storage', 'storage-1d', 'storage-1y', 'storage-3m'];
|
|
18216
|
+
var result = {};
|
|
18217
|
+
for (var _i = 0, _cloundTagMap = cloundTagMap; _i < _cloundTagMap.length; _i++) {
|
|
18218
|
+
var keyItem = _cloundTagMap[_i];
|
|
18219
|
+
var _cloudServ = tenant.cloudserv[keyItem];
|
|
18220
|
+
if (_cloudServ) {
|
|
18221
|
+
result[keyItem] = {
|
|
18222
|
+
cloudserv_storage_provider: _cloudServ.provider,
|
|
18223
|
+
cloudserv_storage_storagebucket: _cloudServ.storagebucket,
|
|
18224
|
+
cloudserv_storage_storageendpoint: _cloudServ.storageendpoint,
|
|
18225
|
+
cloudserv_storage_storageurl: _cloudServ.storageurl,
|
|
18226
|
+
cloudserv_storage_accesskeyid: _cloudServ.accesskeyid,
|
|
18227
|
+
cloudserv_storage_region: _cloudServ.region
|
|
18228
|
+
};
|
|
18229
|
+
}
|
|
18230
|
+
}
|
|
18231
|
+
if (Object.keys(result).length === 0) {
|
|
18232
|
+
return null;
|
|
18233
|
+
}
|
|
18234
|
+
return result;
|
|
18235
|
+
}
|
|
18236
|
+
}, {
|
|
18237
|
+
key: "getAndSetTenant",
|
|
18070
18238
|
value: function () {
|
|
18071
|
-
var
|
|
18072
|
-
var
|
|
18073
|
-
return _regeneratorRuntime$1().wrap(function
|
|
18074
|
-
while (1) switch (
|
|
18239
|
+
var _getAndSetTenant = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee4(tenantcode) {
|
|
18240
|
+
var tenantsRes, tenant, normalizedTenant;
|
|
18241
|
+
return _regeneratorRuntime$1().wrap(function _callee4$(_context5) {
|
|
18242
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
18075
18243
|
case 0:
|
|
18076
|
-
|
|
18077
|
-
|
|
18078
|
-
return
|
|
18244
|
+
_context5.prev = 0;
|
|
18245
|
+
_context5.next = 3;
|
|
18246
|
+
return normalAxios.get('/api/auth/tenantlist', {}).then(function (res) {
|
|
18247
|
+
var _res$data;
|
|
18248
|
+
return res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.tenants;
|
|
18249
|
+
});
|
|
18079
18250
|
case 3:
|
|
18080
|
-
|
|
18081
|
-
|
|
18082
|
-
|
|
18083
|
-
|
|
18251
|
+
tenantsRes = _context5.sent;
|
|
18252
|
+
tenant = null;
|
|
18253
|
+
if (tenantsRes !== null && tenantsRes !== void 0 && tenantsRes.length) {
|
|
18254
|
+
if (!tenantcode) {
|
|
18255
|
+
tenant = tenantsRes[0];
|
|
18256
|
+
} else {
|
|
18257
|
+
tenant = tenantsRes.find(function (item) {
|
|
18258
|
+
return item.code === tenantcode;
|
|
18259
|
+
}) || null;
|
|
18260
|
+
}
|
|
18084
18261
|
}
|
|
18085
|
-
|
|
18086
|
-
|
|
18087
|
-
|
|
18088
|
-
|
|
18089
|
-
|
|
18262
|
+
if (!tenant) {
|
|
18263
|
+
lsProxy.removeItem('tenant');
|
|
18264
|
+
CloudServ$1.remove();
|
|
18265
|
+
} else {
|
|
18266
|
+
lsProxy.setItem('tenant', JSON.stringify(tenant));
|
|
18267
|
+
normalizedTenant = this.formatTenant(tenant);
|
|
18268
|
+
if (normalizedTenant) {
|
|
18269
|
+
CloudServ$1.set(normalizedTenant);
|
|
18270
|
+
}
|
|
18271
|
+
}
|
|
18272
|
+
_context5.next = 13;
|
|
18273
|
+
break;
|
|
18090
18274
|
case 9:
|
|
18091
|
-
|
|
18092
|
-
|
|
18275
|
+
_context5.prev = 9;
|
|
18276
|
+
_context5.t0 = _context5["catch"](0);
|
|
18277
|
+
console.error(_context5.t0);
|
|
18278
|
+
console.warn('获取租户信息失败,当前您登录的帐号可能为非标准租户帐号。');
|
|
18279
|
+
case 13:
|
|
18093
18280
|
case "end":
|
|
18094
|
-
return
|
|
18281
|
+
return _context5.stop();
|
|
18095
18282
|
}
|
|
18096
|
-
},
|
|
18283
|
+
}, _callee4, this, [[0, 9]]);
|
|
18097
18284
|
}));
|
|
18098
|
-
function
|
|
18099
|
-
return
|
|
18285
|
+
function getAndSetTenant(_x) {
|
|
18286
|
+
return _getAndSetTenant.apply(this, arguments);
|
|
18100
18287
|
}
|
|
18101
|
-
return
|
|
18102
|
-
}()
|
|
18288
|
+
return getAndSetTenant;
|
|
18289
|
+
}() // 单点登录
|
|
18103
18290
|
}, {
|
|
18104
|
-
key: "
|
|
18291
|
+
key: "singleLogin",
|
|
18105
18292
|
value: function () {
|
|
18106
|
-
var
|
|
18107
|
-
var
|
|
18108
|
-
return _regeneratorRuntime$1().wrap(function
|
|
18109
|
-
while (1) switch (
|
|
18293
|
+
var _singleLogin = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee5(query) {
|
|
18294
|
+
var flag, token, refreshtoken, tokenexpires, envname, context, isneedlogin, loginRole, user;
|
|
18295
|
+
return _regeneratorRuntime$1().wrap(function _callee5$(_context6) {
|
|
18296
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
18110
18297
|
case 0:
|
|
18111
|
-
|
|
18112
|
-
|
|
18298
|
+
query = cloneDeep$1(query);
|
|
18299
|
+
flag = false; // 是否登录成功
|
|
18300
|
+
token = query.token;
|
|
18301
|
+
refreshtoken = query.refreshtoken;
|
|
18302
|
+
tokenexpires = query.tokenexpires;
|
|
18303
|
+
envname = query.envname;
|
|
18304
|
+
context = query.context;
|
|
18305
|
+
if (!this.checkLoginByToken(token)) {
|
|
18306
|
+
_context6.next = 26;
|
|
18307
|
+
break;
|
|
18113
18308
|
}
|
|
18114
|
-
|
|
18115
|
-
|
|
18116
|
-
|
|
18117
|
-
|
|
18118
|
-
|
|
18119
|
-
|
|
18309
|
+
isneedlogin = true; // 是否需要走单点登录流程
|
|
18310
|
+
loginRole = this.getRoleByToken(token);
|
|
18311
|
+
if (loginRole === 'center') {
|
|
18312
|
+
// 如果本地已经登录 且 query 登录参数与本地一致 说明是刚登录没多久【token也没刷新过】 视为已经登录 不需再走单点登录流程
|
|
18313
|
+
// 之所以不强制校验 refreshtoken tokenexpires 是因为安装卸载配置页面有可能放在产品运营中心 没有这两字段
|
|
18314
|
+
if (this.checkLogin() && token === this.getToken()) {
|
|
18315
|
+
isneedlogin = false;
|
|
18316
|
+
flag = true;
|
|
18317
|
+
}
|
|
18318
|
+
} else {
|
|
18319
|
+
// 如果本地已经登录 且 query 登录参数与本地一致 说明是刚登录没多久【token也没刷新过】 视为已经登录 不需再走单点登录流程
|
|
18320
|
+
if (this.checkLogin() && token === this.getToken() && refreshtoken === this.getRefreshToken() && tokenexpires === this.getTokenExpires()) {
|
|
18321
|
+
isneedlogin = false;
|
|
18322
|
+
flag = true;
|
|
18323
|
+
}
|
|
18324
|
+
}
|
|
18325
|
+
if (!isneedlogin) {
|
|
18326
|
+
_context6.next = 24;
|
|
18327
|
+
break;
|
|
18328
|
+
}
|
|
18329
|
+
this.setToken(token);
|
|
18330
|
+
this.setUserByToken(token); // 解析token为用户信息存入
|
|
18331
|
+
refreshtoken ? this.setRefreshToken(refreshtoken) : this.removeRefreshToken();
|
|
18332
|
+
tokenexpires ? this.setTokenExpires(tokenexpires) : this.removeTokenExpires();
|
|
18333
|
+
envname ? this.setQueryEnvname(envname) : this.removeQueryEnvname();
|
|
18334
|
+
// context 上下文字段 产品运营中心安装 卸载 配置 和 产品配置中心业务配置 页面需要用到
|
|
18335
|
+
// web 端有传 app没传 需要做兼容
|
|
18336
|
+
context && lsProxy.setItem('context', decodeURIComponent(context));
|
|
18337
|
+
// 单点登录写入 token 之后 换取完整的 refreshtoken
|
|
18338
|
+
try {
|
|
18339
|
+
if (this.checkLogin()) {
|
|
18340
|
+
user = this.getUserByToken(this.getRefreshToken());
|
|
18341
|
+
if (!(user !== null && user !== void 0 && user.tokenId)) {
|
|
18342
|
+
this.updateToken();
|
|
18343
|
+
}
|
|
18344
|
+
}
|
|
18345
|
+
} catch (err) {
|
|
18346
|
+
console.error(err);
|
|
18347
|
+
}
|
|
18348
|
+
// 这里兼容报错
|
|
18349
|
+
_context6.next = 21;
|
|
18350
|
+
return this.getAndSetTenant();
|
|
18351
|
+
case 21:
|
|
18352
|
+
_context6.next = 23;
|
|
18353
|
+
return this.getAndSetUserInfo();
|
|
18354
|
+
case 23:
|
|
18355
|
+
flag = true;
|
|
18356
|
+
case 24:
|
|
18357
|
+
_context6.next = 28;
|
|
18358
|
+
break;
|
|
18359
|
+
case 26:
|
|
18360
|
+
flag = false;
|
|
18361
|
+
console.error('没传 token 或所传 token 已过期,无法单点登录。');
|
|
18362
|
+
case 28:
|
|
18363
|
+
// 单点登录后 无论是否成功 都需要删除 query 中相关参数
|
|
18364
|
+
token && delete query.token;
|
|
18365
|
+
refreshtoken && delete query.refreshtoken;
|
|
18366
|
+
tokenexpires && delete query.tokenexpires;
|
|
18367
|
+
envname && delete query.envname;
|
|
18368
|
+
context && delete query.context;
|
|
18369
|
+
// debugger
|
|
18370
|
+
return _context6.abrupt("return", {
|
|
18371
|
+
flag: flag,
|
|
18372
|
+
query: query
|
|
18373
|
+
});
|
|
18374
|
+
case 34:
|
|
18120
18375
|
case "end":
|
|
18121
|
-
return
|
|
18376
|
+
return _context6.stop();
|
|
18122
18377
|
}
|
|
18123
|
-
},
|
|
18378
|
+
}, _callee5, this);
|
|
18124
18379
|
}));
|
|
18125
|
-
function
|
|
18126
|
-
return
|
|
18380
|
+
function singleLogin(_x2) {
|
|
18381
|
+
return _singleLogin.apply(this, arguments);
|
|
18127
18382
|
}
|
|
18128
|
-
return
|
|
18383
|
+
return singleLogin;
|
|
18129
18384
|
}()
|
|
18130
18385
|
}]);
|
|
18131
|
-
return
|
|
18386
|
+
return Login;
|
|
18132
18387
|
}();
|
|
18133
|
-
var
|
|
18388
|
+
var login = new Login();
|
|
18134
18389
|
|
|
18135
|
-
var
|
|
18136
|
-
var
|
|
18137
|
-
var
|
|
18138
|
-
|
|
18139
|
-
|
|
18140
|
-
|
|
18141
|
-
|
|
18142
|
-
|
|
18143
|
-
|
|
18144
|
-
|
|
18145
|
-
|
|
18146
|
-
|
|
18147
|
-
|
|
18390
|
+
var urlIsIp = function urlIsIp(url) {
|
|
18391
|
+
var hostname = url.split('://')[1].split(':')[0].split('/')[0];
|
|
18392
|
+
var arr = hostname.split('.');
|
|
18393
|
+
if (arr.length !== 4) return false;
|
|
18394
|
+
var flag = true;
|
|
18395
|
+
for (var i = 0, len = arr.length; i < len; i++) {
|
|
18396
|
+
if (!Number.isInteger(Number(arr[i]))) {
|
|
18397
|
+
flag = false;
|
|
18398
|
+
break;
|
|
18399
|
+
}
|
|
18400
|
+
}
|
|
18401
|
+
return flag;
|
|
18402
|
+
};
|
|
18148
18403
|
|
|
18149
|
-
|
|
18150
|
-
|
|
18151
|
-
|
|
18152
|
-
|
|
18153
|
-
|
|
18154
|
-
|
|
18155
|
-
|
|
18156
|
-
|
|
18157
|
-
|
|
18158
|
-
|
|
18159
|
-
|
|
18160
|
-
|
|
18161
|
-
|
|
18162
|
-
|
|
18404
|
+
// 如果是非ip地址 则切换为与主页面一样的 location.protocol 前缀
|
|
18405
|
+
var toggleHttpOrHttps = function toggleHttpOrHttps(url) {
|
|
18406
|
+
var res = url;
|
|
18407
|
+
if (!urlIsIp(res)) {
|
|
18408
|
+
if (!res.startsWith(location.protocol)) {
|
|
18409
|
+
var arr = res.split('//');
|
|
18410
|
+
arr[0] = location.protocol;
|
|
18411
|
+
res = arr.join('//');
|
|
18412
|
+
}
|
|
18413
|
+
}
|
|
18414
|
+
return res;
|
|
18415
|
+
};
|
|
18416
|
+
var Core = /*#__PURE__*/function () {
|
|
18417
|
+
function Core() {
|
|
18418
|
+
_classCallCheck$1(this, Core);
|
|
18419
|
+
_defineProperty$1(this, "loadStatus", 0);
|
|
18420
|
+
// 0未开始 1正在加载 2加载完成
|
|
18421
|
+
_defineProperty$1(this, "cache", {
|
|
18422
|
+
envName: '',
|
|
18423
|
+
envData: null,
|
|
18424
|
+
tenantCode: '',
|
|
18425
|
+
webDefineData: null
|
|
18426
|
+
});
|
|
18427
|
+
_defineProperty$1(this, "requestDataPromise", null);
|
|
18428
|
+
}
|
|
18429
|
+
_createClass$1(Core, [{
|
|
18430
|
+
key: "clearCache",
|
|
18431
|
+
value: function clearCache() {
|
|
18432
|
+
this.loadStatus = 0;
|
|
18433
|
+
this.cache = {
|
|
18434
|
+
envName: '',
|
|
18435
|
+
envData: null,
|
|
18436
|
+
tenantCode: '',
|
|
18437
|
+
webDefineData: null
|
|
18438
|
+
};
|
|
18439
|
+
this.requestDataPromise = null;
|
|
18440
|
+
}
|
|
18441
|
+
|
|
18442
|
+
// 请求实时G3数据
|
|
18443
|
+
}, {
|
|
18444
|
+
key: "requestData",
|
|
18445
|
+
value: function () {
|
|
18446
|
+
var _requestData = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
|
|
18447
|
+
var nowEnvname, nowTenantCode;
|
|
18448
|
+
return _regeneratorRuntime$1().wrap(function _callee$(_context) {
|
|
18449
|
+
while (1) switch (_context.prev = _context.next) {
|
|
18450
|
+
case 0:
|
|
18451
|
+
_context.next = 2;
|
|
18452
|
+
return Module.getEnvname();
|
|
18453
|
+
case 2:
|
|
18454
|
+
nowEnvname = _context.sent;
|
|
18455
|
+
nowTenantCode = getUser('tenantcode') || '';
|
|
18456
|
+
this.cache.envName = nowEnvname;
|
|
18457
|
+
this.cache.tenantCode = nowTenantCode;
|
|
18458
|
+
_context.next = 8;
|
|
18459
|
+
return this.requestEnvData(nowEnvname);
|
|
18460
|
+
case 8:
|
|
18461
|
+
this.cache.envData = _context.sent;
|
|
18462
|
+
_context.next = 11;
|
|
18463
|
+
return this.requestWebDefineData();
|
|
18464
|
+
case 11:
|
|
18465
|
+
this.cache.webDefineData = _context.sent;
|
|
18466
|
+
return _context.abrupt("return", this.cache);
|
|
18467
|
+
case 13:
|
|
18468
|
+
case "end":
|
|
18469
|
+
return _context.stop();
|
|
18470
|
+
}
|
|
18471
|
+
}, _callee, this);
|
|
18472
|
+
}));
|
|
18473
|
+
function requestData() {
|
|
18474
|
+
return _requestData.apply(this, arguments);
|
|
18475
|
+
}
|
|
18476
|
+
return requestData;
|
|
18477
|
+
}()
|
|
18478
|
+
}, {
|
|
18479
|
+
key: "requestEnvData",
|
|
18480
|
+
value: function () {
|
|
18481
|
+
var _requestEnvData = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee2(envName) {
|
|
18482
|
+
var result, hostsRoot, response, _result, _result2;
|
|
18483
|
+
return _regeneratorRuntime$1().wrap(function _callee2$(_context2) {
|
|
18484
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
18485
|
+
case 0:
|
|
18486
|
+
// envName = '产品运营中心验证'
|
|
18487
|
+
result = null;
|
|
18488
|
+
if (!envName) {
|
|
18489
|
+
_context2.next = 15;
|
|
18490
|
+
break;
|
|
18491
|
+
}
|
|
18492
|
+
hostsRoot = document.location.protocol === 'https:' ? 'https://mconfig.xtion.net' : 'http://mconfig.xtion.net:8015';
|
|
18493
|
+
_context2.prev = 3;
|
|
18494
|
+
_context2.next = 6;
|
|
18495
|
+
return normalAxios.get("".concat(hostsRoot, "/multiplatconfig/env/").concat(envName), {
|
|
18496
|
+
isShowLoading: false,
|
|
18497
|
+
isSendToken: false
|
|
18498
|
+
});
|
|
18499
|
+
case 6:
|
|
18500
|
+
response = _context2.sent;
|
|
18501
|
+
// console.log(response)
|
|
18502
|
+
// debugger
|
|
18503
|
+
result = get$1(response, 'data.0');
|
|
18504
|
+
|
|
18505
|
+
// 如果是非ip地址 则切换为与主页面一样的 location.protocol 前缀
|
|
18506
|
+
((_result = result) === null || _result === void 0 ? void 0 : _result.business) && (result.business = toggleHttpOrHttps(result.business));
|
|
18507
|
+
((_result2 = result) === null || _result2 === void 0 ? void 0 : _result2.smartcenter) && (result.smartcenter = toggleHttpOrHttps(result.smartcenter));
|
|
18508
|
+
_context2.next = 15;
|
|
18509
|
+
break;
|
|
18510
|
+
case 12:
|
|
18511
|
+
_context2.prev = 12;
|
|
18512
|
+
_context2.t0 = _context2["catch"](3);
|
|
18513
|
+
console.error(_context2.t0);
|
|
18514
|
+
case 15:
|
|
18515
|
+
return _context2.abrupt("return", result);
|
|
18516
|
+
case 16:
|
|
18517
|
+
case "end":
|
|
18518
|
+
return _context2.stop();
|
|
18519
|
+
}
|
|
18520
|
+
}, _callee2, null, [[3, 12]]);
|
|
18521
|
+
}));
|
|
18522
|
+
function requestEnvData(_x) {
|
|
18523
|
+
return _requestEnvData.apply(this, arguments);
|
|
18524
|
+
}
|
|
18525
|
+
return requestEnvData;
|
|
18526
|
+
}()
|
|
18527
|
+
}, {
|
|
18528
|
+
key: "requestWebDefineData",
|
|
18529
|
+
value: function () {
|
|
18530
|
+
var _requestWebDefineData = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee3() {
|
|
18531
|
+
var _this$cache$envData, _this$cache;
|
|
18532
|
+
var envId, tenantCode, smartcenter, result, _res, res, list, usedList;
|
|
18533
|
+
return _regeneratorRuntime$1().wrap(function _callee3$(_context3) {
|
|
18534
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
18535
|
+
case 0:
|
|
18536
|
+
envId = (_this$cache$envData = this.cache.envData) === null || _this$cache$envData === void 0 ? void 0 : _this$cache$envData.envid;
|
|
18537
|
+
tenantCode = this.cache.tenantCode;
|
|
18538
|
+
smartcenter = (_this$cache = this.cache) === null || _this$cache === void 0 || (_this$cache = _this$cache.envData) === null || _this$cache === void 0 ? void 0 : _this$cache.smartcenter;
|
|
18539
|
+
result = null;
|
|
18540
|
+
if (!(envId && tenantCode && smartcenter)) {
|
|
18541
|
+
_context3.next = 16;
|
|
18542
|
+
break;
|
|
18543
|
+
}
|
|
18544
|
+
_context3.prev = 5;
|
|
18545
|
+
_context3.next = 8;
|
|
18546
|
+
return normalAxios.post("".concat(smartcenter, "/api/smartcenter/biz/getTenantWebAndApiDefined"), {
|
|
18547
|
+
envid: envId,
|
|
18548
|
+
tenantcode: tenantCode
|
|
18549
|
+
}, {
|
|
18550
|
+
isShowLoading: false
|
|
18551
|
+
});
|
|
18552
|
+
case 8:
|
|
18553
|
+
res = _context3.sent;
|
|
18554
|
+
_context3.next = 14;
|
|
18555
|
+
break;
|
|
18556
|
+
case 11:
|
|
18557
|
+
_context3.prev = 11;
|
|
18558
|
+
_context3.t0 = _context3["catch"](5);
|
|
18559
|
+
console.error(_context3.t0);
|
|
18560
|
+
case 14:
|
|
18561
|
+
// console.log(res)
|
|
18562
|
+
// debugger
|
|
18563
|
+
list = ((_res = res) === null || _res === void 0 || (_res = _res.data) === null || _res === void 0 ? void 0 : _res.list) || [];
|
|
18564
|
+
if (list && list.length) {
|
|
18565
|
+
usedList = list.filter(function (item) {
|
|
18566
|
+
return item.status === 1;
|
|
18567
|
+
});
|
|
18568
|
+
usedList.forEach(function (item) {
|
|
18569
|
+
if (item.protocol) {
|
|
18570
|
+
try {
|
|
18571
|
+
item.protocol = JSON.parse(item.protocol);
|
|
18572
|
+
} catch (err) {
|
|
18573
|
+
console.error(err);
|
|
18574
|
+
}
|
|
18575
|
+
}
|
|
18576
|
+
if (item.apiprotocol) {
|
|
18577
|
+
try {
|
|
18578
|
+
item.apiprotocol = JSON.parse(item.apiprotocol);
|
|
18579
|
+
} catch (err) {
|
|
18580
|
+
console.error(err);
|
|
18581
|
+
}
|
|
18582
|
+
}
|
|
18583
|
+
});
|
|
18584
|
+
result = usedList;
|
|
18585
|
+
}
|
|
18586
|
+
case 16:
|
|
18587
|
+
return _context3.abrupt("return", result);
|
|
18588
|
+
case 17:
|
|
18589
|
+
case "end":
|
|
18590
|
+
return _context3.stop();
|
|
18591
|
+
}
|
|
18592
|
+
}, _callee3, this, [[5, 11]]);
|
|
18593
|
+
}));
|
|
18594
|
+
function requestWebDefineData() {
|
|
18595
|
+
return _requestWebDefineData.apply(this, arguments);
|
|
18596
|
+
}
|
|
18597
|
+
return requestWebDefineData;
|
|
18598
|
+
}()
|
|
18599
|
+
}, {
|
|
18600
|
+
key: "getData",
|
|
18601
|
+
value: function () {
|
|
18602
|
+
var _getData = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee4() {
|
|
18603
|
+
var nowEnvname, nowTenantCode;
|
|
18604
|
+
return _regeneratorRuntime$1().wrap(function _callee4$(_context4) {
|
|
18605
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
18606
|
+
case 0:
|
|
18607
|
+
_context4.next = 2;
|
|
18608
|
+
return Module.getEnvname();
|
|
18609
|
+
case 2:
|
|
18610
|
+
nowEnvname = _context4.sent;
|
|
18611
|
+
nowTenantCode = getUser('tenantcode') || ''; // console.log(tenantCode)
|
|
18612
|
+
if (!(this.cache.envName === nowEnvname && this.cache.tenantCode === nowTenantCode && this.loadStatus === 2)) {
|
|
18613
|
+
_context4.next = 6;
|
|
18614
|
+
break;
|
|
18615
|
+
}
|
|
18616
|
+
return _context4.abrupt("return", this.cache);
|
|
18617
|
+
case 6:
|
|
18618
|
+
if (!(this.loadStatus === 1 && this.requestDataPromise)) {
|
|
18619
|
+
_context4.next = 8;
|
|
18620
|
+
break;
|
|
18621
|
+
}
|
|
18622
|
+
return _context4.abrupt("return", this.requestDataPromise);
|
|
18623
|
+
case 8:
|
|
18624
|
+
this.loadStatus = 1;
|
|
18625
|
+
this.requestDataPromise = this.requestData();
|
|
18626
|
+
_context4.next = 12;
|
|
18627
|
+
return this.requestDataPromise;
|
|
18628
|
+
case 12:
|
|
18629
|
+
this.loadStatus = 2;
|
|
18630
|
+
return _context4.abrupt("return", this.cache);
|
|
18631
|
+
case 14:
|
|
18632
|
+
case "end":
|
|
18633
|
+
return _context4.stop();
|
|
18634
|
+
}
|
|
18635
|
+
}, _callee4, this);
|
|
18636
|
+
}));
|
|
18637
|
+
function getData() {
|
|
18638
|
+
return _getData.apply(this, arguments);
|
|
18639
|
+
}
|
|
18640
|
+
return getData;
|
|
18641
|
+
}()
|
|
18642
|
+
}, {
|
|
18643
|
+
key: "getEnvData",
|
|
18644
|
+
value: function () {
|
|
18645
|
+
var _getEnvData = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee5() {
|
|
18646
|
+
var res, data;
|
|
18647
|
+
return _regeneratorRuntime$1().wrap(function _callee5$(_context5) {
|
|
18648
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
18649
|
+
case 0:
|
|
18650
|
+
res = {
|
|
18651
|
+
errorMsg: '',
|
|
18652
|
+
data: null
|
|
18653
|
+
};
|
|
18654
|
+
_context5.next = 3;
|
|
18655
|
+
return this.getData();
|
|
18656
|
+
case 3:
|
|
18657
|
+
data = _context5.sent;
|
|
18658
|
+
if (!data.envName) {
|
|
18659
|
+
res.errorMsg = '找不到租户环境名称,请检查登录时是否有填写企业名称。';
|
|
18660
|
+
} else if (!data.envData) {
|
|
18661
|
+
res.errorMsg = '找不到租户环境信息。';
|
|
18662
|
+
} else {
|
|
18663
|
+
res.data = data.envData;
|
|
18664
|
+
}
|
|
18665
|
+
return _context5.abrupt("return", res);
|
|
18666
|
+
case 6:
|
|
18667
|
+
case "end":
|
|
18668
|
+
return _context5.stop();
|
|
18669
|
+
}
|
|
18670
|
+
}, _callee5, this);
|
|
18671
|
+
}));
|
|
18672
|
+
function getEnvData() {
|
|
18673
|
+
return _getEnvData.apply(this, arguments);
|
|
18674
|
+
}
|
|
18675
|
+
return getEnvData;
|
|
18676
|
+
}()
|
|
18677
|
+
}, {
|
|
18678
|
+
key: "getEnvBusiness",
|
|
18679
|
+
value: function () {
|
|
18680
|
+
var _getEnvBusiness = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee6() {
|
|
18681
|
+
var business, envData;
|
|
18682
|
+
return _regeneratorRuntime$1().wrap(function _callee6$(_context6) {
|
|
18683
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
18684
|
+
case 0:
|
|
18685
|
+
business = '';
|
|
18686
|
+
_context6.next = 3;
|
|
18687
|
+
return this.getEnvData();
|
|
18688
|
+
case 3:
|
|
18689
|
+
envData = _context6.sent;
|
|
18690
|
+
if (envData.data) {
|
|
18691
|
+
business = envData.data.business;
|
|
18163
18692
|
}
|
|
18693
|
+
return _context6.abrupt("return", business);
|
|
18694
|
+
case 6:
|
|
18695
|
+
case "end":
|
|
18696
|
+
return _context6.stop();
|
|
18697
|
+
}
|
|
18698
|
+
}, _callee6, this);
|
|
18699
|
+
}));
|
|
18700
|
+
function getEnvBusiness() {
|
|
18701
|
+
return _getEnvBusiness.apply(this, arguments);
|
|
18702
|
+
}
|
|
18703
|
+
return getEnvBusiness;
|
|
18704
|
+
}()
|
|
18705
|
+
}, {
|
|
18706
|
+
key: "getModuleData",
|
|
18707
|
+
value: function () {
|
|
18708
|
+
var _getModuleData = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee7(modulekey) {
|
|
18709
|
+
var res, data;
|
|
18710
|
+
return _regeneratorRuntime$1().wrap(function _callee7$(_context7) {
|
|
18711
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
18712
|
+
case 0:
|
|
18713
|
+
if (!modulekey) {
|
|
18714
|
+
modulekey = globalOptions.modulekey;
|
|
18715
|
+
}
|
|
18716
|
+
res = {
|
|
18717
|
+
errorMsg: '',
|
|
18718
|
+
data: null
|
|
18719
|
+
};
|
|
18720
|
+
_context7.next = 4;
|
|
18721
|
+
return this.getData();
|
|
18722
|
+
case 4:
|
|
18723
|
+
data = _context7.sent;
|
|
18724
|
+
if (!modulekey) {
|
|
18725
|
+
res.errorMsg = '缺少 modulekey,请检查。';
|
|
18726
|
+
} else if (!data.envName) {
|
|
18727
|
+
res.errorMsg = '找不到租户环境名称,请检查登录时是否有填写企业名称。';
|
|
18728
|
+
} else if (!data.envData) {
|
|
18729
|
+
res.errorMsg = '找不到租户环境信息。';
|
|
18730
|
+
} else if (!data.webDefineData) {
|
|
18731
|
+
res.errorMsg = '该租户没有部署 G3。';
|
|
18732
|
+
} else if (!data.webDefineData.length) {
|
|
18733
|
+
res.errorMsg = '该租户没有授权场景模块/SPU模块。';
|
|
18734
|
+
} else {
|
|
18735
|
+
res.data = data.webDefineData.find(function (item) {
|
|
18736
|
+
return item.modulekey === modulekey;
|
|
18737
|
+
});
|
|
18738
|
+
if (!res.data) {
|
|
18739
|
+
res.errorMsg = "\u8BE5\u79DF\u6237\u6CA1\u6709\u6388\u6743 ".concat(modulekey, " \u6A21\u5757\u3002");
|
|
18740
|
+
}
|
|
18741
|
+
}
|
|
18742
|
+
return _context7.abrupt("return", res);
|
|
18743
|
+
case 7:
|
|
18744
|
+
case "end":
|
|
18745
|
+
return _context7.stop();
|
|
18746
|
+
}
|
|
18747
|
+
}, _callee7, this);
|
|
18748
|
+
}));
|
|
18749
|
+
function getModuleData(_x2) {
|
|
18750
|
+
return _getModuleData.apply(this, arguments);
|
|
18751
|
+
}
|
|
18752
|
+
return getModuleData;
|
|
18753
|
+
}()
|
|
18754
|
+
}, {
|
|
18755
|
+
key: "getContext",
|
|
18756
|
+
value: function () {
|
|
18757
|
+
var _getContext = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee8(modulekey) {
|
|
18758
|
+
var context, moduleData;
|
|
18759
|
+
return _regeneratorRuntime$1().wrap(function _callee8$(_context8) {
|
|
18760
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
18761
|
+
case 0:
|
|
18762
|
+
if (!modulekey) {
|
|
18763
|
+
modulekey = globalOptions.modulekey;
|
|
18764
|
+
}
|
|
18765
|
+
_context8.next = 3;
|
|
18766
|
+
return this.getModuleData(modulekey);
|
|
18767
|
+
case 3:
|
|
18768
|
+
moduleData = _context8.sent;
|
|
18769
|
+
if (moduleData !== null && moduleData !== void 0 && moduleData.data) {
|
|
18770
|
+
context = {
|
|
18771
|
+
envid: moduleData.envid || '',
|
|
18772
|
+
envname: this.cache.envName || '',
|
|
18773
|
+
tenantcode: moduleData.tenantcode || '',
|
|
18774
|
+
modulecode: moduleData.modulecode || '',
|
|
18775
|
+
modulekey: moduleData.modulekey || '',
|
|
18776
|
+
modulename: moduleData.modulename || '',
|
|
18777
|
+
moduleversion: moduleData.moduleversion || '',
|
|
18778
|
+
versioncode: moduleData.versioncode || '',
|
|
18779
|
+
versionnum: moduleData.moduleversion || ''
|
|
18780
|
+
};
|
|
18781
|
+
}
|
|
18782
|
+
return _context8.abrupt("return", context);
|
|
18783
|
+
case 6:
|
|
18784
|
+
case "end":
|
|
18785
|
+
return _context8.stop();
|
|
18786
|
+
}
|
|
18787
|
+
}, _callee8, this);
|
|
18788
|
+
}));
|
|
18789
|
+
function getContext(_x3) {
|
|
18790
|
+
return _getContext.apply(this, arguments);
|
|
18791
|
+
}
|
|
18792
|
+
return getContext;
|
|
18793
|
+
}()
|
|
18794
|
+
}, {
|
|
18795
|
+
key: "getModuleBusiness",
|
|
18796
|
+
value: function () {
|
|
18797
|
+
var _getModuleBusiness = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee9(modulekey) {
|
|
18798
|
+
var business, moduleData, envBusiness;
|
|
18799
|
+
return _regeneratorRuntime$1().wrap(function _callee9$(_context9) {
|
|
18800
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
18801
|
+
case 0:
|
|
18802
|
+
business = '';
|
|
18803
|
+
_context9.next = 3;
|
|
18804
|
+
return this.getModuleData(modulekey);
|
|
18805
|
+
case 3:
|
|
18806
|
+
moduleData = _context9.sent;
|
|
18807
|
+
if (!moduleData.data) {
|
|
18808
|
+
_context9.next = 9;
|
|
18809
|
+
break;
|
|
18810
|
+
}
|
|
18811
|
+
_context9.next = 7;
|
|
18812
|
+
return this.getEnvBusiness();
|
|
18813
|
+
case 7:
|
|
18814
|
+
envBusiness = _context9.sent;
|
|
18815
|
+
business = "".concat(moduleData.data.address || envBusiness);
|
|
18816
|
+
case 9:
|
|
18817
|
+
return _context9.abrupt("return", business);
|
|
18818
|
+
case 10:
|
|
18819
|
+
case "end":
|
|
18820
|
+
return _context9.stop();
|
|
18821
|
+
}
|
|
18822
|
+
}, _callee9, this);
|
|
18823
|
+
}));
|
|
18824
|
+
function getModuleBusiness(_x4) {
|
|
18825
|
+
return _getModuleBusiness.apply(this, arguments);
|
|
18826
|
+
}
|
|
18827
|
+
return getModuleBusiness;
|
|
18828
|
+
}()
|
|
18829
|
+
}, {
|
|
18830
|
+
key: "checkModule",
|
|
18831
|
+
value: function () {
|
|
18832
|
+
var _checkModule = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee10(modulekey) {
|
|
18833
|
+
var moduleData;
|
|
18834
|
+
return _regeneratorRuntime$1().wrap(function _callee10$(_context10) {
|
|
18835
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
18836
|
+
case 0:
|
|
18837
|
+
if (!modulekey) {
|
|
18838
|
+
modulekey = globalOptions.modulekey;
|
|
18839
|
+
}
|
|
18840
|
+
_context10.next = 3;
|
|
18841
|
+
return this.getModuleData(modulekey);
|
|
18842
|
+
case 3:
|
|
18843
|
+
moduleData = _context10.sent;
|
|
18844
|
+
return _context10.abrupt("return", !!moduleData.data);
|
|
18845
|
+
case 5:
|
|
18846
|
+
case "end":
|
|
18847
|
+
return _context10.stop();
|
|
18848
|
+
}
|
|
18849
|
+
}, _callee10, this);
|
|
18850
|
+
}));
|
|
18851
|
+
function checkModule(_x5) {
|
|
18852
|
+
return _checkModule.apply(this, arguments);
|
|
18853
|
+
}
|
|
18854
|
+
return checkModule;
|
|
18855
|
+
}()
|
|
18856
|
+
}]);
|
|
18857
|
+
return Core;
|
|
18858
|
+
}();
|
|
18859
|
+
var core = new Core();
|
|
18860
|
+
|
|
18861
|
+
var createAxiosInstance = function createAxiosInstance() {
|
|
18862
|
+
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'spu';
|
|
18863
|
+
var options = arguments.length > 1 ? arguments[1] : undefined;
|
|
18864
|
+
var axiosInstance = axios$1.create({
|
|
18865
|
+
baseURL: type === 'spu' ? "/api/".concat(options.modulekey, "/").concat(options.moduleversion) : ''
|
|
18866
|
+
// baseURL: '',
|
|
18867
|
+
// timeout: 36000000
|
|
18868
|
+
// withCredentials: true, // 不能开启 影响ali oss
|
|
18869
|
+
// headers: {
|
|
18870
|
+
// // 'Content-Type': 'application/json;charset=UTF-8',
|
|
18871
|
+
// // 'app_id': '100'
|
|
18872
|
+
// }
|
|
18873
|
+
});
|
|
18874
|
+
|
|
18875
|
+
axiosInstance.interceptors.request.use( /*#__PURE__*/function () {
|
|
18876
|
+
var _ref = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee(config) {
|
|
18877
|
+
var isShowLoading, isSendToken, token, moduleData;
|
|
18878
|
+
return _regeneratorRuntime$1().wrap(function _callee$(_context) {
|
|
18879
|
+
while (1) switch (_context.prev = _context.next) {
|
|
18880
|
+
case 0:
|
|
18881
|
+
// const isShowLoading = typeof config?.isShowLoading !== 'undefined' ? config.isShowLoading : true
|
|
18882
|
+
// console.error(444444)
|
|
18883
|
+
// console.log(config)
|
|
18884
|
+
isShowLoading = get$1(config, 'isShowLoading', true);
|
|
18885
|
+
isShowLoading && loadding.open();
|
|
18886
|
+
isSendToken = get$1(config, 'isSendToken', true);
|
|
18887
|
+
if (!isSendToken) {
|
|
18888
|
+
_context.next = 16;
|
|
18889
|
+
break;
|
|
18890
|
+
}
|
|
18891
|
+
if (!(config.url !== '/api/auth/refreshtoken')) {
|
|
18892
|
+
_context.next = 14;
|
|
18893
|
+
break;
|
|
18164
18894
|
}
|
|
18895
|
+
if (!(!login.checkLogin() && login.getRole() !== 'center')) {
|
|
18896
|
+
_context.next = 14;
|
|
18897
|
+
break;
|
|
18898
|
+
}
|
|
18899
|
+
_context.prev = 6;
|
|
18900
|
+
_context.next = 9;
|
|
18901
|
+
return login.updateToken();
|
|
18902
|
+
case 9:
|
|
18903
|
+
_context.next = 14;
|
|
18904
|
+
break;
|
|
18905
|
+
case 11:
|
|
18906
|
+
_context.prev = 11;
|
|
18907
|
+
_context.t0 = _context["catch"](6);
|
|
18908
|
+
console.error(_context.t0);
|
|
18909
|
+
case 14:
|
|
18910
|
+
token = login.getToken();
|
|
18911
|
+
if (config !== null && config !== void 0 && config.headers && token) {
|
|
18912
|
+
config.headers.token = token;
|
|
18913
|
+
}
|
|
18914
|
+
case 16:
|
|
18165
18915
|
if (!(type === 'spu' && config.modulekey)) {
|
|
18166
|
-
_context.next =
|
|
18916
|
+
_context.next = 21;
|
|
18167
18917
|
break;
|
|
18168
18918
|
}
|
|
18169
|
-
_context.next =
|
|
18919
|
+
_context.next = 19;
|
|
18170
18920
|
return core.getModuleData(config.modulekey);
|
|
18171
|
-
case
|
|
18921
|
+
case 19:
|
|
18172
18922
|
moduleData = _context.sent;
|
|
18173
18923
|
if (moduleData.data) {
|
|
18174
18924
|
config.baseURL = "/api/".concat(config.modulekey, "/").concat(moduleData.data.moduleversion);
|
|
@@ -18176,13 +18926,13 @@ var createAxiosInstance = function createAxiosInstance() {
|
|
|
18176
18926
|
console.error(moduleData.errorMsg);
|
|
18177
18927
|
config.baseURL = "/api/".concat(config.modulekey, "/v?.?");
|
|
18178
18928
|
}
|
|
18179
|
-
case
|
|
18929
|
+
case 21:
|
|
18180
18930
|
return _context.abrupt("return", config);
|
|
18181
|
-
case
|
|
18931
|
+
case 22:
|
|
18182
18932
|
case "end":
|
|
18183
18933
|
return _context.stop();
|
|
18184
18934
|
}
|
|
18185
|
-
}, _callee);
|
|
18935
|
+
}, _callee, null, [[6, 11]]);
|
|
18186
18936
|
}));
|
|
18187
18937
|
return function (_x) {
|
|
18188
18938
|
return _ref.apply(this, arguments);
|
|
@@ -51631,80 +52381,6 @@ var dayjs_min = {exports: {}};
|
|
|
51631
52381
|
var dayjs_minExports = dayjs_min.exports;
|
|
51632
52382
|
var dayjs = /*@__PURE__*/getDefaultExportFromCjs(dayjs_minExports);
|
|
51633
52383
|
|
|
51634
|
-
var CloudServ = /*#__PURE__*/function () {
|
|
51635
|
-
function CloudServ() {
|
|
51636
|
-
_classCallCheck$1(this, CloudServ);
|
|
51637
|
-
_defineProperty$1(this, "CLOUD_SERVE_KEY", 'cloudserv');
|
|
51638
|
-
_defineProperty$1(this, "cacheStorage", null);
|
|
51639
|
-
}
|
|
51640
|
-
_createClass$1(CloudServ, [{
|
|
51641
|
-
key: "get",
|
|
51642
|
-
value: function get() {
|
|
51643
|
-
var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'storage';
|
|
51644
|
-
if (this.cacheStorage) {
|
|
51645
|
-
return this.cacheStorage[key] || null;
|
|
51646
|
-
}
|
|
51647
|
-
var storageStr = lsProxy.getItem(this.CLOUD_SERVE_KEY);
|
|
51648
|
-
if (!storageStr) {
|
|
51649
|
-
return null;
|
|
51650
|
-
}
|
|
51651
|
-
var storage = JSON.parse(storageStr);
|
|
51652
|
-
this.cacheStorage = storage;
|
|
51653
|
-
return storage[key];
|
|
51654
|
-
}
|
|
51655
|
-
}, {
|
|
51656
|
-
key: "set",
|
|
51657
|
-
value: function set(storage) {
|
|
51658
|
-
if (_typeof(storage) === 'object') {
|
|
51659
|
-
this.cacheStorage = storage;
|
|
51660
|
-
storage = JSON.stringify(storage);
|
|
51661
|
-
}
|
|
51662
|
-
lsProxy.setItem(this.CLOUD_SERVE_KEY, storage);
|
|
51663
|
-
}
|
|
51664
|
-
}, {
|
|
51665
|
-
key: "remove",
|
|
51666
|
-
value: function remove() {
|
|
51667
|
-
lsProxy.removeItem(this.CLOUD_SERVE_KEY);
|
|
51668
|
-
}
|
|
51669
|
-
}, {
|
|
51670
|
-
key: "getProvider",
|
|
51671
|
-
value: function getProvider() {
|
|
51672
|
-
var sign = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'storage';
|
|
51673
|
-
var storage = this.get(sign);
|
|
51674
|
-
if (!storage) {
|
|
51675
|
-
return false;
|
|
51676
|
-
}
|
|
51677
|
-
return storage.cloudserv_storage_provider;
|
|
51678
|
-
}
|
|
51679
|
-
}, {
|
|
51680
|
-
key: "isAliyun",
|
|
51681
|
-
value: function isAliyun() {
|
|
51682
|
-
var sign = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'storage';
|
|
51683
|
-
return this.getProvider(sign) === 'aliyun';
|
|
51684
|
-
}
|
|
51685
|
-
}, {
|
|
51686
|
-
key: "isAzure",
|
|
51687
|
-
value: function isAzure() {
|
|
51688
|
-
var sign = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'storage';
|
|
51689
|
-
return this.getProvider(sign) === 'azure';
|
|
51690
|
-
}
|
|
51691
|
-
}, {
|
|
51692
|
-
key: "isAwss3",
|
|
51693
|
-
value: function isAwss3() {
|
|
51694
|
-
var sign = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'storage';
|
|
51695
|
-
return this.getProvider(sign) === 'awss3';
|
|
51696
|
-
}
|
|
51697
|
-
}, {
|
|
51698
|
-
key: "isHuawei",
|
|
51699
|
-
value: function isHuawei() {
|
|
51700
|
-
var sign = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'storage';
|
|
51701
|
-
return this.getProvider(sign) === 'huawei';
|
|
51702
|
-
}
|
|
51703
|
-
}]);
|
|
51704
|
-
return CloudServ;
|
|
51705
|
-
}();
|
|
51706
|
-
var cloudServ = new CloudServ();
|
|
51707
|
-
|
|
51708
52384
|
// 一个小时的超时能力 1000 * 60 * 60
|
|
51709
52385
|
var last = 0;
|
|
51710
52386
|
var servtoken = null;
|
|
@@ -51876,7 +52552,7 @@ var getUrl = /*#__PURE__*/function () {
|
|
|
51876
52552
|
while (1) switch (_context.prev = _context.next) {
|
|
51877
52553
|
case 0:
|
|
51878
52554
|
_ref$type = _ref.type, type = _ref$type === void 0 ? 'img' : _ref$type, _ref$source = _ref.source, source = _ref$source === void 0 ? '' : _ref$source, _ref$filename = _ref.filename, filename = _ref$filename === void 0 ? '' : _ref$filename, _ref$datetime = _ref.datetime, datetime = _ref$datetime === void 0 ? '' : _ref$datetime, _ref$storagetype = _ref.storagetype, storagetype = _ref$storagetype === void 0 ? 'storage' : _ref$storagetype, _ref$cope = _ref.cope, cope = _ref$cope === void 0 ? '' : _ref$cope;
|
|
51879
|
-
cloudServStorage =
|
|
52555
|
+
cloudServStorage = CloudServ$1.get(storagetype);
|
|
51880
52556
|
if (cloudServStorage) {
|
|
51881
52557
|
_context.next = 4;
|
|
51882
52558
|
break;
|
|
@@ -51893,8 +52569,8 @@ var getUrl = /*#__PURE__*/function () {
|
|
|
51893
52569
|
}
|
|
51894
52570
|
throw Error('无可用servToken');
|
|
51895
52571
|
case 9:
|
|
51896
|
-
isAliYun =
|
|
51897
|
-
isHuawei =
|
|
52572
|
+
isAliYun = CloudServ$1.isAliyun(storagetype);
|
|
52573
|
+
isHuawei = CloudServ$1.isHuawei(storagetype);
|
|
51898
52574
|
tenantCode = getUser('tenantcode');
|
|
51899
52575
|
if (!filename) {
|
|
51900
52576
|
filename = source;
|
|
@@ -52047,7 +52723,7 @@ var downloadFile = /*#__PURE__*/function () {
|
|
|
52047
52723
|
// console.log(e)
|
|
52048
52724
|
// throw Error(e)
|
|
52049
52725
|
// })
|
|
52050
|
-
isAliYun =
|
|
52726
|
+
isAliYun = CloudServ$1.isAliyun(storagetype); // const isHuawei = CloudServ.isHuawei(storagetype)
|
|
52051
52727
|
if (isAliYun) {
|
|
52052
52728
|
downloadFileByUrl(url, filename);
|
|
52053
52729
|
} else {
|
|
@@ -52527,7 +53203,7 @@ var upload = /*#__PURE__*/function () {
|
|
|
52527
53203
|
}
|
|
52528
53204
|
throw Error('请传入文件');
|
|
52529
53205
|
case 3:
|
|
52530
|
-
cloudServStorage =
|
|
53206
|
+
cloudServStorage = CloudServ$1.get(storagetype);
|
|
52531
53207
|
if (cloudServStorage) {
|
|
52532
53208
|
_context4.next = 6;
|
|
52533
53209
|
break;
|
|
@@ -52544,8 +53220,8 @@ var upload = /*#__PURE__*/function () {
|
|
|
52544
53220
|
}
|
|
52545
53221
|
throw Error('无可用servToken');
|
|
52546
53222
|
case 11:
|
|
52547
|
-
isAliYun =
|
|
52548
|
-
isHuawei =
|
|
53223
|
+
isAliYun = CloudServ$1.isAliyun(storagetype);
|
|
53224
|
+
isHuawei = CloudServ$1.isHuawei(storagetype);
|
|
52549
53225
|
tenantCode = getUser('tenantcode');
|
|
52550
53226
|
suffix = '.' + file.name.substring(file.name.lastIndexOf('.') + 1);
|
|
52551
53227
|
source = source ? source : v4() + suffix;
|
|
@@ -52726,598 +53402,43 @@ var setTitle = function setTitle(pagetitle) {
|
|
|
52726
53402
|
// 父级spu容器 且 是APP
|
|
52727
53403
|
((_window = window) === null || _window === void 0 || (_window = _window.Native) === null || _window === void 0 ? void 0 : _window.setNavigationBarTitle) && window.Native.setNavigationBarTitle(pagetitle);
|
|
52728
53404
|
};
|
|
52729
|
-
|
|
52730
|
-
|
|
52731
|
-
|
|
52732
|
-
|
|
52733
|
-
|
|
52734
|
-
|
|
52735
|
-
|
|
52736
|
-
|
|
52737
|
-
|
|
52738
|
-
_createClass$1(Login, [{
|
|
52739
|
-
key: "getData",
|
|
52740
|
-
value: function getData(key) {
|
|
52741
|
-
if (this.cache[key]) {
|
|
52742
|
-
return this.cache[key];
|
|
52743
|
-
} else {
|
|
52744
|
-
var data = lsProxy.getItem(key);
|
|
52745
|
-
this.cache[key] = data;
|
|
52746
|
-
return data;
|
|
52747
|
-
}
|
|
52748
|
-
}
|
|
52749
|
-
}, {
|
|
52750
|
-
key: "setData",
|
|
52751
|
-
value: function setData(key, value) {
|
|
52752
|
-
this.cache[key] = value;
|
|
52753
|
-
lsProxy.setItem(key, value);
|
|
52754
|
-
}
|
|
52755
|
-
}, {
|
|
52756
|
-
key: "removeData",
|
|
52757
|
-
value: function removeData(key) {
|
|
52758
|
-
delete this.cache[key];
|
|
52759
|
-
lsProxy.removeItem(key);
|
|
52760
|
-
}
|
|
52761
|
-
}, {
|
|
52762
|
-
key: "getEnvname",
|
|
52763
|
-
value: function () {
|
|
52764
|
-
var _getEnvname = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
|
|
52765
|
-
var _context, _window, _window2;
|
|
52766
|
-
var envname, context, contextEnvname, queryEnvname;
|
|
52767
|
-
return _regeneratorRuntime$1().wrap(function _callee$(_context2) {
|
|
52768
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
52769
|
-
case 0:
|
|
52770
|
-
envname = ''; // web 查 context 的 envname
|
|
52771
|
-
context = lsProxy.getItem('context');
|
|
52772
|
-
context && (context = JSON.parse(context));
|
|
52773
|
-
contextEnvname = ((_context = context) === null || _context === void 0 ? void 0 : _context.envname) || ''; // 链接有些spu可能会传 envname
|
|
52774
|
-
queryEnvname = this.getQueryEnvname();
|
|
52775
|
-
if (!contextEnvname) {
|
|
52776
|
-
_context2.next = 9;
|
|
52777
|
-
break;
|
|
52778
|
-
}
|
|
52779
|
-
envname = contextEnvname;
|
|
52780
|
-
_context2.next = 17;
|
|
52781
|
-
break;
|
|
52782
|
-
case 9:
|
|
52783
|
-
if (!queryEnvname) {
|
|
52784
|
-
_context2.next = 13;
|
|
52785
|
-
break;
|
|
52786
|
-
}
|
|
52787
|
-
envname = queryEnvname;
|
|
52788
|
-
_context2.next = 17;
|
|
52789
|
-
break;
|
|
52790
|
-
case 13:
|
|
52791
|
-
if (!((_window = window) !== null && _window !== void 0 && (_window = _window.aPaaS) !== null && _window !== void 0 && _window.getWebInitParams && (_window2 = window) !== null && _window2 !== void 0 && (_window2 = _window2.Native) !== null && _window2 !== void 0 && _window2.setNavigationBarReturnButton)) {
|
|
52792
|
-
_context2.next = 17;
|
|
52793
|
-
break;
|
|
52794
|
-
}
|
|
52795
|
-
_context2.next = 16;
|
|
52796
|
-
return new Promise(function (resolve, reject) {
|
|
52797
|
-
window.aPaaS.getWebInitParams(function (params) {
|
|
52798
|
-
resolve((params === null || params === void 0 ? void 0 : params.envname) || '');
|
|
52799
|
-
});
|
|
52800
|
-
});
|
|
52801
|
-
case 16:
|
|
52802
|
-
envname = _context2.sent;
|
|
52803
|
-
case 17:
|
|
52804
|
-
return _context2.abrupt("return", envname);
|
|
52805
|
-
case 18:
|
|
52806
|
-
case "end":
|
|
52807
|
-
return _context2.stop();
|
|
52808
|
-
}
|
|
52809
|
-
}, _callee, this);
|
|
52810
|
-
}));
|
|
52811
|
-
function getEnvname() {
|
|
52812
|
-
return _getEnvname.apply(this, arguments);
|
|
52813
|
-
}
|
|
52814
|
-
return getEnvname;
|
|
52815
|
-
}()
|
|
52816
|
-
}, {
|
|
52817
|
-
key: "setQueryEnvname",
|
|
52818
|
-
value: function setQueryEnvname(value) {
|
|
52819
|
-
this.setData('envname', value);
|
|
52820
|
-
}
|
|
52821
|
-
}, {
|
|
52822
|
-
key: "getQueryEnvname",
|
|
52823
|
-
value: function getQueryEnvname() {
|
|
52824
|
-
return this.getData('envname') || '';
|
|
52825
|
-
}
|
|
52826
|
-
}, {
|
|
52827
|
-
key: "removeQueryEnvname",
|
|
52828
|
-
value: function removeQueryEnvname() {
|
|
52829
|
-
this.removeData('envname');
|
|
52830
|
-
}
|
|
52831
|
-
}, {
|
|
52832
|
-
key: "getToken",
|
|
52833
|
-
value: function getToken() {
|
|
52834
|
-
return this.getData('token');
|
|
52835
|
-
}
|
|
52836
|
-
}, {
|
|
52837
|
-
key: "setToken",
|
|
52838
|
-
value: function setToken(value) {
|
|
52839
|
-
this.setData('token', value);
|
|
52840
|
-
}
|
|
52841
|
-
}, {
|
|
52842
|
-
key: "removeToken",
|
|
52843
|
-
value: function removeToken() {
|
|
52844
|
-
this.removeData('token');
|
|
52845
|
-
}
|
|
52846
|
-
}, {
|
|
52847
|
-
key: "getTokenExpires",
|
|
52848
|
-
value: function getTokenExpires() {
|
|
52849
|
-
return this.getData('tokenexpires');
|
|
52850
|
-
}
|
|
52851
|
-
}, {
|
|
52852
|
-
key: "setTokenExpires",
|
|
52853
|
-
value: function setTokenExpires(value) {
|
|
52854
|
-
this.setData('tokenexpires', value);
|
|
52855
|
-
}
|
|
52856
|
-
}, {
|
|
52857
|
-
key: "removeTokenExpires",
|
|
52858
|
-
value: function removeTokenExpires() {
|
|
52859
|
-
this.removeData('tokenexpires');
|
|
52860
|
-
}
|
|
52861
|
-
}, {
|
|
52862
|
-
key: "getRefreshToken",
|
|
52863
|
-
value: function getRefreshToken() {
|
|
52864
|
-
return this.getData('refreshtoken');
|
|
52865
|
-
}
|
|
52866
|
-
}, {
|
|
52867
|
-
key: "setRefreshToken",
|
|
52868
|
-
value: function setRefreshToken(value) {
|
|
52869
|
-
this.setData('refreshtoken', value);
|
|
52870
|
-
}
|
|
52871
|
-
}, {
|
|
52872
|
-
key: "removeRefreshToken",
|
|
52873
|
-
value: function removeRefreshToken() {
|
|
52874
|
-
this.removeData('refreshtoken');
|
|
52875
|
-
}
|
|
52876
|
-
}, {
|
|
52877
|
-
key: "updateToken",
|
|
52878
|
-
value: function updateToken() {
|
|
52879
|
-
var _this = this;
|
|
52880
|
-
return normalAxios.get('/api/auth/refreshtoken', {
|
|
52881
|
-
params: {
|
|
52882
|
-
refreshtoken: this.getRefreshToken()
|
|
52883
|
-
},
|
|
52884
|
-
isShowLoadding: false,
|
|
52885
|
-
isShowErrorMessage: false
|
|
52886
|
-
}).then(function (res) {
|
|
52887
|
-
// console.log(res)
|
|
52888
|
-
var data = res === null || res === void 0 ? void 0 : res.data;
|
|
52889
|
-
if (data) {
|
|
52890
|
-
_this.setToken(data.token);
|
|
52891
|
-
_this.setRefreshToken(data.refreshtoken);
|
|
52892
|
-
_this.setTokenExpires(data.tokenexpires);
|
|
52893
|
-
}
|
|
52894
|
-
});
|
|
52895
|
-
}
|
|
52896
|
-
}, {
|
|
52897
|
-
key: "startRefreshtoken",
|
|
52898
|
-
value: function startRefreshtoken() {
|
|
52899
|
-
var _this2 = this;
|
|
52900
|
-
// 如果有登录 则过期前15秒更新token
|
|
52901
|
-
// 如果没登录 每隔1分钟走token更新逻辑(如果刚开始没登录 后面才登录【不需要再在登陆后写刷新token逻辑】)
|
|
52902
|
-
this.stopRefreshtoken();
|
|
52903
|
-
var time = this.checkLogin() ? Number(this.getTokenExpires()) - Date.now() - 1000 * 15 : 1000 * 60;
|
|
52904
|
-
// const time = 5000
|
|
52905
|
-
if (time > 0) {
|
|
52906
|
-
this.refreshtokenTimer = window.setTimeout( /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee2() {
|
|
52907
|
-
return _regeneratorRuntime$1().wrap(function _callee2$(_context3) {
|
|
52908
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
52909
|
-
case 0:
|
|
52910
|
-
if (!_this2.checkLogin()) {
|
|
52911
|
-
_context3.next = 3;
|
|
52912
|
-
break;
|
|
52913
|
-
}
|
|
52914
|
-
_context3.next = 3;
|
|
52915
|
-
return _this2.updateToken();
|
|
52916
|
-
case 3:
|
|
52917
|
-
_this2.startRefreshtoken();
|
|
52918
|
-
case 4:
|
|
52919
|
-
case "end":
|
|
52920
|
-
return _context3.stop();
|
|
52921
|
-
}
|
|
52922
|
-
}, _callee2);
|
|
52923
|
-
})), time);
|
|
52924
|
-
}
|
|
52925
|
-
}
|
|
52926
|
-
}, {
|
|
52927
|
-
key: "stopRefreshtoken",
|
|
52928
|
-
value: function stopRefreshtoken() {
|
|
52929
|
-
clearTimeout(this.refreshtokenTimer);
|
|
52930
|
-
this.refreshtokenTimer = null;
|
|
52931
|
-
}
|
|
52932
|
-
}, {
|
|
52933
|
-
key: "getUser",
|
|
52934
|
-
value: function getUser(key) {
|
|
52935
|
-
var user = this.getData('user');
|
|
52936
|
-
var userObj = user ? JSON.parse(user) : null;
|
|
52937
|
-
if (!key) {
|
|
52938
|
-
return userObj;
|
|
52939
|
-
} else {
|
|
52940
|
-
return userObj ? userObj[key] || '' : '';
|
|
52941
|
-
}
|
|
52942
|
-
}
|
|
52943
|
-
}, {
|
|
52944
|
-
key: "setUser",
|
|
52945
|
-
value: function setUser(value) {
|
|
52946
|
-
var res;
|
|
52947
|
-
if (typeof value === 'string') {
|
|
52948
|
-
res = JSON.parse(value);
|
|
52949
|
-
} else {
|
|
52950
|
-
res = cloneDeep$1(value);
|
|
52951
|
-
}
|
|
52952
|
-
for (var x in res) {
|
|
52953
|
-
res[x.toLowerCase()] = res[x];
|
|
52954
|
-
}
|
|
52955
|
-
this.setData('user', JSON.stringify(res));
|
|
52956
|
-
}
|
|
52957
|
-
}, {
|
|
52958
|
-
key: "setUserByToken",
|
|
52959
|
-
value: function setUserByToken(token) {
|
|
52960
|
-
var jwtInfo = this.jwtDecode(token);
|
|
52961
|
-
if (jwtInfo && jwtInfo.LoginUser) {
|
|
52962
|
-
this.setUser(jwtInfo.LoginUser);
|
|
52963
|
-
} else {
|
|
52964
|
-
this.removeUser();
|
|
52965
|
-
}
|
|
52966
|
-
}
|
|
52967
|
-
}, {
|
|
52968
|
-
key: "removeUser",
|
|
52969
|
-
value: function removeUser() {
|
|
52970
|
-
this.removeData('user');
|
|
52971
|
-
}
|
|
52972
|
-
}, {
|
|
52973
|
-
key: "jwtDecode",
|
|
52974
|
-
value: function jwtDecode(token) {
|
|
52975
|
-
if (!token) {
|
|
52976
|
-
console.error('token为空 jwt解析token出错');
|
|
52977
|
-
return null;
|
|
52978
|
-
}
|
|
52979
|
-
try {
|
|
52980
|
-
return o(token);
|
|
52981
|
-
} catch (e) {
|
|
52982
|
-
console.error('jwt解析token出错', token, e);
|
|
52983
|
-
return null;
|
|
52984
|
-
}
|
|
52985
|
-
}
|
|
52986
|
-
// // 产品运营中心token
|
|
52987
|
-
// {
|
|
52988
|
-
// "LoginUser": {
|
|
52989
|
-
// "appId": "100",
|
|
52990
|
-
// "tenantCode": "1656652",
|
|
52991
|
-
// "productCode": "100000000000000000",
|
|
52992
|
-
// "productVersionCode": null,
|
|
52993
|
-
// "clientTypeCode": null,
|
|
52994
|
-
// "userCode": "6",
|
|
52995
|
-
// "accountCode": "6",
|
|
52996
|
-
// "username": "庄焕滨",
|
|
52997
|
-
// "tokenId": "bd69b4a4-5376-47cd-91c3-f1e1576440e5",
|
|
52998
|
-
// "appCodes": null,
|
|
52999
|
-
// "appCode": null,
|
|
53000
|
-
// "platRoleCodes": ["1637696814759153664"],
|
|
53001
|
-
// "metamodeltype": 2,
|
|
53002
|
-
// "orgCode": "1751852081616130048",
|
|
53003
|
-
// "centerRole": true
|
|
53004
|
-
// },
|
|
53005
|
-
// "TwoFactorAuthCode": "6f56da978dffe31a3b03a56c446f9467",
|
|
53006
|
-
// "exp": 1751694745
|
|
53007
|
-
// }
|
|
53008
|
-
// // 租户token
|
|
53009
|
-
// {
|
|
53010
|
-
// "exp": 1720161305,
|
|
53011
|
-
// "LoginUser": {
|
|
53012
|
-
// "accountInfoCode": "1803686723986010112",
|
|
53013
|
-
// "accountCode": "1803686724107644928",
|
|
53014
|
-
// "tenantCode": "3000911",
|
|
53015
|
-
// "productCode": "100000000000000000",
|
|
53016
|
-
// "productVersionCode": "30000000000000911",
|
|
53017
|
-
// "clientTypeCode": 1,
|
|
53018
|
-
// "tokenId": "8614059e-69a5-4e1e-a948-f2ef680d0dd5",
|
|
53019
|
-
// "orgCode": "1803686397149065216",
|
|
53020
|
-
// "userInfoId": "1806591894588108800",
|
|
53021
|
-
// "userInfoName": "woOUQJEAAAn4r5-7jffaxad6yotbEZ5A",
|
|
53022
|
-
// "positionCode": "1803686397304254473",
|
|
53023
|
-
// "positionName": "系统管理员-勿删",
|
|
53024
|
-
// "memberCode": "1806591894659411968",
|
|
53025
|
-
// "refPositionCode": "1300728614534385664",
|
|
53026
|
-
// "categoryCode": "",
|
|
53027
|
-
// "orgStructTypeId": "1",
|
|
53028
|
-
// "userName": null,
|
|
53029
|
-
// "userName1": "woOUQJEAAAn4r5-7jffaxad6yotbEZ5A",
|
|
53030
|
-
// "userName2": null,
|
|
53031
|
-
// "userName3": null,
|
|
53032
|
-
// "tenantName": "智慧100-企微版-V9.1.1开发租户",
|
|
53033
|
-
// "appCode": "sales",
|
|
53034
|
-
// "appCodes": [
|
|
53035
|
-
// "promotion",
|
|
53036
|
-
// "distribution",
|
|
53037
|
-
// "sales"
|
|
53038
|
-
// ],
|
|
53039
|
-
// "subPdCodes": [
|
|
53040
|
-
// "sfa",
|
|
53041
|
-
// "dms",
|
|
53042
|
-
// "pmm",
|
|
53043
|
-
// "tpm",
|
|
53044
|
-
// "ai"
|
|
53045
|
-
// ],
|
|
53046
|
-
// "codepath": "1.1803686395634921472.1803686397149065216.",
|
|
53047
|
-
// "isleaforg": "true",
|
|
53048
|
-
// "metamodeltype": 1,
|
|
53049
|
-
// "isSmsLogin": false
|
|
53050
|
-
// }
|
|
53051
|
-
// }
|
|
53052
|
-
// 查询token所属登录角色
|
|
53053
|
-
// tenant: 普通租户登录 默认
|
|
53054
|
-
// center: 产品运营中心登录 单点登录时只带 token 没带 refreshtoken 和 tokenexpires
|
|
53055
|
-
}, {
|
|
53056
|
-
key: "getLoginRole",
|
|
53057
|
-
value: function getLoginRole(token) {
|
|
53058
|
-
var loginRole = 'tenant'; // center | tenant
|
|
53059
|
-
if (token) {
|
|
53060
|
-
var _jwtInfo$LoginUser, _jwtInfo$LoginUser2;
|
|
53061
|
-
var jwtInfo = this.jwtDecode(token);
|
|
53062
|
-
if (jwtInfo !== null && jwtInfo !== void 0 && (_jwtInfo$LoginUser = jwtInfo.LoginUser) !== null && _jwtInfo$LoginUser !== void 0 && _jwtInfo$LoginUser.centerRole || (jwtInfo === null || jwtInfo === void 0 || (_jwtInfo$LoginUser2 = jwtInfo.LoginUser) === null || _jwtInfo$LoginUser2 === void 0 ? void 0 : _jwtInfo$LoginUser2.appId) === '100') {
|
|
53063
|
-
// 产品运营中心登录
|
|
53064
|
-
loginRole = 'center';
|
|
53065
|
-
}
|
|
53066
|
-
}
|
|
53067
|
-
return loginRole;
|
|
53068
|
-
}
|
|
53069
|
-
// 检测当前用户是否登录状态
|
|
53070
|
-
}, {
|
|
53071
|
-
key: "checkLogin",
|
|
53072
|
-
value: function checkLogin() {
|
|
53073
|
-
var haslogged = false;
|
|
53074
|
-
var token = this.getToken();
|
|
53075
|
-
if (token) {
|
|
53076
|
-
if (this.getLoginRole(token) === 'center') {
|
|
53077
|
-
haslogged = this.checkTokenLogin(token);
|
|
53078
|
-
} else {
|
|
53079
|
-
var refreshtoken = this.getRefreshToken();
|
|
53080
|
-
var tokenexpires = this.getTokenExpires();
|
|
53081
|
-
var now = Date.now();
|
|
53082
|
-
if (token && refreshtoken && tokenexpires && Number(tokenexpires) > now) {
|
|
53083
|
-
haslogged = this.checkTokenLogin(token);
|
|
53084
|
-
}
|
|
53085
|
-
}
|
|
53086
|
-
}
|
|
53087
|
-
return haslogged;
|
|
53088
|
-
}
|
|
53089
|
-
// 检测token是否过期
|
|
53090
|
-
}, {
|
|
53091
|
-
key: "checkTokenLogin",
|
|
53092
|
-
value: function checkTokenLogin(token) {
|
|
53093
|
-
var haslogged = false;
|
|
53094
|
-
if (token) {
|
|
53095
|
-
var now = Date.now();
|
|
53096
|
-
var jwtInfo = this.jwtDecode(token);
|
|
53097
|
-
if (jwtInfo !== null && jwtInfo !== void 0 && jwtInfo.exp) {
|
|
53098
|
-
haslogged = Number(jwtInfo.exp + '000') > now;
|
|
53099
|
-
} else {
|
|
53100
|
-
haslogged = false;
|
|
53101
|
-
}
|
|
53102
|
-
}
|
|
53103
|
-
return haslogged;
|
|
53104
|
-
}
|
|
53105
|
-
// 接口请求回来的 userInfo 有 functioncodes 以便做权限校验
|
|
53106
|
-
// 有可能是中心角色请求失败 兼容不报错
|
|
53107
|
-
}, {
|
|
53108
|
-
key: "getAndSetUserInfo",
|
|
53109
|
-
value: function () {
|
|
53110
|
-
var _getAndSetUserInfo = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee3() {
|
|
53111
|
-
var accountinfo;
|
|
53112
|
-
return _regeneratorRuntime$1().wrap(function _callee3$(_context4) {
|
|
53113
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
53114
|
-
case 0:
|
|
53115
|
-
_context4.prev = 0;
|
|
53116
|
-
_context4.next = 3;
|
|
53117
|
-
return normalAxios.post('/api/teapi/rolepermission/account/getaccountinfo', {
|
|
53118
|
-
positionid: this.getUser('positioncode') || '',
|
|
53119
|
-
deviceinfo: '',
|
|
53120
|
-
sysversion: '',
|
|
53121
|
-
clientversion: ''
|
|
53122
|
-
}).then(function (res) {
|
|
53123
|
-
if (res.code === 200 && res.data) {
|
|
53124
|
-
return res.data;
|
|
53125
|
-
} else {
|
|
53126
|
-
return null;
|
|
53127
|
-
}
|
|
53128
|
-
});
|
|
53129
|
-
case 3:
|
|
53130
|
-
accountinfo = _context4.sent;
|
|
53131
|
-
if (accountinfo) {
|
|
53132
|
-
this.setUser(accountinfo);
|
|
53133
|
-
}
|
|
53134
|
-
_context4.next = 11;
|
|
53135
|
-
break;
|
|
53136
|
-
case 7:
|
|
53137
|
-
_context4.prev = 7;
|
|
53138
|
-
_context4.t0 = _context4["catch"](0);
|
|
53139
|
-
console.error(_context4.t0);
|
|
53140
|
-
console.warn('获取用户信息失败,当前您登录的帐号可能为非标准租户帐号。');
|
|
53141
|
-
case 11:
|
|
53142
|
-
case "end":
|
|
53143
|
-
return _context4.stop();
|
|
53144
|
-
}
|
|
53145
|
-
}, _callee3, this, [[0, 7]]);
|
|
53146
|
-
}));
|
|
53147
|
-
function getAndSetUserInfo() {
|
|
53148
|
-
return _getAndSetUserInfo.apply(this, arguments);
|
|
53149
|
-
}
|
|
53150
|
-
return getAndSetUserInfo;
|
|
53151
|
-
}()
|
|
53152
|
-
}, {
|
|
53153
|
-
key: "formatTenant",
|
|
53154
|
-
value: function formatTenant(tenant) {
|
|
53155
|
-
if (!tenant) {
|
|
53156
|
-
return null;
|
|
53157
|
-
}
|
|
53158
|
-
var cloundTagMap = ['storage', 'storage-1d', 'storage-1y', 'storage-3m'];
|
|
53159
|
-
var result = {};
|
|
53160
|
-
for (var _i = 0, _cloundTagMap = cloundTagMap; _i < _cloundTagMap.length; _i++) {
|
|
53161
|
-
var keyItem = _cloundTagMap[_i];
|
|
53162
|
-
var _cloudServ = tenant.cloudserv[keyItem];
|
|
53163
|
-
if (_cloudServ) {
|
|
53164
|
-
result[keyItem] = {
|
|
53165
|
-
cloudserv_storage_provider: _cloudServ.provider,
|
|
53166
|
-
cloudserv_storage_storagebucket: _cloudServ.storagebucket,
|
|
53167
|
-
cloudserv_storage_storageendpoint: _cloudServ.storageendpoint,
|
|
53168
|
-
cloudserv_storage_storageurl: _cloudServ.storageurl,
|
|
53169
|
-
cloudserv_storage_accesskeyid: _cloudServ.accesskeyid,
|
|
53170
|
-
cloudserv_storage_region: _cloudServ.region
|
|
53171
|
-
};
|
|
53172
|
-
}
|
|
53173
|
-
}
|
|
53174
|
-
if (Object.keys(result).length === 0) {
|
|
53175
|
-
return null;
|
|
53176
|
-
}
|
|
53177
|
-
return result;
|
|
53178
|
-
}
|
|
53179
|
-
}, {
|
|
53180
|
-
key: "getAndSetTenant",
|
|
53181
|
-
value: function () {
|
|
53182
|
-
var _getAndSetTenant = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee4(tenantcode) {
|
|
53183
|
-
var tenantsRes, tenant, normalizedTenant;
|
|
53184
|
-
return _regeneratorRuntime$1().wrap(function _callee4$(_context5) {
|
|
53185
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
53186
|
-
case 0:
|
|
53187
|
-
_context5.prev = 0;
|
|
53188
|
-
_context5.next = 3;
|
|
53189
|
-
return normalAxios.get('/api/auth/tenantlist', {}).then(function (res) {
|
|
53190
|
-
var _res$data;
|
|
53191
|
-
return res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.tenants;
|
|
53192
|
-
});
|
|
53193
|
-
case 3:
|
|
53194
|
-
tenantsRes = _context5.sent;
|
|
53195
|
-
tenant = null;
|
|
53196
|
-
if (tenantsRes !== null && tenantsRes !== void 0 && tenantsRes.length) {
|
|
53197
|
-
if (!tenantcode) {
|
|
53198
|
-
tenant = tenantsRes[0];
|
|
53199
|
-
} else {
|
|
53200
|
-
tenant = tenantsRes.find(function (item) {
|
|
53201
|
-
return item.code === tenantcode;
|
|
53202
|
-
}) || null;
|
|
53203
|
-
}
|
|
53204
|
-
}
|
|
53205
|
-
if (!tenant) {
|
|
53206
|
-
lsProxy.removeItem('tenant');
|
|
53207
|
-
cloudServ.remove();
|
|
53208
|
-
} else {
|
|
53209
|
-
lsProxy.setItem('tenant', JSON.stringify(tenant));
|
|
53210
|
-
normalizedTenant = this.formatTenant(tenant);
|
|
53211
|
-
if (normalizedTenant) {
|
|
53212
|
-
cloudServ.set(normalizedTenant);
|
|
53213
|
-
}
|
|
53214
|
-
}
|
|
53215
|
-
_context5.next = 13;
|
|
53216
|
-
break;
|
|
53217
|
-
case 9:
|
|
53218
|
-
_context5.prev = 9;
|
|
53219
|
-
_context5.t0 = _context5["catch"](0);
|
|
53220
|
-
console.error(_context5.t0);
|
|
53221
|
-
console.warn('获取租户信息失败,当前您登录的帐号可能为非标准租户帐号。');
|
|
53222
|
-
case 13:
|
|
53223
|
-
case "end":
|
|
53224
|
-
return _context5.stop();
|
|
53405
|
+
var getSpuContainerType = /*#__PURE__*/function () {
|
|
53406
|
+
var _ref = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
|
|
53407
|
+
var _window2, _window3;
|
|
53408
|
+
return _regeneratorRuntime$1().wrap(function _callee$(_context) {
|
|
53409
|
+
while (1) switch (_context.prev = _context.next) {
|
|
53410
|
+
case 0:
|
|
53411
|
+
if (!((_window2 = window) !== null && _window2 !== void 0 && (_window2 = _window2.aPaaS) !== null && _window2 !== void 0 && _window2.getPhoto)) {
|
|
53412
|
+
_context.next = 4;
|
|
53413
|
+
break;
|
|
53225
53414
|
}
|
|
53226
|
-
|
|
53227
|
-
|
|
53228
|
-
|
|
53229
|
-
|
|
53230
|
-
|
|
53231
|
-
return getAndSetTenant;
|
|
53232
|
-
}() // 单点登录
|
|
53233
|
-
}, {
|
|
53234
|
-
key: "singleLogin",
|
|
53235
|
-
value: function () {
|
|
53236
|
-
var _singleLogin = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee5(query) {
|
|
53237
|
-
var flag, token, refreshtoken, tokenexpires, envname, context, isneedlogin, loginRole;
|
|
53238
|
-
return _regeneratorRuntime$1().wrap(function _callee5$(_context6) {
|
|
53239
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
53240
|
-
case 0:
|
|
53241
|
-
query = cloneDeep$1(query);
|
|
53242
|
-
flag = false; // 是否登录成功
|
|
53243
|
-
token = query.token;
|
|
53244
|
-
refreshtoken = query.refreshtoken;
|
|
53245
|
-
tokenexpires = query.tokenexpires;
|
|
53246
|
-
envname = query.envname;
|
|
53247
|
-
context = query.context;
|
|
53248
|
-
if (!this.checkTokenLogin(token)) {
|
|
53249
|
-
_context6.next = 25;
|
|
53250
|
-
break;
|
|
53251
|
-
}
|
|
53252
|
-
isneedlogin = true; // 是否需要走单点登录流程
|
|
53253
|
-
loginRole = this.getLoginRole(token);
|
|
53254
|
-
if (loginRole === 'center') {
|
|
53255
|
-
// 如果本地已经登录 且 query 登录参数与本地一致 说明是刚登录没多久【token也没刷新过】 视为已经登录 不需再走单点登录流程
|
|
53256
|
-
// 之所以不强制校验 refreshtoken tokenexpires 是因为安装卸载配置页面有可能放在产品运营中心 没有这两字段
|
|
53257
|
-
if (this.checkLogin() && token === this.getToken()) {
|
|
53258
|
-
isneedlogin = false;
|
|
53259
|
-
flag = true;
|
|
53260
|
-
}
|
|
53261
|
-
} else {
|
|
53262
|
-
// 如果本地已经登录 且 query 登录参数与本地一致 说明是刚登录没多久【token也没刷新过】 视为已经登录 不需再走单点登录流程
|
|
53263
|
-
if (this.checkLogin() && token === this.getToken() && refreshtoken === this.getRefreshToken() && tokenexpires === this.getTokenExpires()) {
|
|
53264
|
-
isneedlogin = false;
|
|
53265
|
-
flag = true;
|
|
53266
|
-
}
|
|
53267
|
-
}
|
|
53268
|
-
if (!isneedlogin) {
|
|
53269
|
-
_context6.next = 23;
|
|
53270
|
-
break;
|
|
53271
|
-
}
|
|
53272
|
-
this.setToken(token);
|
|
53273
|
-
this.setUserByToken(token); // 解析token为用户信息存入
|
|
53274
|
-
refreshtoken ? this.setRefreshToken(refreshtoken) : this.removeRefreshToken();
|
|
53275
|
-
tokenexpires ? this.setTokenExpires(tokenexpires) : this.removeTokenExpires();
|
|
53276
|
-
envname ? this.setQueryEnvname(envname) : this.removeQueryEnvname();
|
|
53277
|
-
// context 上下文字段 产品运营中心安装 卸载 配置 和 产品配置中心业务配置 页面需要用到
|
|
53278
|
-
// web 端有传 app没传 需要做兼容
|
|
53279
|
-
context && lsProxy.setItem('context', decodeURIComponent(context));
|
|
53280
|
-
// 这里兼容报错
|
|
53281
|
-
_context6.next = 20;
|
|
53282
|
-
return this.getAndSetTenant();
|
|
53283
|
-
case 20:
|
|
53284
|
-
_context6.next = 22;
|
|
53285
|
-
return this.getAndSetUserInfo();
|
|
53286
|
-
case 22:
|
|
53287
|
-
flag = true;
|
|
53288
|
-
case 23:
|
|
53289
|
-
_context6.next = 27;
|
|
53290
|
-
break;
|
|
53291
|
-
case 25:
|
|
53292
|
-
flag = false;
|
|
53293
|
-
console.error('没传 token 或所传 token 已过期,无法单点登录。');
|
|
53294
|
-
case 27:
|
|
53295
|
-
// 单点登录后 无论是否成功 都需要删除 query 中相关参数
|
|
53296
|
-
token && delete query.token;
|
|
53297
|
-
refreshtoken && delete query.refreshtoken;
|
|
53298
|
-
tokenexpires && delete query.tokenexpires;
|
|
53299
|
-
envname && delete query.envname;
|
|
53300
|
-
context && delete query.context;
|
|
53301
|
-
// debugger
|
|
53302
|
-
return _context6.abrupt("return", {
|
|
53303
|
-
flag: flag,
|
|
53304
|
-
query: query
|
|
53305
|
-
});
|
|
53306
|
-
case 33:
|
|
53307
|
-
case "end":
|
|
53308
|
-
return _context6.stop();
|
|
53415
|
+
return _context.abrupt("return", 'app');
|
|
53416
|
+
case 4:
|
|
53417
|
+
if (!((_window3 = window) !== null && _window3 !== void 0 && (_window3 = _window3.Module) !== null && _window3 !== void 0 && _window3.spuContainerType)) {
|
|
53418
|
+
_context.next = 8;
|
|
53419
|
+
break;
|
|
53309
53420
|
}
|
|
53310
|
-
|
|
53311
|
-
|
|
53312
|
-
|
|
53313
|
-
|
|
53421
|
+
return _context.abrupt("return", window.Module.spuContainerType);
|
|
53422
|
+
case 8:
|
|
53423
|
+
return _context.abrupt("return", '');
|
|
53424
|
+
case 9:
|
|
53425
|
+
case "end":
|
|
53426
|
+
return _context.stop();
|
|
53314
53427
|
}
|
|
53315
|
-
|
|
53316
|
-
|
|
53317
|
-
|
|
53318
|
-
|
|
53428
|
+
}, _callee);
|
|
53429
|
+
}));
|
|
53430
|
+
return function getSpuContainerType() {
|
|
53431
|
+
return _ref.apply(this, arguments);
|
|
53432
|
+
};
|
|
53319
53433
|
}();
|
|
53320
|
-
var
|
|
53434
|
+
var isInApp = function isInApp() {
|
|
53435
|
+
var _window4, _window5;
|
|
53436
|
+
if ((_window4 = window) !== null && _window4 !== void 0 && (_window4 = _window4.aPaaS) !== null && _window4 !== void 0 && _window4.getPhoto || (_window5 = window) !== null && _window5 !== void 0 && (_window5 = _window5.top) !== null && _window5 !== void 0 && (_window5 = _window5.aPaaS) !== null && _window5 !== void 0 && _window5.getPhoto) {
|
|
53437
|
+
return true;
|
|
53438
|
+
} else {
|
|
53439
|
+
return false;
|
|
53440
|
+
}
|
|
53441
|
+
};
|
|
53321
53442
|
|
|
53322
53443
|
// import SpuLoadding from './loadding'
|
|
53323
53444
|
// import SpuExpandexp from './expandexp'
|
|
@@ -60569,10 +60690,12 @@ function _initTest() {
|
|
|
60569
60690
|
// }
|
|
60570
60691
|
// // SPUWebPlugin.install = install
|
|
60571
60692
|
// // SPUWebPlugin.version = version
|
|
60693
|
+
// 基于部署路径查出 modulekey moduleversion
|
|
60694
|
+
var arr = location.pathname.split('/');
|
|
60572
60695
|
var globalOptions = {
|
|
60573
|
-
|
|
60574
|
-
|
|
60575
|
-
moduleversion: '
|
|
60696
|
+
modulename: '',
|
|
60697
|
+
modulekey: arr[1] || '',
|
|
60698
|
+
moduleversion: arr[2] || '',
|
|
60576
60699
|
storageproxyprefix: '',
|
|
60577
60700
|
router: null
|
|
60578
60701
|
};
|
|
@@ -60656,13 +60779,13 @@ var SPUWebPlugin = {
|
|
|
60656
60779
|
install: install,
|
|
60657
60780
|
version: version
|
|
60658
60781
|
};
|
|
60782
|
+
var updateToken = login.updateToken.bind(login);
|
|
60659
60783
|
var getToken = login.getToken.bind(login);
|
|
60660
60784
|
var getTokenExpires = login.getTokenExpires.bind(login);
|
|
60661
60785
|
var getRefreshToken = login.getRefreshToken.bind(login);
|
|
60662
60786
|
var getUser = login.getUser.bind(login);
|
|
60663
60787
|
var checkLogin = login.checkLogin.bind(login);
|
|
60664
60788
|
var singleLogin = login.singleLogin.bind(login);
|
|
60665
|
-
var startRefreshtoken = login.startRefreshtoken.bind(login);
|
|
60666
60789
|
var wxworkSuite = {
|
|
60667
60790
|
JSSDK: jssdk,
|
|
60668
60791
|
isWxworkSuiteTenant: isWxworkSuiteTenant,
|
|
@@ -60674,7 +60797,8 @@ var Module = {
|
|
|
60674
60797
|
getModuleData: core.getModuleData.bind(core),
|
|
60675
60798
|
getEnvname: login.getEnvname.bind(login),
|
|
60676
60799
|
getEnvData: core.getEnvData.bind(core),
|
|
60677
|
-
checkModule: core.checkModule.bind(core)
|
|
60800
|
+
checkModule: core.checkModule.bind(core),
|
|
60801
|
+
getSpuContainerType: getSpuContainerType
|
|
60678
60802
|
};
|
|
60679
60803
|
|
|
60680
|
-
export { AMapLoader, Module, normalAxios as apaasAxios, normalAxios as axios, checkLogin, index as components, SPUWebPlugin as default, downloadService, expandexp, functionCheck, getDistance, getLocation, getRefreshToken, getToken, getTokenExpires, getUniqueid, getUser, v4 as getUuid, globalConfig, globalOptions, lsProxy, setTitle, singleLogin, spuAxios, spuConfig, ssProxy,
|
|
60804
|
+
export { AMapLoader, Module, normalAxios as apaasAxios, normalAxios as axios, checkLogin, index as components, SPUWebPlugin as default, downloadService, expandexp, functionCheck, getDistance, getLocation, getRefreshToken, getToken, getTokenExpires, getUniqueid, getUser, v4 as getUuid, globalConfig, globalOptions, isInApp, lsProxy, setTitle, singleLogin, spuAxios, spuConfig, ssProxy, updateToken, uploadService, wxworkSuite };
|