ztxkutils 2.10.38 → 2.10.40

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  export { c as authority } from './authority-e6bde99f.js';
2
2
  export { d as dataModel } from './dataModel-1fbaff40.js';
3
3
  export { t as tools } from './tools-09a4d620.js';
4
- export { v as validate } from './validate-e51e4026.js';
5
- export { r as request } from './request-8e2b5826.js';
4
+ export { v as validate } from './validate-a06e1fa0.js';
5
+ export { r as request } from './request-ba8abf99.js';
6
6
  export { r as reqUrl } from './reqUrl-787dd9e5.js';
7
7
  import './tslib.es6-35653116.js';
8
8
  import 'dayjs';
@@ -0,0 +1 @@
1
+ declare function openDB(dbName: string, version?: number): Promise<unknown>;
@@ -2487,6 +2487,8 @@ var isFirstSet = false; // 首次初始化
2487
2487
  var OLD_AUTHORIZATION = 'Basic c3dvcmQ6c3dvcmRfc2VjcmV0';
2488
2488
  var NEW_AUTHORIZATION = 'Basic em1kbXM6em1kbXNfc2VjcmV0';
2489
2489
  var Authorization = OLD_AUTHORIZATION;
2490
+ // 用于存储目前状态为pending的请求标识信息 2023-05-15
2491
+ var pendingRequest = [];
2490
2492
  function loginRequest(params, InnerAuthorization) {
2491
2493
  return request({
2492
2494
  method: 'POST',
@@ -2712,9 +2714,18 @@ function setInterceptorsResponse(jumpCallback, otherOptions) {
2712
2714
  function setInterceptorsRequest() {
2713
2715
  // 拦截器,拦截响应头信息
2714
2716
  axios.interceptors.request.use(function (config) {
2717
+ var _a;
2715
2718
  if (config.isCancelRepeat) {
2716
2719
  axiosCancel.pendingRequestCancel(config);
2717
2720
  }
2721
+ // 如果需要清除未完成的请求 2023-05-15
2722
+ if (config.isCancelNoCompleteRequest &&
2723
+ !config.cancelToken &&
2724
+ ((_a = config.method) === null || _a === void 0 ? void 0 : _a.toUpperCase()) !== 'POST') {
2725
+ var cancelTokenObj = axios.CancelToken.source();
2726
+ config.cancelToken = cancelTokenObj.token;
2727
+ pendingRequest.push(cancelTokenObj.cancel);
2728
+ }
2718
2729
  return config;
2719
2730
  });
2720
2731
  }
@@ -2868,6 +2879,13 @@ function request(myOptions, jumpCallback, otherOptions) {
2868
2879
  }
2869
2880
  return axios(newOptions);
2870
2881
  }
2882
+ // 清除未完成的请求 2023-05-15
2883
+ function clearNoCompleteRequest() {
2884
+ pendingRequest.forEach(function (cancel, index) {
2885
+ cancel && cancel();
2886
+ });
2887
+ pendingRequest = [];
2888
+ }
2871
2889
  function clearCatch() {
2872
2890
  catchPromiseObj = [];
2873
2891
  }
@@ -2877,7 +2895,8 @@ var request$1 = /*#__PURE__*/Object.freeze({
2877
2895
  OLD_AUTHORIZATION: OLD_AUTHORIZATION,
2878
2896
  NEW_AUTHORIZATION: NEW_AUTHORIZATION,
2879
2897
  'default': request,
2898
+ clearNoCompleteRequest: clearNoCompleteRequest,
2880
2899
  clearCatch: clearCatch
2881
2900
  });
2882
2901
 
2883
- export { NEW_AUTHORIZATION as N, OLD_AUTHORIZATION as O, request as a, clearCatch as c, request$1 as r };
2902
+ export { NEW_AUTHORIZATION as N, OLD_AUTHORIZATION as O, request as a, clearCatch as b, clearNoCompleteRequest as c, request$1 as r };
package/dist/request.d.ts CHANGED
@@ -12,6 +12,8 @@ export interface IOptions extends AxiosRequestConfig {
12
12
  noCatchUrl?: string[];
13
13
  isCatch?: boolean;
14
14
  isCancelRepeat?: boolean;
15
+ isCancelNoCompleteRequest?: boolean;
15
16
  }
16
17
  export default function request(myOptions: IOptions, jumpCallback?: any, otherOptions?: any): any;
18
+ export declare function clearNoCompleteRequest(): void;
17
19
  export declare function clearCatch(): void;
package/dist/request.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import './tslib.es6-35653116.js';
2
2
  import 'axios';
3
3
  import 'ztxkui';
4
- export { N as NEW_AUTHORIZATION, O as OLD_AUTHORIZATION, c as clearCatch, a as default } from './request-8e2b5826.js';
4
+ export { N as NEW_AUTHORIZATION, O as OLD_AUTHORIZATION, b as clearCatch, c as clearNoCompleteRequest, a as default } from './request-ba8abf99.js';
5
5
  import './authority-e6bde99f.js';
6
6
  import './crypto-c481f616.js';
7
7
  import 'crypto';
@@ -1,34 +1 @@
1
- declare const PV_URL_SET: Set<unknown>;
2
- /**
3
- * routeUrl: string
4
- * systemId: string
5
- * userId: string
6
- * navigator: string // 浏览器信息 userAgent
7
- * platform: string // 系统信息
8
- * memory: string // 内存信息
9
- * eventKey: string // 事件名
10
- * eventValue: string // 事件值
11
- * {
12
- * jsHeapSizeLimit: 上下文内可用堆的最大体积,以字节计算。
13
- * totalJSHeapSize: 已分配的堆体积,以字节计算。
14
- * usedJSHeapSize: 当前 JS 堆活跃段(segment)的体积,以字节计算。
15
- * }
16
- */
17
- declare function getUserOsInfo(userAgent?: string): "Windows 10" | "Windows 8" | "Windows 7" | "Windows Vista" | "Windows XP" | "Windows 2000" | "Mac/iOS" | "UNIX" | "Linux" | "Other";
18
- declare class MyStatistic {
19
- private systemId;
20
- private userId;
21
- private navigator;
22
- private platform;
23
- constructor(systemId: any, userId: any);
24
- private send;
25
- private initPerformance;
26
- private errorHandle;
27
- private unhandledrejectionHandle;
28
- private initError;
29
- removeError(): void;
30
- pv(): void;
31
- event(eventKey: string, eventValue: string): void;
32
- error(error: Error, info?: any): void;
33
- }
34
- declare const statistic: MyStatistic;
1
+ export {};
@@ -71,6 +71,19 @@ var commonMessage = {
71
71
  passwordMessage: '密码必须包含大小写字母、数字、特殊字符且最小长度为8,且不能出现连续数字或字符,不能出现相同字符,且禁止使用用户账号作为密码',
72
72
  spaceMessage: '请勿输入空格',
73
73
  };
74
+ function isConsecutiveChars(char1, char2) {
75
+ var lowerCaseAlphabet = 'abcdefghijklmnopqrstuvwxyz'; // 小写字母
76
+ var upperCaseAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; // 大写字母
77
+ var numeric = '0123456789'; // 数字
78
+ // 找到包含两个字符的字符集
79
+ var alphabet = [lowerCaseAlphabet, upperCaseAlphabet, numeric].find(function (alph) { return alph.includes(char1) && alph.includes(char2); });
80
+ if (!alphabet) {
81
+ return false; // 如果两个字符不在同一字符集中,那么它们不可能连续
82
+ }
83
+ var index1 = alphabet.indexOf(char1);
84
+ var index2 = alphabet.indexOf(char2);
85
+ return Math.abs(index1 - index2) === 1; // 如果两个字符在字符集中的位置相邻,那么它们是连续的
86
+ }
74
87
  function validatePassword(password, username) {
75
88
  // 用正则表达式检查密码基本规则
76
89
  var regex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\da-zA-Z]).{8,}$/;
@@ -80,13 +93,26 @@ function validatePassword(password, username) {
80
93
  message: '密码中必须包含大小写字母、数字、特殊字符,且长度必须大于8个字符!',
81
94
  };
82
95
  }
83
- // 检查密码中是否有连续的字母或数字
96
+ // 检查密码中是否有连续的字母或数字 连续超过三次
97
+ var count = 0;
98
+ var startChart = 0;
84
99
  for (var i = 0; i < password.length - 1; i++) {
85
- if (Math.abs(password.charCodeAt(i) - password.charCodeAt(i + 1)) === 1) {
86
- return {
87
- result: false,
88
- message: '密码中有连续的字母或数字!',
89
- };
100
+ if (isConsecutiveChars(password[i], password[i + 1])) {
101
+ if (count === 0) {
102
+ startChart = i;
103
+ }
104
+ count++;
105
+ if (count >= 2) {
106
+ // 密码中不应含有连续的字母或数字
107
+ return {
108
+ result: false,
109
+ message: "\u4ECE\u7B2C" + (startChart + 1) + "\u4E2A\u5B57\u7B26\u5F00\u59CB\uFF0C\u6709\u8FDE\u7EED\u8D85\u8FC7\u4E09\u4F4D\u7684\u5B57\u6BCD\u6216\u6570\u5B57!",
110
+ };
111
+ }
112
+ }
113
+ else {
114
+ count = 0;
115
+ startChart = 0;
90
116
  }
91
117
  }
92
118
  // 检查密码中是否有相同的字符
package/dist/validate.js CHANGED
@@ -1 +1 @@
1
- export { c as commonMessage, b as validate, a as validatePassword } from './validate-e51e4026.js';
1
+ export { c as commonMessage, b as validate, a as validatePassword } from './validate-a06e1fa0.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkutils",
3
- "version": "2.10.38",
3
+ "version": "2.10.40",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -49,6 +49,7 @@
49
49
  "dependencies": {
50
50
  "crypto-js": "^4.1.1",
51
51
  "decimal.js-light": "^2.5.1",
52
+ "dexie": "^3.2.3",
52
53
  "js-base64": "^3.6.0",
53
54
  "jwt-decode": "^3.1.2",
54
55
  "screenfull": "^5.1.0",