tools-min-ns 1.9.6 → 1.9.8

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/README.md CHANGED
@@ -5,6 +5,13 @@ cnpm i tools-min-ns --save
5
5
  ```
6
6
 
7
7
  # updates
8
+ ## v1.9.8
9
+
10
+ > PasswordUtil aes加解密使用URL编码和解码
11
+
12
+ ## v1.9.7
13
+
14
+ > DateUtil 月份错误bug修复
8
15
 
9
16
  ## v1.9.6
10
17
 
@@ -22,6 +29,7 @@ cnpm i tools-min-ns --save
22
29
  ## v1.9.3
23
30
 
24
31
  > DateUtil 优化并新增isDateInYearAndMonth方法
32
+ >
25
33
  > UrlUtil 优化getUrlRequest在web,h5中的路由为hash的兼容性
26
34
 
27
35
  ## v1.9.2
@@ -55,8 +63,11 @@ cnpm i tools-min-ns --save
55
63
  ## v1.7.0
56
64
 
57
65
  > 新增FileUtil
66
+ >
58
67
  > ObjectUtil 新增getHash
68
+ >
59
69
  > StringUtil 新增getHash
70
+ >
60
71
  > BrowserUtil 新增getIdSync
61
72
 
62
73
  ## v1.6.0
@@ -80,7 +91,9 @@ getDateDiff 修复
80
91
  2. 优化浏览器判断
81
92
 
82
93
  > 新增CookieUtil cookie增删改查
94
+ >
83
95
  > 新增EnvUtil 环境判断
96
+ >
84
97
  > 新增RequestUtil 请求工具
85
98
 
86
99
  ## v1.4.0
@@ -114,7 +114,7 @@ declare namespace DateUtil {
114
114
  * @param {Number} year 年份
115
115
  * @param {Number} month 月份 (1-12)
116
116
  * @example
117
- * getDaysInMonth(2012,2) => 31
117
+ * getDaysInMonth(2012,3) => 31
118
118
  */
119
119
  const getDaysInMonth: (year: string | number, month: string | number) => number;
120
120
  /**
@@ -315,7 +315,7 @@ var DateUtil;
315
315
  } else {
316
316
  result.setMonth(result.getMonth() + (diff.month || 0));
317
317
  }
318
- result.setDate(Math.min(n, DateUtil.getDaysInMonth(result.getFullYear(), result.getMonth())));
318
+ result.setDate(Math.min(n, DateUtil.getDaysInMonth(result.getFullYear(), result.getMonth() + 1)));
319
319
  // 处理 year
320
320
  var m = result.getDate();
321
321
  result.setDate(1);
@@ -324,7 +324,7 @@ var DateUtil;
324
324
  } else {
325
325
  result.setFullYear(result.getFullYear() + (diff.year || 0));
326
326
  }
327
- result.setDate(Math.min(m, DateUtil.getDaysInMonth(result.getFullYear(), result.getMonth())));
327
+ result.setDate(Math.min(m, DateUtil.getDaysInMonth(result.getFullYear(), result.getMonth() + 1)));
328
328
  return result;
329
329
  };
330
330
  /**
@@ -346,7 +346,7 @@ var DateUtil;
346
346
  * @param {Number} year 年份
347
347
  * @param {Number} month 月份 (1-12)
348
348
  * @example
349
- * getDaysInMonth(2012,2) => 31
349
+ * getDaysInMonth(2012,3) => 31
350
350
  */
351
351
  DateUtil.getDaysInMonth = function (year, month) {
352
352
  return [31, DateUtil.isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][Number(month) - 1];
@@ -421,7 +421,7 @@ var DateUtil;
421
421
  millsecond: 1
422
422
  });
423
423
  case 'MONTH':
424
- return new Date(parts.Year, parts.Month, DateUtil.getDaysInMonth(parts.Year, parts.Month), 23, 59, 59, 999);
424
+ return new Date(parts.Year, parts.Month, DateUtil.getDaysInMonth(parts.Year, parts.Month + 1), 23, 59, 59, 999);
425
425
  case 'WEEK':
426
426
  var year = date.getFullYear();
427
427
  var month = date.getMonth();
@@ -12,7 +12,7 @@ declare namespace PasswordUtil {
12
12
  * @example
13
13
  * strEncrypt('XX') => 3f231e9c5040a51a663a4e12ddd509fc31f201caf95f
14
14
  */
15
- const strEncrypt: (str: string, pwd?: string) => any;
15
+ const strEncrypt: (str: string, pwd?: string) => string;
16
16
  /**
17
17
  * AES解密函数
18
18
  * @param str 待解密字符串
@@ -29,7 +29,7 @@ var PasswordUtil;
29
29
  mode: CryptoJS.mode.ECB,
30
30
  padding: CryptoJS.pad.Pkcs7
31
31
  });
32
- return encrypted.toString();
32
+ return encodeURIComponent(encrypted.toString());
33
33
  };
34
34
  /**
35
35
  * AES解密函数
@@ -44,7 +44,7 @@ var PasswordUtil;
44
44
  }
45
45
  if (str == '') return '';
46
46
  var key = CryptoJS.enc.Utf8.parse(pwd);
47
- var decrypt = CryptoJS.AES.decrypt(str, key, {
47
+ var decrypt = CryptoJS.AES.decrypt(decodeURIComponent(str), key, {
48
48
  mode: CryptoJS.mode.ECB,
49
49
  padding: CryptoJS.pad.Pkcs7
50
50
  });
@@ -114,7 +114,7 @@ declare namespace DateUtil {
114
114
  * @param {Number} year 年份
115
115
  * @param {Number} month 月份 (1-12)
116
116
  * @example
117
- * getDaysInMonth(2012,2) => 31
117
+ * getDaysInMonth(2012,3) => 31
118
118
  */
119
119
  const getDaysInMonth: (year: string | number, month: string | number) => number;
120
120
  /**
@@ -325,7 +325,7 @@ var DateUtil;
325
325
  } else {
326
326
  result.setMonth(result.getMonth() + (diff.month || 0));
327
327
  }
328
- result.setDate(Math.min(n, DateUtil.getDaysInMonth(result.getFullYear(), result.getMonth())));
328
+ result.setDate(Math.min(n, DateUtil.getDaysInMonth(result.getFullYear(), result.getMonth() + 1)));
329
329
  // 处理 year
330
330
  var m = result.getDate();
331
331
  result.setDate(1);
@@ -334,7 +334,7 @@ var DateUtil;
334
334
  } else {
335
335
  result.setFullYear(result.getFullYear() + (diff.year || 0));
336
336
  }
337
- result.setDate(Math.min(m, DateUtil.getDaysInMonth(result.getFullYear(), result.getMonth())));
337
+ result.setDate(Math.min(m, DateUtil.getDaysInMonth(result.getFullYear(), result.getMonth() + 1)));
338
338
  return result;
339
339
  };
340
340
  /**
@@ -356,7 +356,7 @@ var DateUtil;
356
356
  * @param {Number} year 年份
357
357
  * @param {Number} month 月份 (1-12)
358
358
  * @example
359
- * getDaysInMonth(2012,2) => 31
359
+ * getDaysInMonth(2012,3) => 31
360
360
  */
361
361
  DateUtil.getDaysInMonth = function (year, month) {
362
362
  return [31, DateUtil.isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][Number(month) - 1];
@@ -431,7 +431,7 @@ var DateUtil;
431
431
  millsecond: 1
432
432
  });
433
433
  case 'MONTH':
434
- return new Date(parts.Year, parts.Month, DateUtil.getDaysInMonth(parts.Year, parts.Month), 23, 59, 59, 999);
434
+ return new Date(parts.Year, parts.Month, DateUtil.getDaysInMonth(parts.Year, parts.Month + 1), 23, 59, 59, 999);
435
435
  case 'WEEK':
436
436
  var year = date.getFullYear();
437
437
  var month = date.getMonth();
@@ -12,7 +12,7 @@ declare namespace PasswordUtil {
12
12
  * @example
13
13
  * strEncrypt('XX') => 3f231e9c5040a51a663a4e12ddd509fc31f201caf95f
14
14
  */
15
- const strEncrypt: (str: string, pwd?: string) => any;
15
+ const strEncrypt: (str: string, pwd?: string) => string;
16
16
  /**
17
17
  * AES解密函数
18
18
  * @param str 待解密字符串
@@ -39,7 +39,7 @@ var PasswordUtil;
39
39
  mode: CryptoJS.mode.ECB,
40
40
  padding: CryptoJS.pad.Pkcs7
41
41
  });
42
- return encrypted.toString();
42
+ return encodeURIComponent(encrypted.toString());
43
43
  };
44
44
  /**
45
45
  * AES解密函数
@@ -54,7 +54,7 @@ var PasswordUtil;
54
54
  }
55
55
  if (str == '') return '';
56
56
  var key = CryptoJS.enc.Utf8.parse(pwd);
57
- var decrypt = CryptoJS.AES.decrypt(str, key, {
57
+ var decrypt = CryptoJS.AES.decrypt(decodeURIComponent(str), key, {
58
58
  mode: CryptoJS.mode.ECB,
59
59
  padding: CryptoJS.pad.Pkcs7
60
60
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tools-min-ns",
3
3
  "description": "工具包适用于前端以及node",
4
- "version": "1.9.6",
4
+ "version": "1.9.8",
5
5
  "main": "lib/index.js",
6
6
  "license": "MIT",
7
7
  "author": "nanshen",