@smart100/spu-web-plugin 0.0.26 → 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.26";
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;
@@ -17869,11 +17869,12 @@ var SpuConfig = /*#__PURE__*/function () {
17869
17869
  _classCallCheck$1(this, SpuConfig);
17870
17870
  _defineProperty$1(this, "isload", false);
17871
17871
  _defineProperty$1(this, "cache", []);
17872
+ _defineProperty$1(this, "getPro", null);
17872
17873
  }
17873
17874
  _createClass$1(SpuConfig, [{
17874
- key: "get",
17875
+ key: "getFun",
17875
17876
  value: function () {
17876
- var _get = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee(dataid) {
17877
+ var _getFun = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
17877
17878
  var res, _res$data;
17878
17879
  return _regeneratorRuntime$1().wrap(function _callee$(_context) {
17879
17880
  while (1) switch (_context.prev = _context.next) {
@@ -17904,33 +17905,61 @@ var SpuConfig = /*#__PURE__*/function () {
17904
17905
  case 11:
17905
17906
  this.isload = true;
17906
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:
17907
17936
  if (!dataid) {
17908
- _context.next = 20;
17937
+ _context2.next = 12;
17909
17938
  break;
17910
17939
  }
17911
17940
  if (!Array.isArray(dataid)) {
17912
- _context.next = 17;
17941
+ _context2.next = 9;
17913
17942
  break;
17914
17943
  }
17915
- return _context.abrupt("return", cloneDeep$1(this.cache.filter(function (item) {
17944
+ return _context2.abrupt("return", cloneDeep$1(this.cache.filter(function (item) {
17916
17945
  return dataid.some(function (item2) {
17917
17946
  return item2 === item.dataid;
17918
17947
  });
17919
17948
  })));
17920
- case 17:
17921
- 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) {
17922
17951
  return item.dataid === dataid;
17923
17952
  })));
17924
- case 18:
17925
- _context.next = 21;
17953
+ case 10:
17954
+ _context2.next = 13;
17926
17955
  break;
17927
- case 20:
17928
- return _context.abrupt("return", cloneDeep$1(this.cache));
17929
- case 21:
17956
+ case 12:
17957
+ return _context2.abrupt("return", cloneDeep$1(this.cache));
17958
+ case 13:
17930
17959
  case "end":
17931
- return _context.stop();
17960
+ return _context2.stop();
17932
17961
  }
17933
- }, _callee, this, [[1, 8]]);
17962
+ }, _callee2, this);
17934
17963
  }));
17935
17964
  function get(_x) {
17936
17965
  return _get.apply(this, arguments);
@@ -17945,6 +17974,112 @@ function initSpuConfig(options) {
17945
17974
  }
17946
17975
  var spuConfig = new SpuConfig();
17947
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
+
17948
18083
  function commonjsRequire(path) {
17949
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.');
17950
18085
  }
@@ -60138,4 +60273,4 @@ var Module = {
60138
60273
  checkModule: core.checkModule.bind(core)
60139
60274
  };
60140
60275
 
60141
- 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.26",
3
+ "version": "0.0.27",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "dev": "npm run build:types && rollup -c -w",
@@ -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