@whitesev/utils 2.9.5 → 2.9.7
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/index.amd.js +49 -36
- package/dist/index.amd.js.map +1 -1
- package/dist/index.amd.min.js +1 -1
- package/dist/index.amd.min.js.map +1 -1
- package/dist/index.cjs.js +49 -36
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.cjs.min.js.map +1 -1
- package/dist/index.esm.js +49 -36
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.iife.js +49 -36
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.iife.min.js.map +1 -1
- package/dist/index.system.js +49 -36
- package/dist/index.system.js.map +1 -1
- package/dist/index.system.min.js +1 -1
- package/dist/index.system.min.js.map +1 -1
- package/dist/index.umd.js +49 -36
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/types/src/UtilsGMCookie.d.ts +3 -2
- package/dist/types/src/UtilsGMMenu.d.ts +4 -4
- package/package.json +3 -3
- package/src/ColorConversion.ts +6 -0
- package/src/CommonUtil.ts +33 -31
- package/src/UtilsGMCookie.ts +3 -2
- package/src/UtilsGMMenu.ts +7 -7
package/dist/index.esm.js
CHANGED
|
@@ -77,6 +77,9 @@ class ColorConversion {
|
|
|
77
77
|
if (typeof level !== "number") {
|
|
78
78
|
level = Number(level);
|
|
79
79
|
}
|
|
80
|
+
if (isNaN(level)) {
|
|
81
|
+
throw new TypeError(`输入错误的level:${level}`);
|
|
82
|
+
}
|
|
80
83
|
const rgbc = this.hexToRgb(color);
|
|
81
84
|
for (let index = 0; index < 3; index++) {
|
|
82
85
|
const rgbcItemValue = rgbc[index];
|
|
@@ -97,6 +100,9 @@ class ColorConversion {
|
|
|
97
100
|
if (typeof level !== "number") {
|
|
98
101
|
level = Number(level);
|
|
99
102
|
}
|
|
103
|
+
if (isNaN(level)) {
|
|
104
|
+
throw new TypeError(`输入错误的level:${level}`);
|
|
105
|
+
}
|
|
100
106
|
const rgbc = this.hexToRgb(color);
|
|
101
107
|
for (let index = 0; index < 3; index++) {
|
|
102
108
|
const rgbcItemValue = Number(rgbc[index]);
|
|
@@ -304,38 +310,44 @@ class CommonUtil {
|
|
|
304
310
|
if (target == null) {
|
|
305
311
|
target = {};
|
|
306
312
|
}
|
|
313
|
+
// 当前遍历的目标对象
|
|
314
|
+
let iteratorTarget;
|
|
307
315
|
if (isAdd) {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
const targetValue = Reflect.get(target, targetKeyName);
|
|
311
|
-
const sourceValue = Reflect.get(source, sourceKeyName);
|
|
312
|
-
if (typeof sourceValue === "object" &&
|
|
313
|
-
sourceValue != null &&
|
|
314
|
-
sourceKeyName in target &&
|
|
315
|
-
!UtilsContext.isDOM(sourceValue)) {
|
|
316
|
-
/* 源端的值是object类型,且不是元素节点 */
|
|
317
|
-
Reflect.set(target, sourceKeyName, UtilsContext.assign(targetValue, sourceValue, isAdd));
|
|
318
|
-
continue;
|
|
319
|
-
}
|
|
320
|
-
Reflect.set(target, sourceKeyName, sourceValue);
|
|
321
|
-
}
|
|
316
|
+
// 追加并覆盖是以source为准
|
|
317
|
+
iteratorTarget = source;
|
|
322
318
|
}
|
|
323
319
|
else {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
320
|
+
// 覆盖以target为准
|
|
321
|
+
iteratorTarget = target;
|
|
322
|
+
}
|
|
323
|
+
for (const keyName in iteratorTarget) {
|
|
324
|
+
if (!isAdd && !(keyName in source)) {
|
|
325
|
+
// 仅替换 但是源端没有此键
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
const targetValue = Reflect.get(target, keyName);
|
|
329
|
+
const sourceValue = Reflect.get(source, keyName);
|
|
330
|
+
if (typeof sourceValue === "object" &&
|
|
331
|
+
sourceValue != null &&
|
|
332
|
+
keyName in target &&
|
|
333
|
+
!UtilsContext.isDOM(sourceValue)) {
|
|
334
|
+
// 源端的值是object类型,且不是元素节点
|
|
335
|
+
// 如果是数组,那此数组中有值,清空旧的数组再赋值
|
|
336
|
+
let childObjectValue;
|
|
337
|
+
if (Array.isArray(sourceValue)) {
|
|
338
|
+
if (Array.isArray(targetValue)) {
|
|
339
|
+
targetValue.length = 0;
|
|
335
340
|
}
|
|
336
|
-
|
|
337
|
-
|
|
341
|
+
childObjectValue = sourceValue;
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
childObjectValue = UtilsContext.assign(targetValue, sourceValue, isAdd);
|
|
338
345
|
}
|
|
346
|
+
Reflect.set(target, keyName, childObjectValue);
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
/* 直接赋值 */
|
|
350
|
+
Reflect.set(target, keyName, sourceValue);
|
|
339
351
|
}
|
|
340
352
|
}
|
|
341
353
|
return target;
|
|
@@ -580,7 +592,7 @@ class UtilsGMCookie {
|
|
|
580
592
|
}
|
|
581
593
|
}
|
|
582
594
|
/**
|
|
583
|
-
*
|
|
595
|
+
* 获取多组Cookie
|
|
584
596
|
* @param option 配置
|
|
585
597
|
**/
|
|
586
598
|
getList(option) {
|
|
@@ -693,7 +705,8 @@ class UtilsGMCookie {
|
|
|
693
705
|
}
|
|
694
706
|
}
|
|
695
707
|
/**
|
|
696
|
-
* 解析cookie
|
|
708
|
+
* 解析cookie字符串,按`;`分割
|
|
709
|
+
*
|
|
697
710
|
* 例如:document.cookie
|
|
698
711
|
* @param cookieStr
|
|
699
712
|
*/
|
|
@@ -2110,31 +2123,31 @@ class GMMenu {
|
|
|
2110
2123
|
}
|
|
2111
2124
|
/**
|
|
2112
2125
|
* 设置当enable为true时默认显示在菜单中前面的emoji图标
|
|
2113
|
-
* @param emojiString
|
|
2126
|
+
* @param emojiString emoji字符串
|
|
2114
2127
|
*/
|
|
2115
2128
|
setEnableTrueEmoji(emojiString) {
|
|
2116
2129
|
if (typeof emojiString !== "string") {
|
|
2117
|
-
throw new
|
|
2130
|
+
throw new TypeError("参数emojiString必须是string类型");
|
|
2118
2131
|
}
|
|
2119
2132
|
this.MenuHandle.$emoji.success = emojiString;
|
|
2120
2133
|
}
|
|
2121
2134
|
/**
|
|
2122
2135
|
* 设置当enable为false时默认显示在菜单中前面的emoji图标
|
|
2123
|
-
* @param emojiString
|
|
2136
|
+
* @param emojiString emoji字符串
|
|
2124
2137
|
*/
|
|
2125
2138
|
setEnableFalseEmoji(emojiString) {
|
|
2126
2139
|
if (typeof emojiString !== "string") {
|
|
2127
|
-
throw new
|
|
2140
|
+
throw new TypeError("参数emojiString必须是string类型");
|
|
2128
2141
|
}
|
|
2129
2142
|
this.MenuHandle.$emoji.error = emojiString;
|
|
2130
2143
|
}
|
|
2131
2144
|
/**
|
|
2132
2145
|
* 设置本地存储的菜单外部的键名
|
|
2133
|
-
* @param keyName
|
|
2146
|
+
* @param keyName 键名
|
|
2134
2147
|
*/
|
|
2135
2148
|
setLocalStorageKeyName(keyName) {
|
|
2136
2149
|
if (typeof keyName !== "string") {
|
|
2137
|
-
throw new
|
|
2150
|
+
throw new TypeError("参数keyName必须是string类型");
|
|
2138
2151
|
}
|
|
2139
2152
|
this.MenuHandle.$data.key = keyName;
|
|
2140
2153
|
}
|
|
@@ -5483,7 +5496,7 @@ class DOMUtils {
|
|
|
5483
5496
|
}
|
|
5484
5497
|
const domUtils = new DOMUtils();
|
|
5485
5498
|
|
|
5486
|
-
const version = "2.9.
|
|
5499
|
+
const version = "2.9.7";
|
|
5487
5500
|
|
|
5488
5501
|
class Utils {
|
|
5489
5502
|
windowApi;
|