@whitesev/utils 2.6.2 → 2.6.4
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 +25 -7
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +25 -7
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +25 -7
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +25 -7
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +25 -7
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +25 -7
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/UtilsGMCookie.d.ts +4 -0
- package/dist/types/src/types/UtilsGMCookie.d.ts +2 -2
- package/package.json +1 -1
- package/src/Utils.ts +1 -1
- package/src/UtilsGMCookie.ts +24 -7
- package/src/types/UtilsGMCookie.d.ts +2 -2
package/dist/index.amd.js
CHANGED
|
@@ -236,6 +236,15 @@ define((function () { 'use strict';
|
|
|
236
236
|
this.windowApi = Object.assign({}, windowApiOption);
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
|
+
/**
|
|
240
|
+
* 获取Cookie分组
|
|
241
|
+
*/
|
|
242
|
+
getCookiesList() {
|
|
243
|
+
if (this.windowApi.document.cookie.trim() === "") {
|
|
244
|
+
return [];
|
|
245
|
+
}
|
|
246
|
+
return this.windowApi.document.cookie.split(";");
|
|
247
|
+
}
|
|
239
248
|
/**
|
|
240
249
|
* 获取单个cookie
|
|
241
250
|
* @param cookieName cookie名
|
|
@@ -244,7 +253,7 @@ define((function () { 'use strict';
|
|
|
244
253
|
if (typeof cookieName !== "string") {
|
|
245
254
|
throw new TypeError("Utils.GMCookie.get 参数cookieName 必须为字符串");
|
|
246
255
|
}
|
|
247
|
-
let cookies = this.
|
|
256
|
+
let cookies = this.getCookiesList();
|
|
248
257
|
let findValue = undefined;
|
|
249
258
|
for (const cookieItem of cookies) {
|
|
250
259
|
let item = cookieItem.trim();
|
|
@@ -290,7 +299,7 @@ define((function () { 'use strict';
|
|
|
290
299
|
path: "/",
|
|
291
300
|
};
|
|
292
301
|
defaultOption = utils.assign(defaultOption, option);
|
|
293
|
-
let cookies = this.
|
|
302
|
+
let cookies = this.getCookiesList();
|
|
294
303
|
cookies.forEach((item) => {
|
|
295
304
|
item = item.trim();
|
|
296
305
|
let itemSplit = item.split("=");
|
|
@@ -341,7 +350,7 @@ define((function () { 'use strict';
|
|
|
341
350
|
path: "/",
|
|
342
351
|
};
|
|
343
352
|
defaultOption = utils.assign(defaultOption, option);
|
|
344
|
-
let cookies = this.
|
|
353
|
+
let cookies = this.getCookiesList();
|
|
345
354
|
cookies.forEach((item) => {
|
|
346
355
|
item = item.trim();
|
|
347
356
|
let itemSplit = item.split("=");
|
|
@@ -380,7 +389,7 @@ define((function () { 'use strict';
|
|
|
380
389
|
url: this.windowApi.window.location.href,
|
|
381
390
|
name: "",
|
|
382
391
|
value: "",
|
|
383
|
-
domain:
|
|
392
|
+
domain: "",
|
|
384
393
|
path: "/",
|
|
385
394
|
secure: true,
|
|
386
395
|
httpOnly: false,
|
|
@@ -399,6 +408,9 @@ define((function () { 'use strict';
|
|
|
399
408
|
";expires=" +
|
|
400
409
|
new Date(life).toGMTString() +
|
|
401
410
|
"; path=/";
|
|
411
|
+
if (utils.isNotNull(defaultOption.domain)) {
|
|
412
|
+
cookieStr += "; domain=" + defaultOption.domain;
|
|
413
|
+
}
|
|
402
414
|
this.windowApi.document.cookie = cookieStr;
|
|
403
415
|
}
|
|
404
416
|
catch (error) {
|
|
@@ -422,10 +434,13 @@ define((function () { 'use strict';
|
|
|
422
434
|
url: this.windowApi.window.location.href,
|
|
423
435
|
name: "",
|
|
424
436
|
path: "/",
|
|
425
|
-
firstPartyDomain:
|
|
437
|
+
firstPartyDomain: "",
|
|
426
438
|
};
|
|
427
439
|
defaultOption = utils.assign(defaultOption, option);
|
|
428
|
-
let cookieStr = `${defaultOption.name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=${defaultOption.path}
|
|
440
|
+
let cookieStr = `${defaultOption.name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=${defaultOption.path}`;
|
|
441
|
+
if (utils.isNotNull(defaultOption.firstPartyDomain)) {
|
|
442
|
+
cookieStr += `; domain=${defaultOption.firstPartyDomain};`;
|
|
443
|
+
}
|
|
429
444
|
this.windowApi.document.cookie = cookieStr;
|
|
430
445
|
}
|
|
431
446
|
catch (error) {
|
|
@@ -443,6 +458,9 @@ define((function () { 'use strict';
|
|
|
443
458
|
* @param cookieStr
|
|
444
459
|
*/
|
|
445
460
|
parseCookie(cookieStr) {
|
|
461
|
+
if (cookieStr.trim() === "") {
|
|
462
|
+
return [];
|
|
463
|
+
}
|
|
446
464
|
let cookies = cookieStr.split(";");
|
|
447
465
|
let result = [];
|
|
448
466
|
for (const cookieItem of cookies) {
|
|
@@ -5037,7 +5055,7 @@ define((function () { 'use strict';
|
|
|
5037
5055
|
this.windowApi = new WindowApi(option);
|
|
5038
5056
|
}
|
|
5039
5057
|
/** 版本号 */
|
|
5040
|
-
version = "2025.3.
|
|
5058
|
+
version = "2025.3.25";
|
|
5041
5059
|
addStyle(cssText) {
|
|
5042
5060
|
if (typeof cssText !== "string") {
|
|
5043
5061
|
throw new Error("Utils.addStyle 参数cssText 必须为String类型");
|