ztxkutils 20.0.1 → 20.0.2
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/dataModel-b3629ef3.js +26 -0
- package/dist/dataModel.js +1 -1
- package/dist/i18next.js +7 -19
- package/dist/index.js +3 -3
- package/dist/request-d1972b41.js +2992 -0
- package/dist/request.js +1 -1
- package/dist/validate-21b58a69.js +260 -0
- package/dist/validate.js +1 -1
- package/package.json +1 -1
package/dist/request.js
CHANGED
@@ -2,7 +2,7 @@ import './tslib.es6-35653116.js';
|
|
2
2
|
import './i18next.js';
|
3
3
|
import 'axios';
|
4
4
|
import 'ztxkui';
|
5
|
-
export { N as NEW_AUTHORIZATION, O as OLD_AUTHORIZATION, d as clearAutonomousCatch, b as clearCatch, c as clearNoCompleteRequest, a as default } from './request-
|
5
|
+
export { N as NEW_AUTHORIZATION, O as OLD_AUTHORIZATION, d as clearAutonomousCatch, b as clearCatch, c as clearNoCompleteRequest, a as default } from './request-d1972b41.js';
|
6
6
|
import './authority-7a91cb9f.js';
|
7
7
|
import './crypto-c481f616.js';
|
8
8
|
import 'crypto';
|
@@ -0,0 +1,260 @@
|
|
1
|
+
import instance from './i18next.js';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* @description 常用正则表达式
|
5
|
+
*/
|
6
|
+
var validate = {
|
7
|
+
/**
|
8
|
+
* @description 长度验证,最小长度字符,0-200个字符
|
9
|
+
*/
|
10
|
+
smallLenValidate: /^(?:\s*)[\s\S]{0,200}(?:\s*)$/,
|
11
|
+
/**
|
12
|
+
* @description 长度验证,中等长度字符,0-400个字符
|
13
|
+
*/
|
14
|
+
middleLenValidate: /^(?:\s*)[\s\S]{0,400}(?:\s*)$/,
|
15
|
+
/**
|
16
|
+
* @description 长度验证,最大长度字符,0-600个字符
|
17
|
+
*/
|
18
|
+
largeLenValidate: /^(?:\s*)[\s\S]{0,600}(?:\s*)$/,
|
19
|
+
/**
|
20
|
+
* @description 长度验证,最大长度字符,0-5000个字符
|
21
|
+
*/
|
22
|
+
maxlargeLenValidate: /^(?:\s*)[\s\S]{0,5000}(?:\s*)$/,
|
23
|
+
/**
|
24
|
+
* @description 电话号码验证
|
25
|
+
*/
|
26
|
+
// phoneValidate: /^1(3\d|4\d|5\d|6\d|7\d|8\d|9\d)\d{8}$/,
|
27
|
+
// 数字 横线 长度 0 - 15位/^([0-9])|(\-)*$/
|
28
|
+
phoneValidate: /^[0-9\-]{0,15}$/,
|
29
|
+
/**
|
30
|
+
* @description 短信验证码 接受11位手机号
|
31
|
+
*/
|
32
|
+
shortPhoneValidate: /^1[0-9]{10}$/,
|
33
|
+
/**
|
34
|
+
* @description 身份证验证
|
35
|
+
* 18位 最后一位可以是X x
|
36
|
+
*/
|
37
|
+
idCardValidate: /^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,
|
38
|
+
/**
|
39
|
+
* @description 邮箱验证
|
40
|
+
*/
|
41
|
+
emailValidate: /^([\s\S])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,8})$/,
|
42
|
+
/**
|
43
|
+
* @description 密码验证
|
44
|
+
*/
|
45
|
+
// passwordValidate: /^(?![0-9]+$)(?![a-z]+$)(?![A-Z]+$)(?!([^(0-9a-zA-Z)])+$)^.{8,16}$/,
|
46
|
+
passwordValidate: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\da-zA-Z]).{8,}$/,
|
47
|
+
/**
|
48
|
+
* @description 空格验证
|
49
|
+
*/
|
50
|
+
spaceValidate: /^[^\s]*$/g,
|
51
|
+
};
|
52
|
+
var commonMessage = {
|
53
|
+
smallLenMessage: function (type) {
|
54
|
+
if (type === void 0) { type = ''; }
|
55
|
+
return instance.t('{{type}}超过最大字符长度200', { type: type });
|
56
|
+
},
|
57
|
+
middleLenMessage: function (type) {
|
58
|
+
if (type === void 0) { type = ''; }
|
59
|
+
return instance.t('{{type}}超过最大字符长度400', { type: type });
|
60
|
+
},
|
61
|
+
largeLenMessage: function (type) {
|
62
|
+
if (type === void 0) { type = ''; }
|
63
|
+
return instance.t('{{type}}超过最大字符长度600', { type: type });
|
64
|
+
},
|
65
|
+
maxlargeLenValidate: function (type) {
|
66
|
+
if (type === void 0) { type = ''; }
|
67
|
+
return instance.t('{{type}}超过最大字符长度5000', { type: type });
|
68
|
+
},
|
69
|
+
phoneMessage: instance.t('请输入正确的手机号'),
|
70
|
+
idCardMessage: instance.t('请输入正确的身份证'),
|
71
|
+
emailMessage: instance.t('请输入正确的邮箱'),
|
72
|
+
// passwordMessage: '密码由8-16位的字母+数字,字母+特殊字符,数字+特殊字符组成',
|
73
|
+
passwordMessage: instance.t('密码必须包含大小写字母、数字、特殊字符且最小长度为8,且不能出现连续数字或字符,不能出现相同字符,且禁止使用用户账号作为密码'),
|
74
|
+
spaceMessage: instance.t('请勿输入空格'),
|
75
|
+
};
|
76
|
+
var alphabet1 = [
|
77
|
+
'abcdefghijklmnopqrstuvwxyz',
|
78
|
+
'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
79
|
+
'0123456789',
|
80
|
+
];
|
81
|
+
var alphabet2 = ['qwertyuiop', 'asdfghjkl', 'zxcvbnm'];
|
82
|
+
var alphabet3 = ['qaz', 'wsx', 'edc', 'rfv', 'tgb', 'yhn', 'ujm'];
|
83
|
+
function isConsecutiveChars(char1, char2, alphabetArr) {
|
84
|
+
// const lowerCaseAlphabet = 'abcdefghijklmnopqrstuvwxyz'; // 小写字母
|
85
|
+
// const upperCaseAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; // 大写字母
|
86
|
+
// const numeric = '0123456789'; // 数字
|
87
|
+
// 找到包含两个字符的字符集
|
88
|
+
var alphabet = alphabetArr.find(function (alph) { return alph.includes(char1) && alph.includes(char2); });
|
89
|
+
if (!alphabet) {
|
90
|
+
return false; // 如果两个字符不在同一字符集中,那么它们不可能连续
|
91
|
+
}
|
92
|
+
var index1 = alphabet.indexOf(char1);
|
93
|
+
var index2 = alphabet.indexOf(char2);
|
94
|
+
// return Math.abs(index1 - index2) === 1; // 如果两个字符在字符集中的位置相邻,那么它们是连续的
|
95
|
+
return index1 - index2;
|
96
|
+
}
|
97
|
+
function validatePassword(password, username) {
|
98
|
+
// 用正则表达式检查密码基本规则
|
99
|
+
var regex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\da-zA-Z]).{8,}$/;
|
100
|
+
if (!regex.test(password)) {
|
101
|
+
return {
|
102
|
+
result: false,
|
103
|
+
message: instance.t('密码中必须包含大小写字母、数字、特殊字符,且长度必须大于8个字符!'),
|
104
|
+
};
|
105
|
+
}
|
106
|
+
// 检查密码是否与用户名相同
|
107
|
+
if (password === username) {
|
108
|
+
return {
|
109
|
+
result: false,
|
110
|
+
message: instance.t('密码与用户名相同!'),
|
111
|
+
};
|
112
|
+
}
|
113
|
+
// 检查密码中是否有相同且连续的字符 超过三次
|
114
|
+
var count1 = 0;
|
115
|
+
for (var i = 0; i < password.length - 1; i++) {
|
116
|
+
if (password[i] === password[i + 1]) {
|
117
|
+
count1++;
|
118
|
+
if (count1 >= 2) {
|
119
|
+
return {
|
120
|
+
result: false,
|
121
|
+
message: instance.t('密码中有相同且连续超过三次的字符!'),
|
122
|
+
};
|
123
|
+
}
|
124
|
+
}
|
125
|
+
else {
|
126
|
+
count1 = 0;
|
127
|
+
}
|
128
|
+
}
|
129
|
+
// 检查密码中是否有连续的字母或数字 连续超过三次
|
130
|
+
var count = 0;
|
131
|
+
var startChart = 0;
|
132
|
+
var currentConsecutiveCount = 0; // 记录上次是递增还是递减
|
133
|
+
// 第一次循环 找出 连续字母 数字
|
134
|
+
for (var i = 0; i < password.length - 1; i++) {
|
135
|
+
var consecutiveCount = isConsecutiveChars(password[i], password[i + 1], alphabet1);
|
136
|
+
// 是递增 还是 递减
|
137
|
+
if (consecutiveCount === 1 || consecutiveCount === -1) {
|
138
|
+
if (currentConsecutiveCount === 0) {
|
139
|
+
currentConsecutiveCount = consecutiveCount;
|
140
|
+
}
|
141
|
+
if (count === 0) {
|
142
|
+
startChart = i;
|
143
|
+
}
|
144
|
+
// 如果记录到上次跟本次的连续规则相同
|
145
|
+
if (currentConsecutiveCount === consecutiveCount) {
|
146
|
+
count++;
|
147
|
+
if (count >= 2) {
|
148
|
+
// 密码中不应含有连续的字母或数字
|
149
|
+
return {
|
150
|
+
result: false,
|
151
|
+
message: instance.t('从第{{slot0}}个字符开始,有连续{{slot1}}超过三位的字母或数字!', {
|
152
|
+
slot0: startChart + 1,
|
153
|
+
slot1: currentConsecutiveCount === 1 ? '递减' : '递增',
|
154
|
+
}),
|
155
|
+
};
|
156
|
+
}
|
157
|
+
}
|
158
|
+
else {
|
159
|
+
// 需要重置规则
|
160
|
+
count = 0;
|
161
|
+
startChart = 0;
|
162
|
+
}
|
163
|
+
currentConsecutiveCount = consecutiveCount;
|
164
|
+
}
|
165
|
+
else {
|
166
|
+
count = 0;
|
167
|
+
startChart = 0;
|
168
|
+
currentConsecutiveCount = 0;
|
169
|
+
}
|
170
|
+
}
|
171
|
+
// 第二次循环 找出键盘连续横排字母
|
172
|
+
for (var i = 0; i < password.length - 1; i++) {
|
173
|
+
var consecutiveCount = isConsecutiveChars(password[i], password[i + 1], alphabet2);
|
174
|
+
// 是递增 还是 递减
|
175
|
+
if (consecutiveCount === 1 || consecutiveCount === -1) {
|
176
|
+
if (currentConsecutiveCount === 0) {
|
177
|
+
currentConsecutiveCount = consecutiveCount;
|
178
|
+
}
|
179
|
+
if (count === 0) {
|
180
|
+
startChart = i;
|
181
|
+
}
|
182
|
+
// 如果记录到上次跟本次的连续规则相同
|
183
|
+
if (currentConsecutiveCount === consecutiveCount) {
|
184
|
+
count++;
|
185
|
+
if (count >= 2) {
|
186
|
+
// 密码中不应含有连续的字母或数字
|
187
|
+
return {
|
188
|
+
result: false,
|
189
|
+
message: instance.t('从第{{slot0}}个字符开始,有按键盘横向连续{{slot1}}超过三位的字母!', {
|
190
|
+
slot0: startChart + 1,
|
191
|
+
slot1: currentConsecutiveCount === 1 ? '递减' : '递增',
|
192
|
+
}),
|
193
|
+
};
|
194
|
+
}
|
195
|
+
}
|
196
|
+
else {
|
197
|
+
// 需要重置规则
|
198
|
+
count = 0;
|
199
|
+
startChart = 0;
|
200
|
+
}
|
201
|
+
currentConsecutiveCount = consecutiveCount;
|
202
|
+
}
|
203
|
+
else {
|
204
|
+
count = 0;
|
205
|
+
startChart = 0;
|
206
|
+
currentConsecutiveCount = 0;
|
207
|
+
}
|
208
|
+
}
|
209
|
+
// 第三次循环 找出键盘连续竖排字母
|
210
|
+
for (var i = 0; i < password.length - 1; i++) {
|
211
|
+
var consecutiveCount = isConsecutiveChars(password[i], password[i + 1], alphabet3);
|
212
|
+
// 是递增 还是 递减
|
213
|
+
if (consecutiveCount === 1 || consecutiveCount === -1) {
|
214
|
+
if (currentConsecutiveCount === 0) {
|
215
|
+
currentConsecutiveCount = consecutiveCount;
|
216
|
+
}
|
217
|
+
if (count === 0) {
|
218
|
+
startChart = i;
|
219
|
+
}
|
220
|
+
// 如果记录到上次跟本次的连续规则相同
|
221
|
+
if (currentConsecutiveCount === consecutiveCount) {
|
222
|
+
count++;
|
223
|
+
if (count >= 2) {
|
224
|
+
// 密码中不应含有连续的字母或数字
|
225
|
+
return {
|
226
|
+
result: false,
|
227
|
+
message: instance.t('从第{{slot0}}个字符开始,有按键盘竖向连续{{slot1}}超过三位的字母或数字!', {
|
228
|
+
slot0: startChart + 1,
|
229
|
+
slot1: currentConsecutiveCount === 1 ? '递减' : '递增',
|
230
|
+
}),
|
231
|
+
};
|
232
|
+
}
|
233
|
+
}
|
234
|
+
else {
|
235
|
+
// 需要重置规则
|
236
|
+
count = 0;
|
237
|
+
startChart = 0;
|
238
|
+
}
|
239
|
+
currentConsecutiveCount = consecutiveCount;
|
240
|
+
}
|
241
|
+
else {
|
242
|
+
count = 0;
|
243
|
+
startChart = 0;
|
244
|
+
currentConsecutiveCount = 0;
|
245
|
+
}
|
246
|
+
}
|
247
|
+
// 如果通过了所有的检查,则返回true
|
248
|
+
return {
|
249
|
+
result: true,
|
250
|
+
};
|
251
|
+
}
|
252
|
+
|
253
|
+
var validate$1 = /*#__PURE__*/Object.freeze({
|
254
|
+
__proto__: null,
|
255
|
+
validatePassword: validatePassword,
|
256
|
+
validate: validate,
|
257
|
+
commonMessage: commonMessage
|
258
|
+
});
|
259
|
+
|
260
|
+
export { validatePassword as a, validate as b, commonMessage as c, validate$1 as v };
|
package/dist/validate.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
import './i18next.js';
|
2
|
-
export { c as commonMessage, b as validate, a as validatePassword } from './validate-
|
2
|
+
export { c as commonMessage, b as validate, a as validatePassword } from './validate-21b58a69.js';
|