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