ls-pro-common 3.1.31 → 3.1.32

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/es/http/index.js CHANGED
@@ -57,12 +57,10 @@ request.interceptors.request.use(function (url, options) {
57
57
  options.headers = options.headers || {};
58
58
  // 处理浏览器指纹
59
59
  if (browserId) {
60
- // @ts-ignore
61
60
  options.headers.browserId = browserId;
62
61
  } else {
63
62
  if (getCache('browserId')) {
64
63
  browserId = getCache('browserId');
65
- // @ts-ignore
66
64
  options.headers.browserId = browserId;
67
65
  } else {
68
66
  getBrowserId().then(function (id) {
@@ -73,45 +71,37 @@ request.interceptors.request.use(function (url, options) {
73
71
  // 处理门店
74
72
  var shopNo = getCacheSessionFirst('shopNo');
75
73
  if (shopNo) {
76
- // @ts-ignore
77
74
  options.headers.shopNo = shopNo;
78
75
  }
79
76
  // 处理门店
80
77
  var shopCode = getCacheSessionFirst('shopCode');
81
78
  if (shopCode) {
82
- // @ts-ignore
83
79
  options.headers.shopCode = shopCode;
84
80
  }
85
81
  // 处理仓库
86
82
  var storeNo = getCacheSessionFirst('storeNo');
87
83
  if (storeNo) {
88
- // @ts-ignore
89
84
  options.headers.storeNo = storeNo;
90
85
  }
91
86
  var tag = getCookie('x-asm-prefer-tag');
92
87
  if (tag) {
93
- // @ts-ignore
94
88
  options.headers['x-asm-prefer-tag'] = tag; //灰度发版标识
95
89
  }
96
- // @ts-ignore
90
+
97
91
  options.headers['terminal'] = 'PC';
98
- // wms 提示,是否排班标识
99
92
  var expireWarnFlag = getCache('expireWarnFlag', true);
100
- // @ts-ignore
101
93
  options.headers.expireWarnFlag = expireWarnFlag === '1' ? '1' : '0';
102
94
  var token = getCookie('token');
103
95
  if (token && url.indexOf('noToken=1') === -1) {
104
- //@ts-ignore
105
96
  options.headers.token = token;
106
97
  }
107
98
  url = url.replace('&noToken=1', '').replace('noToken=1', '');
108
- var resCode = getUrlQuery('resCode', url) || getUrlQuery('resCode') || getUrlQuery('resourceId') || getResourceProps('resourceId');
99
+ var resCode = getUrlQuery('resCode', url) || window.__currentResCode__ || getUrlQuery('resCode') || getUrlQuery('resourceId') || getResourceProps('resourceId');
109
100
  var param = {
110
101
  _t1: Date.now(),
111
102
  __r: ((_window$crypto$random = (_window$crypto = window.crypto)['randomUUID']) === null || _window$crypto$random === void 0 ? void 0 : _window$crypto$random.call(_window$crypto)) || Math.random()
112
103
  };
113
104
  // 当没有明文参数resCode的时候,添加resCode参数为资源Id
114
- //@ts-ignore
115
105
  if (resCode && !((_options$params = options.params) === null || _options$params === void 0 ? void 0 : _options$params.resCode)) {
116
106
  param.resCode = resCode;
117
107
  }
@@ -229,3 +229,9 @@ export declare const urlDownloadDomain: (url: string) => string;
229
229
  * @param isBlank 是否新开窗口下载,默认新开窗口,不影响原页面展示
230
230
  */
231
231
  export declare const downloadFile: (url: string, fileName?: string | undefined, isBlank?: boolean) => void;
232
+ /**
233
+ * 微前端主工程注入子工程时,子工程调用此方法设置资源Id,权限等参数
234
+ *
235
+ * @param props
236
+ */
237
+ export declare const setCurrentResCode: (props: any) => void;
package/es/utils/index.js CHANGED
@@ -28,7 +28,7 @@ export var getUrlQuery = function getUrlQuery(name) {
28
28
  };
29
29
  export var getResourceProps = function getResourceProps(name) {
30
30
  if (!name) return '';
31
- var id = getUrlQuery('resCode');
31
+ var id = window.__currentResCode__ || getUrlQuery('resCode');
32
32
  var obj;
33
33
  // window.lsResourceList 为主工程写入的资源
34
34
  // @ts-ignore
@@ -510,4 +510,20 @@ export var downloadFile = function downloadFile(url, fileName) {
510
510
  document.body.appendChild(a);
511
511
  a.click();
512
512
  document.body.removeChild(a);
513
+ };
514
+ /**
515
+ * 微前端主工程注入子工程时,子工程调用此方法设置资源Id,权限等参数
516
+ *
517
+ * @param props
518
+ */
519
+ export var setCurrentResCode = function setCurrentResCode(props) {
520
+ var _props$history;
521
+ var initialValue = props === null || props === void 0 ? void 0 : (_props$history = props.history) === null || _props$history === void 0 ? void 0 : _props$history.initialEntries;
522
+ if (Array.isArray(initialValue) && initialValue.length > 0) {
523
+ var parentParams = initialValue[0];
524
+ window.__initVal__ = parentParams;
525
+ window.__currentResCode__ = getUrlQuery('resCode', parentParams);
526
+ window.__currentRight__ = getUrlQuery('right', parentParams);
527
+ window.__currentResRight__ = getUrlQuery('resRight', parentParams);
528
+ }
513
529
  };
package/lib/http/index.js CHANGED
@@ -57,12 +57,10 @@ request.interceptors.request.use(function (url, options) {
57
57
  options.headers = options.headers || {};
58
58
  // 处理浏览器指纹
59
59
  if (browserId) {
60
- // @ts-ignore
61
60
  options.headers.browserId = browserId;
62
61
  } else {
63
62
  if (getCache('browserId')) {
64
63
  browserId = getCache('browserId');
65
- // @ts-ignore
66
64
  options.headers.browserId = browserId;
67
65
  } else {
68
66
  getBrowserId().then(function (id) {
@@ -73,45 +71,37 @@ request.interceptors.request.use(function (url, options) {
73
71
  // 处理门店
74
72
  var shopNo = getCacheSessionFirst('shopNo');
75
73
  if (shopNo) {
76
- // @ts-ignore
77
74
  options.headers.shopNo = shopNo;
78
75
  }
79
76
  // 处理门店
80
77
  var shopCode = getCacheSessionFirst('shopCode');
81
78
  if (shopCode) {
82
- // @ts-ignore
83
79
  options.headers.shopCode = shopCode;
84
80
  }
85
81
  // 处理仓库
86
82
  var storeNo = getCacheSessionFirst('storeNo');
87
83
  if (storeNo) {
88
- // @ts-ignore
89
84
  options.headers.storeNo = storeNo;
90
85
  }
91
86
  var tag = getCookie('x-asm-prefer-tag');
92
87
  if (tag) {
93
- // @ts-ignore
94
88
  options.headers['x-asm-prefer-tag'] = tag; //灰度发版标识
95
89
  }
96
- // @ts-ignore
90
+
97
91
  options.headers['terminal'] = 'PC';
98
- // wms 提示,是否排班标识
99
92
  var expireWarnFlag = getCache('expireWarnFlag', true);
100
- // @ts-ignore
101
93
  options.headers.expireWarnFlag = expireWarnFlag === '1' ? '1' : '0';
102
94
  var token = getCookie('token');
103
95
  if (token && url.indexOf('noToken=1') === -1) {
104
- //@ts-ignore
105
96
  options.headers.token = token;
106
97
  }
107
98
  url = url.replace('&noToken=1', '').replace('noToken=1', '');
108
- var resCode = getUrlQuery('resCode', url) || getUrlQuery('resCode') || getUrlQuery('resourceId') || getResourceProps('resourceId');
99
+ var resCode = getUrlQuery('resCode', url) || window.__currentResCode__ || getUrlQuery('resCode') || getUrlQuery('resourceId') || getResourceProps('resourceId');
109
100
  var param = {
110
101
  _t1: Date.now(),
111
102
  __r: ((_window$crypto$random = (_window$crypto = window.crypto)['randomUUID']) === null || _window$crypto$random === void 0 ? void 0 : _window$crypto$random.call(_window$crypto)) || Math.random()
112
103
  };
113
104
  // 当没有明文参数resCode的时候,添加resCode参数为资源Id
114
- //@ts-ignore
115
105
  if (resCode && !((_options$params = options.params) === null || _options$params === void 0 ? void 0 : _options$params.resCode)) {
116
106
  param.resCode = resCode;
117
107
  }
@@ -229,3 +229,9 @@ export declare const urlDownloadDomain: (url: string) => string;
229
229
  * @param isBlank 是否新开窗口下载,默认新开窗口,不影响原页面展示
230
230
  */
231
231
  export declare const downloadFile: (url: string, fileName?: string | undefined, isBlank?: boolean) => void;
232
+ /**
233
+ * 微前端主工程注入子工程时,子工程调用此方法设置资源Id,权限等参数
234
+ *
235
+ * @param props
236
+ */
237
+ export declare const setCurrentResCode: (props: any) => void;
@@ -28,7 +28,7 @@ export var getUrlQuery = function getUrlQuery(name) {
28
28
  };
29
29
  export var getResourceProps = function getResourceProps(name) {
30
30
  if (!name) return '';
31
- var id = getUrlQuery('resCode');
31
+ var id = window.__currentResCode__ || getUrlQuery('resCode');
32
32
  var obj;
33
33
  // window.lsResourceList 为主工程写入的资源
34
34
  // @ts-ignore
@@ -510,4 +510,20 @@ export var downloadFile = function downloadFile(url, fileName) {
510
510
  document.body.appendChild(a);
511
511
  a.click();
512
512
  document.body.removeChild(a);
513
+ };
514
+ /**
515
+ * 微前端主工程注入子工程时,子工程调用此方法设置资源Id,权限等参数
516
+ *
517
+ * @param props
518
+ */
519
+ export var setCurrentResCode = function setCurrentResCode(props) {
520
+ var _props$history;
521
+ var initialValue = props === null || props === void 0 ? void 0 : (_props$history = props.history) === null || _props$history === void 0 ? void 0 : _props$history.initialEntries;
522
+ if (Array.isArray(initialValue) && initialValue.length > 0) {
523
+ var parentParams = initialValue[0];
524
+ window.__initVal__ = parentParams;
525
+ window.__currentResCode__ = getUrlQuery('resCode', parentParams);
526
+ window.__currentRight__ = getUrlQuery('right', parentParams);
527
+ window.__currentResRight__ = getUrlQuery('resRight', parentParams);
528
+ }
513
529
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ls-pro-common",
3
- "version": "3.1.31",
3
+ "version": "3.1.32",
4
4
  "description": "ls-pro-common",
5
5
  "license": "MIT",
6
6
  "sideEffects": [