ls-pro-common 1.0.60 → 1.0.62

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.
@@ -1010,7 +1010,7 @@ function useDtl(dtlParam) {
1010
1010
  }, "\u5BFC\u51FA") : false].filter(function (o) {
1011
1011
  return o !== false;
1012
1012
  });
1013
- }, [selectedRows]);
1013
+ }, [selectedRows, auditStatus, statusField, masterObject]);
1014
1014
  return {
1015
1015
  formRef: formRef,
1016
1016
  tableRef: tableRef,
package/es/http/index.js CHANGED
@@ -2,7 +2,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
3
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
4
  import { extend } from 'umi-request';
5
- import { getCache, getUrlQuery, setUrlQuery, getResourceProps, showError, toGatewayUrl, reLogin } from '../utils'; //默认超时时间为1分钟
5
+ import { getUrlQuery, setUrlQuery, getCookie, getResourceProps, showError, toGatewayUrl, reLogin } from '../utils'; //默认超时时间为1分钟
6
6
 
7
7
  var request = extend({
8
8
  timeout: 60000
@@ -10,11 +10,11 @@ var request = extend({
10
10
  /** 请求拦截器,统一添加token */
11
11
 
12
12
  request.interceptors.request.use(function (url, options) {
13
- var token = getCache("token");
13
+ var token = getCookie("token");
14
14
 
15
15
  var opts = _objectSpread({}, options);
16
16
 
17
- if (token) {
17
+ if (token && url.indexOf('noToken=1') === -1) {
18
18
  Object.assign(opts, {
19
19
  headers: {
20
20
  token: token
@@ -22,6 +22,7 @@ request.interceptors.request.use(function (url, options) {
22
22
  });
23
23
  }
24
24
 
25
+ url = url.replace('noToken=1', '').replace('&&', '&').replace('?&', '?');
25
26
  var param = {
26
27
  resCode: getUrlQuery('resCode') || getUrlQuery('resourceId') || getResourceProps('resourceId'),
27
28
  _t1: Date.now()
@@ -66,7 +66,7 @@ export declare const getCookie: (name: string) => string | null;
66
66
  * @param {*} value Cookie 值
67
67
  * @param { Number } day 有效天数 默认1天,
68
68
  */
69
- export declare const setCookie: (key: string, value: string | number, day?: number) => void;
69
+ export declare const setCookie: (key: string, value: string | number, day?: number, sameSite?: boolean) => void;
70
70
  /**
71
71
  * 判断是否登录
72
72
  * @returns
@@ -86,6 +86,12 @@ export declare const setCache: (key: string, data: any, session?: boolean) => vo
86
86
  * @returns 关键字对应的值
87
87
  */
88
88
  export declare const getCache: (key: string, session?: boolean) => string | null;
89
+ /**
90
+ *
91
+ * @param key 关键字,不传清除所有
92
+ * @param session 是否session storage , 默认 localStorage
93
+ */
94
+ export declare const clearCache: (key?: string | undefined, session?: boolean) => void;
89
95
  /** @name 显示错误 */
90
96
  export declare const showError: (text: string) => void;
91
97
  /** @name 显示警示 */
package/es/utils/index.js CHANGED
@@ -145,12 +145,22 @@ export var getCookie = function getCookie(name) {
145
145
 
146
146
  export var setCookie = function setCookie(key, value) {
147
147
  var day = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
148
+ var sameSite = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
148
149
 
149
150
  if (day !== 0) {
150
151
  var d = new Date(Date.now() + day * 24 * 60 * 60 * 1000);
151
- document.cookie = "".concat(key, "=").concat(value, ";expires=").concat(d.toUTCString(), ";path=/");
152
+
153
+ if (sameSite) {
154
+ document.cookie = "".concat(key, "=").concat(value, ";expires=").concat(d.toUTCString(), ";path=/;sameSite=None;secure=true");
155
+ } else {
156
+ document.cookie = "".concat(key, "=").concat(value, ";expires=").concat(d.toUTCString(), ";path=/");
157
+ }
152
158
  } else {
153
- document.cookie = key + "=" + value + ";path=/";
159
+ if (sameSite) {
160
+ document.cookie = key + "=" + value + ";path=/;sameSite=None;secure=true";
161
+ } else {
162
+ document.cookie = key + "=" + value + ";path=/";
163
+ }
154
164
  }
155
165
  };
156
166
  /**
@@ -194,6 +204,21 @@ export var getCache = function getCache(key) {
194
204
 
195
205
  return data;
196
206
  };
207
+ /**
208
+ *
209
+ * @param key 关键字,不传清除所有
210
+ * @param session 是否session storage , 默认 localStorage
211
+ */
212
+
213
+ export var clearCache = function clearCache(key) {
214
+ var session = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
215
+
216
+ if (key) {
217
+ session ? sessionStorage.removeItem(key) : localStorage.removeItem(key);
218
+ } else {
219
+ session ? sessionStorage.clear() : localStorage.clear();
220
+ }
221
+ };
197
222
  /** @name 显示错误 */
198
223
 
199
224
  export var showError = function showError(text) {
@@ -245,7 +270,7 @@ export var reLogin = function reLogin() {
245
270
  maskClosable: false,
246
271
  afterClose: function afterClose() {
247
272
  timeout = false;
248
- location.href = '/login?redirect=' + encodeURI(location.href);
273
+ location.href = location.pathname === '/' ? '/login' : '/login?redirect=' + encodeURI(location.href);
249
274
  }
250
275
  });
251
276
  };
@@ -1032,7 +1032,7 @@ function useDtl(dtlParam) {
1032
1032
  }, "\u5BFC\u51FA") : false].filter(function (o) {
1033
1033
  return o !== false;
1034
1034
  });
1035
- }, [selectedRows]);
1035
+ }, [selectedRows, auditStatus, statusField, masterObject]);
1036
1036
  return {
1037
1037
  formRef: formRef,
1038
1038
  tableRef: tableRef,
package/lib/http/index.js CHANGED
@@ -30,10 +30,10 @@ var request = (0, _umiRequest.extend)({
30
30
  /** 请求拦截器,统一添加token */
31
31
 
32
32
  request.interceptors.request.use(function (url, options) {
33
- var token = (0, _utils.getCache)("token");
33
+ var token = (0, _utils.getCookie)("token");
34
34
  var opts = (0, _objectSpread2.default)({}, options);
35
35
 
36
- if (token) {
36
+ if (token && url.indexOf('noToken=1') === -1) {
37
37
  Object.assign(opts, {
38
38
  headers: {
39
39
  token: token
@@ -41,6 +41,7 @@ request.interceptors.request.use(function (url, options) {
41
41
  });
42
42
  }
43
43
 
44
+ url = url.replace('noToken=1', '').replace('&&', '&').replace('?&', '?');
44
45
  var param = {
45
46
  resCode: (0, _utils.getUrlQuery)('resCode') || (0, _utils.getUrlQuery)('resourceId') || (0, _utils.getResourceProps)('resourceId'),
46
47
  _t1: Date.now()
@@ -66,7 +66,7 @@ export declare const getCookie: (name: string) => string | null;
66
66
  * @param {*} value Cookie 值
67
67
  * @param { Number } day 有效天数 默认1天,
68
68
  */
69
- export declare const setCookie: (key: string, value: string | number, day?: number) => void;
69
+ export declare const setCookie: (key: string, value: string | number, day?: number, sameSite?: boolean) => void;
70
70
  /**
71
71
  * 判断是否登录
72
72
  * @returns
@@ -86,6 +86,12 @@ export declare const setCache: (key: string, data: any, session?: boolean) => vo
86
86
  * @returns 关键字对应的值
87
87
  */
88
88
  export declare const getCache: (key: string, session?: boolean) => string | null;
89
+ /**
90
+ *
91
+ * @param key 关键字,不传清除所有
92
+ * @param session 是否session storage , 默认 localStorage
93
+ */
94
+ export declare const clearCache: (key?: string | undefined, session?: boolean) => void;
89
95
  /** @name 显示错误 */
90
96
  export declare const showError: (text: string) => void;
91
97
  /** @name 显示警示 */
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.dateAdd = exports.appPath = void 0;
8
+ exports.dateAdd = exports.clearCache = exports.appPath = void 0;
9
9
  Object.defineProperty(exports, "dateFormat", {
10
10
  enumerable: true,
11
11
  get: function get() {
@@ -220,12 +220,22 @@ exports.getCookie = getCookie;
220
220
 
221
221
  var setCookie = function setCookie(key, value) {
222
222
  var day = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
223
+ var sameSite = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
223
224
 
224
225
  if (day !== 0) {
225
226
  var d = new Date(Date.now() + day * 24 * 60 * 60 * 1000);
226
- document.cookie = "".concat(key, "=").concat(value, ";expires=").concat(d.toUTCString(), ";path=/");
227
+
228
+ if (sameSite) {
229
+ document.cookie = "".concat(key, "=").concat(value, ";expires=").concat(d.toUTCString(), ";path=/;sameSite=None;secure=true");
230
+ } else {
231
+ document.cookie = "".concat(key, "=").concat(value, ";expires=").concat(d.toUTCString(), ";path=/");
232
+ }
227
233
  } else {
228
- document.cookie = key + "=" + value + ";path=/";
234
+ if (sameSite) {
235
+ document.cookie = key + "=" + value + ";path=/;sameSite=None;secure=true";
236
+ } else {
237
+ document.cookie = key + "=" + value + ";path=/";
238
+ }
229
239
  }
230
240
  };
231
241
  /**
@@ -278,11 +288,29 @@ var getCache = function getCache(key) {
278
288
 
279
289
  return data;
280
290
  };
281
- /** @name 显示错误 */
291
+ /**
292
+ *
293
+ * @param key 关键字,不传清除所有
294
+ * @param session 是否session storage , 默认 localStorage
295
+ */
282
296
 
283
297
 
284
298
  exports.getCache = getCache;
285
299
 
300
+ var clearCache = function clearCache(key) {
301
+ var session = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
302
+
303
+ if (key) {
304
+ session ? sessionStorage.removeItem(key) : localStorage.removeItem(key);
305
+ } else {
306
+ session ? sessionStorage.clear() : localStorage.clear();
307
+ }
308
+ };
309
+ /** @name 显示错误 */
310
+
311
+
312
+ exports.clearCache = clearCache;
313
+
286
314
  var showError = function showError(text) {
287
315
  _message2.default.error(text);
288
316
  };
@@ -343,7 +371,7 @@ var reLogin = function reLogin() {
343
371
  maskClosable: false,
344
372
  afterClose: function afterClose() {
345
373
  timeout = false;
346
- location.href = '/login?redirect=' + encodeURI(location.href);
374
+ location.href = location.pathname === '/' ? '/login' : '/login?redirect=' + encodeURI(location.href);
347
375
  }
348
376
  });
349
377
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ls-pro-common",
3
- "version": "1.0.60",
3
+ "version": "1.0.62",
4
4
  "description": "ls-pro-common",
5
5
  "keywords": [
6
6
  "antd",
@@ -28,7 +28,7 @@
28
28
  ],
29
29
  "dependencies": {
30
30
  "@ant-design/icons": "^4.3.0",
31
- "ls-pro-table": "2.62.44",
31
+ "ls-pro-table": "2.62.45",
32
32
  "ls-pro-form": "1.52.29",
33
33
  "@babel/runtime": "^7.16.3",
34
34
  "classnames": "^2.2.6",