@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.umd.js
CHANGED
|
@@ -83,6 +83,9 @@
|
|
|
83
83
|
if (typeof level !== "number") {
|
|
84
84
|
level = Number(level);
|
|
85
85
|
}
|
|
86
|
+
if (isNaN(level)) {
|
|
87
|
+
throw new TypeError(`输入错误的level:${level}`);
|
|
88
|
+
}
|
|
86
89
|
const rgbc = this.hexToRgb(color);
|
|
87
90
|
for (let index = 0; index < 3; index++) {
|
|
88
91
|
const rgbcItemValue = rgbc[index];
|
|
@@ -103,6 +106,9 @@
|
|
|
103
106
|
if (typeof level !== "number") {
|
|
104
107
|
level = Number(level);
|
|
105
108
|
}
|
|
109
|
+
if (isNaN(level)) {
|
|
110
|
+
throw new TypeError(`输入错误的level:${level}`);
|
|
111
|
+
}
|
|
106
112
|
const rgbc = this.hexToRgb(color);
|
|
107
113
|
for (let index = 0; index < 3; index++) {
|
|
108
114
|
const rgbcItemValue = Number(rgbc[index]);
|
|
@@ -310,38 +316,44 @@
|
|
|
310
316
|
if (target == null) {
|
|
311
317
|
target = {};
|
|
312
318
|
}
|
|
319
|
+
// 当前遍历的目标对象
|
|
320
|
+
let iteratorTarget;
|
|
313
321
|
if (isAdd) {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
const targetValue = Reflect.get(target, targetKeyName);
|
|
317
|
-
const sourceValue = Reflect.get(source, sourceKeyName);
|
|
318
|
-
if (typeof sourceValue === "object" &&
|
|
319
|
-
sourceValue != null &&
|
|
320
|
-
sourceKeyName in target &&
|
|
321
|
-
!UtilsContext.isDOM(sourceValue)) {
|
|
322
|
-
/* 源端的值是object类型,且不是元素节点 */
|
|
323
|
-
Reflect.set(target, sourceKeyName, UtilsContext.assign(targetValue, sourceValue, isAdd));
|
|
324
|
-
continue;
|
|
325
|
-
}
|
|
326
|
-
Reflect.set(target, sourceKeyName, sourceValue);
|
|
327
|
-
}
|
|
322
|
+
// 追加并覆盖是以source为准
|
|
323
|
+
iteratorTarget = source;
|
|
328
324
|
}
|
|
329
325
|
else {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
326
|
+
// 覆盖以target为准
|
|
327
|
+
iteratorTarget = target;
|
|
328
|
+
}
|
|
329
|
+
for (const keyName in iteratorTarget) {
|
|
330
|
+
if (!isAdd && !(keyName in source)) {
|
|
331
|
+
// 仅替换 但是源端没有此键
|
|
332
|
+
continue;
|
|
333
|
+
}
|
|
334
|
+
const targetValue = Reflect.get(target, keyName);
|
|
335
|
+
const sourceValue = Reflect.get(source, keyName);
|
|
336
|
+
if (typeof sourceValue === "object" &&
|
|
337
|
+
sourceValue != null &&
|
|
338
|
+
keyName in target &&
|
|
339
|
+
!UtilsContext.isDOM(sourceValue)) {
|
|
340
|
+
// 源端的值是object类型,且不是元素节点
|
|
341
|
+
// 如果是数组,那此数组中有值,清空旧的数组再赋值
|
|
342
|
+
let childObjectValue;
|
|
343
|
+
if (Array.isArray(sourceValue)) {
|
|
344
|
+
if (Array.isArray(targetValue)) {
|
|
345
|
+
targetValue.length = 0;
|
|
341
346
|
}
|
|
342
|
-
|
|
343
|
-
|
|
347
|
+
childObjectValue = sourceValue;
|
|
348
|
+
}
|
|
349
|
+
else {
|
|
350
|
+
childObjectValue = UtilsContext.assign(targetValue, sourceValue, isAdd);
|
|
344
351
|
}
|
|
352
|
+
Reflect.set(target, keyName, childObjectValue);
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
/* 直接赋值 */
|
|
356
|
+
Reflect.set(target, keyName, sourceValue);
|
|
345
357
|
}
|
|
346
358
|
}
|
|
347
359
|
return target;
|
|
@@ -586,7 +598,7 @@
|
|
|
586
598
|
}
|
|
587
599
|
}
|
|
588
600
|
/**
|
|
589
|
-
*
|
|
601
|
+
* 获取多组Cookie
|
|
590
602
|
* @param option 配置
|
|
591
603
|
**/
|
|
592
604
|
getList(option) {
|
|
@@ -699,7 +711,8 @@
|
|
|
699
711
|
}
|
|
700
712
|
}
|
|
701
713
|
/**
|
|
702
|
-
* 解析cookie
|
|
714
|
+
* 解析cookie字符串,按`;`分割
|
|
715
|
+
*
|
|
703
716
|
* 例如:document.cookie
|
|
704
717
|
* @param cookieStr
|
|
705
718
|
*/
|
|
@@ -2116,31 +2129,31 @@
|
|
|
2116
2129
|
}
|
|
2117
2130
|
/**
|
|
2118
2131
|
* 设置当enable为true时默认显示在菜单中前面的emoji图标
|
|
2119
|
-
* @param emojiString
|
|
2132
|
+
* @param emojiString emoji字符串
|
|
2120
2133
|
*/
|
|
2121
2134
|
setEnableTrueEmoji(emojiString) {
|
|
2122
2135
|
if (typeof emojiString !== "string") {
|
|
2123
|
-
throw new
|
|
2136
|
+
throw new TypeError("参数emojiString必须是string类型");
|
|
2124
2137
|
}
|
|
2125
2138
|
this.MenuHandle.$emoji.success = emojiString;
|
|
2126
2139
|
}
|
|
2127
2140
|
/**
|
|
2128
2141
|
* 设置当enable为false时默认显示在菜单中前面的emoji图标
|
|
2129
|
-
* @param emojiString
|
|
2142
|
+
* @param emojiString emoji字符串
|
|
2130
2143
|
*/
|
|
2131
2144
|
setEnableFalseEmoji(emojiString) {
|
|
2132
2145
|
if (typeof emojiString !== "string") {
|
|
2133
|
-
throw new
|
|
2146
|
+
throw new TypeError("参数emojiString必须是string类型");
|
|
2134
2147
|
}
|
|
2135
2148
|
this.MenuHandle.$emoji.error = emojiString;
|
|
2136
2149
|
}
|
|
2137
2150
|
/**
|
|
2138
2151
|
* 设置本地存储的菜单外部的键名
|
|
2139
|
-
* @param keyName
|
|
2152
|
+
* @param keyName 键名
|
|
2140
2153
|
*/
|
|
2141
2154
|
setLocalStorageKeyName(keyName) {
|
|
2142
2155
|
if (typeof keyName !== "string") {
|
|
2143
|
-
throw new
|
|
2156
|
+
throw new TypeError("参数keyName必须是string类型");
|
|
2144
2157
|
}
|
|
2145
2158
|
this.MenuHandle.$data.key = keyName;
|
|
2146
2159
|
}
|
|
@@ -5489,7 +5502,7 @@
|
|
|
5489
5502
|
}
|
|
5490
5503
|
const domUtils = new DOMUtils();
|
|
5491
5504
|
|
|
5492
|
-
const version = "2.9.
|
|
5505
|
+
const version = "2.9.7";
|
|
5493
5506
|
|
|
5494
5507
|
class Utils {
|
|
5495
5508
|
windowApi;
|