@smart100/spu-web-plugin 0.0.25 → 0.0.27

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 CHANGED
@@ -76,6 +76,7 @@ export const spuAxios: any
76
76
  export const apaasAxios: any
77
77
  export const axios: any
78
78
  export const spuConfig: any
79
+ export const globalConfig: any
79
80
  export const downloadService: IDownloadService
80
81
  export const uploadService: IUploadService
81
82
  export const getUniqueid: () => string
@@ -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.25";
711
+ var version = "0.0.27";
712
712
 
713
713
  /** Detect free variable `global` from Node.js. */
714
714
  var freeGlobal$2 = typeof global == 'object' && global && global.Object === Object && global;
@@ -12353,7 +12353,8 @@ var WxworksuiteTree = /*#__PURE__*/function (_LitElement) {
12353
12353
  // 判断是否开启企微通信录支持,默认不开启
12354
12354
  _this.iswwopendata = false;
12355
12355
  // 控制通信录转移类型
12356
- _this.wwopendatatype = ''; // userName | departmentName | express
12356
+ _this.wwopendatatype = ''; // userName | departmentName | expression
12357
+ _this.valuekey = 'id'; // 默认id 也可定义别的属性值比如 codepath(被定义的属性值必须唯一)
12357
12358
  _this.ismulselect = false;
12358
12359
  _this.displaytype = 'mobile'; // web | mobile
12359
12360
  _this.issearch = true;
@@ -12601,7 +12602,7 @@ var WxworksuiteTree = /*#__PURE__*/function (_LitElement) {
12601
12602
  query_type = 1;
12602
12603
  } else if (this.wwopendatatype === 'departmentName') {
12603
12604
  query_type = 2;
12604
- } else if (this.wwopendatatype === 'express') {
12605
+ } else if (this.wwopendatatype === 'expression') {
12605
12606
  query_type = 0;
12606
12607
  }
12607
12608
  return normalAxios$1.post('/api/wxwork/contact/search', {
@@ -12643,8 +12644,8 @@ var WxworksuiteTree = /*#__PURE__*/function (_LitElement) {
12643
12644
  }
12644
12645
  }, {
12645
12646
  key: "getValue",
12646
- value: function getValue() {
12647
- var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'id';
12647
+ value: function getValue(type) {
12648
+ var _this3 = this;
12648
12649
  if (this.ismulselect) {
12649
12650
  var arr = this._list.filter(function (item) {
12650
12651
  return item.checkstate === '1';
@@ -12670,63 +12671,99 @@ var WxworksuiteTree = /*#__PURE__*/function (_LitElement) {
12670
12671
  return !(item !== null && item !== void 0 && item.parent);
12671
12672
  });
12672
12673
  }
12673
- if (type === 'id') {
12674
+ if (!type) {
12674
12675
  var _arr;
12675
12676
  return (_arr = arr) !== null && _arr !== void 0 && _arr.length ? arr.map(function (item) {
12676
- return item.id;
12677
+ return item[_this3.valuekey];
12677
12678
  }) : [];
12678
12679
  } else if (type === 'name') {
12679
12680
  var _arr2;
12680
12681
  return (_arr2 = arr) !== null && _arr2 !== void 0 && _arr2.length ? arr.map(function (item) {
12681
12682
  return item.name;
12682
12683
  }) : [];
12683
- } else {
12684
+ } else if (type === 'fullvalue') {
12684
12685
  var _arr3;
12685
12686
  return (_arr3 = arr) !== null && _arr3 !== void 0 && _arr3.length ? cloneDeep(arr) : [];
12687
+ } else {
12688
+ var _arr4;
12689
+ return (_arr4 = arr) !== null && _arr4 !== void 0 && _arr4.length ? arr.map(function (item) {
12690
+ return item[type];
12691
+ }) : [];
12686
12692
  }
12687
12693
  } else {
12688
12694
  var obj = this._list.find(function (item) {
12689
12695
  return item.isselected;
12690
12696
  });
12691
- if (type === 'id') {
12692
- return obj ? obj.id : '';
12697
+ if (!type) {
12698
+ return obj ? obj[this.valuekey] : '';
12693
12699
  } else if (type === 'name') {
12694
12700
  return obj ? obj.name : '';
12695
- } else {
12701
+ } else if (type === 'fullvalue') {
12696
12702
  return obj ? cloneDeep(obj) : null;
12703
+ } else {
12704
+ return obj ? obj[type] : '';
12705
+ }
12706
+ }
12707
+ }
12708
+ }, {
12709
+ key: "_transValuekeyValueToIdValue",
12710
+ value: function _transValuekeyValueToIdValue(value) {
12711
+ var _this4 = this;
12712
+ if (this.valuekey === 'id') {
12713
+ return value;
12714
+ } else {
12715
+ if (Array.isArray(value)) {
12716
+ return value.map(function (item) {
12717
+ var a = _this4._list.find(function (item2) {
12718
+ return item2[_this4.valuekey] === item;
12719
+ });
12720
+ return (a === null || a === void 0 ? void 0 : a.id) || '';
12721
+ });
12722
+ } else {
12723
+ if (value) {
12724
+ var a = this._list.find(function (item2) {
12725
+ return item2[_this4.valuekey] === value;
12726
+ });
12727
+ return (a === null || a === void 0 ? void 0 : a.id) || '';
12728
+ } else {
12729
+ return value;
12730
+ }
12697
12731
  }
12698
12732
  }
12699
12733
  }
12700
12734
  }, {
12701
12735
  key: "setValue",
12702
12736
  value: function setValue(value) {
12703
- var _this3 = this;
12737
+ var _this5 = this;
12738
+ var idValue = this._transValuekeyValueToIdValue(value);
12704
12739
  // debugger
12705
12740
  if (this.ismulselect) {
12706
12741
  this._list.forEach(function (item) {
12707
12742
  item.checkstate = '0';
12708
12743
  });
12709
- (value === null || value === void 0 ? void 0 : value.length) && value.forEach(function (item) {
12710
- _this3._setCheck(item, '1');
12744
+ Array.isArray(idValue) && idValue.forEach(function (item) {
12745
+ _this5._setCheck(item, '1');
12711
12746
  });
12712
12747
  this._updateTemplate();
12713
12748
  } else {
12714
- this._setSelect(value, true);
12749
+ this._setSelect(idValue, true);
12715
12750
  this._updateTemplate();
12716
12751
  }
12717
12752
  }
12718
12753
  }, {
12719
12754
  key: "setCheck",
12720
- value: function setCheck(id) {
12721
- var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
12722
- this._setCheck(id, value ? '1' : '0');
12755
+ value: function setCheck(value) {
12756
+ var flag = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
12757
+ var idValue = this._transValuekeyValueToIdValue(value);
12758
+ this._setCheck(idValue, flag ? '1' : '0');
12723
12759
  this._updateTemplate();
12724
12760
  }
12725
12761
  }, {
12726
12762
  key: "setSelect",
12727
- value: function setSelect(id) {
12728
- var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
12729
- this._setSelect(id, value);
12763
+ value: function setSelect(value) {
12764
+ var flag = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
12765
+ var idValue = this._transValuekeyValueToIdValue(value);
12766
+ this._setSelect(idValue, flag);
12730
12767
  this._updateTemplate();
12731
12768
  }
12732
12769
  }, {
@@ -12735,7 +12772,7 @@ var WxworksuiteTree = /*#__PURE__*/function (_LitElement) {
12735
12772
  var _this$_data,
12736
12773
  _this$_data2,
12737
12774
  _this$_searchlist,
12738
- _this4 = this;
12775
+ _this6 = this;
12739
12776
  return x(_templateObject$3 || (_templateObject$3 = _taggedTemplateLiteral(["\n <div class=", ">\n <!-- <button class=\"demo\" @click=\"", "\">\n _test\n ", "\n </button> -->\n\n ", "\n\n ", "\n </div>\n "])), e$5({
12740
12777
  'tree': true,
12741
12778
  'tree-web': this.displaytype === 'web',
@@ -12745,11 +12782,11 @@ var WxworksuiteTree = /*#__PURE__*/function (_LitElement) {
12745
12782
  }), this._searchvalue ? x(_templateObject4$1 || (_templateObject4$1 = _taggedTemplateLiteral(["\n ", "\n "])), this !== null && this !== void 0 && (_this$_searchlist = this._searchlist) !== null && _this$_searchlist !== void 0 && _this$_searchlist.length ? x(_templateObject5$1 || (_templateObject5$1 = _taggedTemplateLiteral(["\n ", "\n "])), c(this._searchlist, function (item) {
12746
12783
  return item.id;
12747
12784
  }, function (item, index) {
12748
- return x(_templateObject6$1 || (_templateObject6$1 = _taggedTemplateLiteral(["\n <wxworksuite-treenode\n displaytype=\"", "\"\n expandmode=\"", "\"\n expandicon=\"", "\"\n .node=\"", "\"\n .isonelevel=\"", "\"\n .isrenderchildren=\"", "\"\n .iswwopendata=\"", "\"\n wwopendatatype=\"", "\"\n .ismulselect=\"", "\"\n .updatepoint=\"", "\"\n @toggle=\"", "\"\n >\n </wxworksuite-treenode>\n "])), _this4.displaytype, _this4.expandmode, _this4.expandicon, item, true, false, _this4.iswwopendata, _this4.wwopendatatype, _this4.ismulselect, _this4._updatepoint, _this4._handleToggle);
12785
+ return x(_templateObject6$1 || (_templateObject6$1 = _taggedTemplateLiteral(["\n <wxworksuite-treenode\n displaytype=\"", "\"\n expandmode=\"", "\"\n expandicon=\"", "\"\n .node=\"", "\"\n .isonelevel=\"", "\"\n .isrenderchildren=\"", "\"\n .iswwopendata=\"", "\"\n wwopendatatype=\"", "\"\n .ismulselect=\"", "\"\n .updatepoint=\"", "\"\n @toggle=\"", "\"\n >\n </wxworksuite-treenode>\n "])), _this6.displaytype, _this6.expandmode, _this6.expandicon, item, true, false, _this6.iswwopendata, _this6.wwopendatatype, _this6.ismulselect, _this6._updatepoint, _this6._handleToggle);
12749
12786
  })) : x(_templateObject7$1 || (_templateObject7$1 = _taggedTemplateLiteral(["\n <div class=\"tree-none\">\u6682\u65E0\u641C\u7D22\u7ED3\u679C</div>\n "])))) : x(_templateObject8$1 || (_templateObject8$1 = _taggedTemplateLiteral(["\n ", "\n "])), c(this._data, function (item) {
12750
12787
  return item.id;
12751
12788
  }, function (item, index) {
12752
- return x(_templateObject9$1 || (_templateObject9$1 = _taggedTemplateLiteral(["\n <wxworksuite-treenode\n displaytype=\"", "\"\n expandmode=\"", "\"\n expandicon=\"", "\"\n .node=\"", "\"\n .isonelevel=\"", "\"\n .isrenderchildren=\"", "\"\n .iswwopendata=\"", "\"\n wwopendatatype=\"", "\"\n .ismulselect=\"", "\"\n .updatepoint=\"", "\"\n @toggle=\"", "\"\n >\n </wxworksuite-treenode>\n "])), _this4.displaytype, _this4.expandmode, _this4.expandicon, item, _this4._isonelevel, true, _this4.iswwopendata, _this4.wwopendatatype, _this4.ismulselect, _this4._updatepoint, _this4._handleToggle);
12789
+ return x(_templateObject9$1 || (_templateObject9$1 = _taggedTemplateLiteral(["\n <wxworksuite-treenode\n displaytype=\"", "\"\n expandmode=\"", "\"\n expandicon=\"", "\"\n .node=\"", "\"\n .isonelevel=\"", "\"\n .isrenderchildren=\"", "\"\n .iswwopendata=\"", "\"\n wwopendatatype=\"", "\"\n .ismulselect=\"", "\"\n .updatepoint=\"", "\"\n @toggle=\"", "\"\n >\n </wxworksuite-treenode>\n "])), _this6.displaytype, _this6.expandmode, _this6.expandicon, item, _this6._isonelevel, true, _this6.iswwopendata, _this6.wwopendatatype, _this6.ismulselect, _this6._updatepoint, _this6._handleToggle);
12753
12790
  }))) : x(_templateObject10$1 || (_templateObject10$1 = _taggedTemplateLiteral(["<div class=\"tree-none\">\u6682\u65E0\u6570\u636E</div>"]))));
12754
12791
  }
12755
12792
  }], [{
@@ -12774,6 +12811,9 @@ __decorate([n$1({
12774
12811
  __decorate([n$1({
12775
12812
  type: String
12776
12813
  })], WxworksuiteTree.prototype, "wwopendatatype", void 0);
12814
+ __decorate([n$1({
12815
+ type: String
12816
+ })], WxworksuiteTree.prototype, "valuekey", void 0);
12777
12817
  __decorate([n$1({
12778
12818
  type: Boolean
12779
12819
  })], WxworksuiteTree.prototype, "ismulselect", void 0);
@@ -13322,7 +13362,9 @@ var WxworksuitePluginInstall = function WxworksuitePluginInstall(options) {
13322
13362
  console.log('@smart100/wxworksuite-plugin install');
13323
13363
  console.log('@smart100/wxworksuite-plugin userOptions', options);
13324
13364
  console.log('@smart100/wxworksuite-plugin globalOptions', globalOptions$1);
13325
- // console.error('test')
13365
+ // setTimeout(() => {
13366
+ // console.error('@smart100/wxworksuite-plugin change')
13367
+ // }, 3000)
13326
13368
  initAxios$1(globalOptions$1);
13327
13369
  for (var x in components) {
13328
13370
  components[x].register();
@@ -17827,11 +17869,12 @@ var SpuConfig = /*#__PURE__*/function () {
17827
17869
  _classCallCheck$1(this, SpuConfig);
17828
17870
  _defineProperty$1(this, "isload", false);
17829
17871
  _defineProperty$1(this, "cache", []);
17872
+ _defineProperty$1(this, "getPro", null);
17830
17873
  }
17831
17874
  _createClass$1(SpuConfig, [{
17832
- key: "get",
17875
+ key: "getFun",
17833
17876
  value: function () {
17834
- var _get = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee(dataid) {
17877
+ var _getFun = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
17835
17878
  var res, _res$data;
17836
17879
  return _regeneratorRuntime$1().wrap(function _callee$(_context) {
17837
17880
  while (1) switch (_context.prev = _context.next) {
@@ -17862,33 +17905,61 @@ var SpuConfig = /*#__PURE__*/function () {
17862
17905
  case 11:
17863
17906
  this.isload = true;
17864
17907
  case 12:
17908
+ case "end":
17909
+ return _context.stop();
17910
+ }
17911
+ }, _callee, this, [[1, 8]]);
17912
+ }));
17913
+ function getFun() {
17914
+ return _getFun.apply(this, arguments);
17915
+ }
17916
+ return getFun;
17917
+ }()
17918
+ }, {
17919
+ key: "get",
17920
+ value: function () {
17921
+ var _get = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee2(dataid) {
17922
+ return _regeneratorRuntime$1().wrap(function _callee2$(_context2) {
17923
+ while (1) switch (_context2.prev = _context2.next) {
17924
+ case 0:
17925
+ if (this.isload) {
17926
+ _context2.next = 4;
17927
+ break;
17928
+ }
17929
+ // 兼容同时间发起多个
17930
+ if (!this.getPro) {
17931
+ this.getPro = this.getFun();
17932
+ }
17933
+ _context2.next = 4;
17934
+ return this.getPro;
17935
+ case 4:
17865
17936
  if (!dataid) {
17866
- _context.next = 20;
17937
+ _context2.next = 12;
17867
17938
  break;
17868
17939
  }
17869
17940
  if (!Array.isArray(dataid)) {
17870
- _context.next = 17;
17941
+ _context2.next = 9;
17871
17942
  break;
17872
17943
  }
17873
- return _context.abrupt("return", cloneDeep$1(this.cache.filter(function (item) {
17944
+ return _context2.abrupt("return", cloneDeep$1(this.cache.filter(function (item) {
17874
17945
  return dataid.some(function (item2) {
17875
17946
  return item2 === item.dataid;
17876
17947
  });
17877
17948
  })));
17878
- case 17:
17879
- return _context.abrupt("return", cloneDeep$1(this.cache.find(function (item) {
17949
+ case 9:
17950
+ return _context2.abrupt("return", cloneDeep$1(this.cache.find(function (item) {
17880
17951
  return item.dataid === dataid;
17881
17952
  })));
17882
- case 18:
17883
- _context.next = 21;
17953
+ case 10:
17954
+ _context2.next = 13;
17884
17955
  break;
17885
- case 20:
17886
- return _context.abrupt("return", cloneDeep$1(this.cache));
17887
- case 21:
17956
+ case 12:
17957
+ return _context2.abrupt("return", cloneDeep$1(this.cache));
17958
+ case 13:
17888
17959
  case "end":
17889
- return _context.stop();
17960
+ return _context2.stop();
17890
17961
  }
17891
- }, _callee, this, [[1, 8]]);
17962
+ }, _callee2, this);
17892
17963
  }));
17893
17964
  function get(_x) {
17894
17965
  return _get.apply(this, arguments);
@@ -17903,6 +17974,112 @@ function initSpuConfig(options) {
17903
17974
  }
17904
17975
  var spuConfig = new SpuConfig();
17905
17976
 
17977
+ var GlobalConfig = /*#__PURE__*/function () {
17978
+ function GlobalConfig() {
17979
+ _classCallCheck$1(this, GlobalConfig);
17980
+ _defineProperty$1(this, "isload", false);
17981
+ _defineProperty$1(this, "cache", []);
17982
+ _defineProperty$1(this, "getPro", null);
17983
+ }
17984
+ _createClass$1(GlobalConfig, [{
17985
+ key: "getFun",
17986
+ value: function () {
17987
+ var _getFun = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
17988
+ var res;
17989
+ return _regeneratorRuntime$1().wrap(function _callee$(_context) {
17990
+ while (1) switch (_context.prev = _context.next) {
17991
+ case 0:
17992
+ if (this.isload) {
17993
+ _context.next = 12;
17994
+ break;
17995
+ }
17996
+ _context.prev = 1;
17997
+ _context.next = 4;
17998
+ return normalAxios.post('/api/pemission/rolepermission/globalconfig/getglobalconfigbytype', {
17999
+ configtype: '1'
18000
+ });
18001
+ case 4:
18002
+ res = _context.sent;
18003
+ // console.log(res)
18004
+ // debugger
18005
+ if (res.code === 200) {
18006
+ this.cache = (res === null || res === void 0 ? void 0 : res.data) || [];
18007
+ }
18008
+ _context.next = 11;
18009
+ break;
18010
+ case 8:
18011
+ _context.prev = 8;
18012
+ _context.t0 = _context["catch"](1);
18013
+ console.error(_context.t0);
18014
+ case 11:
18015
+ this.isload = true;
18016
+ case 12:
18017
+ case "end":
18018
+ return _context.stop();
18019
+ }
18020
+ }, _callee, this, [[1, 8]]);
18021
+ }));
18022
+ function getFun() {
18023
+ return _getFun.apply(this, arguments);
18024
+ }
18025
+ return getFun;
18026
+ }()
18027
+ }, {
18028
+ key: "get",
18029
+ value: function () {
18030
+ var _get = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee2(key) {
18031
+ return _regeneratorRuntime$1().wrap(function _callee2$(_context2) {
18032
+ while (1) switch (_context2.prev = _context2.next) {
18033
+ case 0:
18034
+ if (this.isload) {
18035
+ _context2.next = 4;
18036
+ break;
18037
+ }
18038
+ // 兼容同时间发起多个
18039
+ if (!this.getPro) {
18040
+ this.getPro = this.getFun();
18041
+ }
18042
+ _context2.next = 4;
18043
+ return this.getPro;
18044
+ case 4:
18045
+ if (!key) {
18046
+ _context2.next = 12;
18047
+ break;
18048
+ }
18049
+ if (!Array.isArray(key)) {
18050
+ _context2.next = 9;
18051
+ break;
18052
+ }
18053
+ return _context2.abrupt("return", cloneDeep$1(this.cache.filter(function (item) {
18054
+ return key.some(function (item2) {
18055
+ return item2 === item.key;
18056
+ });
18057
+ })));
18058
+ case 9:
18059
+ return _context2.abrupt("return", cloneDeep$1(this.cache.find(function (item) {
18060
+ return item.key === key;
18061
+ })));
18062
+ case 10:
18063
+ _context2.next = 13;
18064
+ break;
18065
+ case 12:
18066
+ return _context2.abrupt("return", cloneDeep$1(this.cache));
18067
+ case 13:
18068
+ case "end":
18069
+ return _context2.stop();
18070
+ }
18071
+ }, _callee2, this);
18072
+ }));
18073
+ function get(_x) {
18074
+ return _get.apply(this, arguments);
18075
+ }
18076
+ return get;
18077
+ }()
18078
+ }]);
18079
+ return GlobalConfig;
18080
+ }();
18081
+ var globalConfig = new GlobalConfig();
18082
+
17906
18083
  function commonjsRequire(path) {
17907
18084
  throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
17908
18085
  }
@@ -60096,4 +60273,4 @@ var Module = {
60096
60273
  checkModule: core.checkModule.bind(core)
60097
60274
  };
60098
60275
 
60099
- 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, globalOptions, lsProxy, singleLogin, spuAxios, spuConfig, ssProxy, startRefreshtoken, uploadService, wxworkSuite };
60276
+ 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, singleLogin, spuAxios, spuConfig, ssProxy, startRefreshtoken, uploadService, wxworkSuite };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smart100/spu-web-plugin",
3
- "version": "0.0.25",
3
+ "version": "0.0.27",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "dev": "npm run build:types && rollup -c -w",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@amap/amap-jsapi-loader": "^1.0.1",
41
- "@smart100/wxworksuite-plugin": "^0.0.5",
41
+ "@smart100/wxworksuite-plugin": "^0.0.6",
42
42
  "axios": "^1.6.0",
43
43
  "co": "^4.6.0",
44
44
  "dayjs": "^1.11.10",
@@ -0,0 +1,54 @@
1
+ import { axios } from './index'
2
+ import { cloneDeep } from 'lodash-es'
3
+
4
+ class GlobalConfig {
5
+ private isload = false
6
+
7
+ cache: any[] = []
8
+
9
+ public async getFun (): Promise<any> {
10
+ if (!this.isload) {
11
+ try {
12
+ const res = await axios.post('/api/pemission/rolepermission/globalconfig/getglobalconfigbytype', {
13
+ configtype: '1'
14
+ })
15
+ // console.log(res)
16
+ // debugger
17
+ if (res.code === 200) {
18
+ this.cache = res?.data || []
19
+ }
20
+ } catch (err) {
21
+ console.error(err)
22
+ }
23
+ this.isload = true
24
+ }
25
+ }
26
+
27
+ private getPro: any = null
28
+
29
+ public async get (key?: string | string[]): Promise<any> {
30
+ if (!this.isload) {
31
+ // 兼容同时间发起多个
32
+ if (!this.getPro) {
33
+ this.getPro = this.getFun()
34
+ }
35
+ await this.getPro
36
+ }
37
+
38
+ if (key) {
39
+ if (Array.isArray(key)) {
40
+ return cloneDeep(this.cache.filter((item: any) => (key.some((item2) => item2 === item.key))))
41
+ } else {
42
+ return cloneDeep(this.cache.find((item: any) => item.key === key))
43
+ }
44
+ } else {
45
+ return cloneDeep(this.cache)
46
+ }
47
+ }
48
+ }
49
+
50
+ const globalConfig = new GlobalConfig()
51
+
52
+ export {
53
+ globalConfig
54
+ }
package/src/index.ts CHANGED
@@ -7,6 +7,7 @@ import { initStorageProxy, lsProxy, ssProxy } from './storageProxy'
7
7
  import { getLocation, getDistance } from './location'
8
8
  import { initAxios, spuAxios, axios } from './axios'
9
9
  import { initSpuConfig, spuConfig } from './spuConfig'
10
+ import { globalConfig } from './globalConfig'
10
11
  import { downloadService, uploadService } from './oss'
11
12
  import { getUniqueid, functionCheck } from './utils'
12
13
  import urlquery from './urlquery'
@@ -155,6 +156,7 @@ export {
155
156
  axios,
156
157
  axios as apaasAxios,
157
158
  spuConfig,
159
+ globalConfig,
158
160
  downloadService,
159
161
  uploadService,
160
162
  getUniqueid,
package/src/spuConfig.ts CHANGED
@@ -8,7 +8,7 @@ class SpuConfig {
8
8
 
9
9
  cache: any[] = []
10
10
 
11
- public async get (dataid?: string | string[]): Promise<any> {
11
+ public async getFun (): Promise<any> {
12
12
  if (!this.isload) {
13
13
  try {
14
14
  const res = await spuAxios.post('/lifecycle/getconfigdata', {
@@ -25,6 +25,18 @@ class SpuConfig {
25
25
  }
26
26
  this.isload = true
27
27
  }
28
+ }
29
+
30
+ private getPro: any = null
31
+
32
+ public async get (dataid?: string | string[]): Promise<any> {
33
+ if (!this.isload) {
34
+ // 兼容同时间发起多个
35
+ if (!this.getPro) {
36
+ this.getPro = this.getFun()
37
+ }
38
+ await this.getPro
39
+ }
28
40
 
29
41
  if (dataid) {
30
42
  if (Array.isArray(dataid)) {
@@ -76,6 +76,7 @@ export const spuAxios: any
76
76
  export const apaasAxios: any
77
77
  export const axios: any
78
78
  export const spuConfig: any
79
+ export const globalConfig: any
79
80
  export const downloadService: IDownloadService
80
81
  export const uploadService: IUploadService
81
82
  export const getUniqueid: () => string