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