@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.system.js
CHANGED
|
@@ -239,6 +239,15 @@ System.register('Utils', [], (function (exports) {
|
|
|
239
239
|
this.windowApi = Object.assign({}, windowApiOption);
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
|
+
/**
|
|
243
|
+
* 获取Cookie分组
|
|
244
|
+
*/
|
|
245
|
+
getCookiesList() {
|
|
246
|
+
if (this.windowApi.document.cookie.trim() === "") {
|
|
247
|
+
return [];
|
|
248
|
+
}
|
|
249
|
+
return this.windowApi.document.cookie.split(";");
|
|
250
|
+
}
|
|
242
251
|
/**
|
|
243
252
|
* 获取单个cookie
|
|
244
253
|
* @param cookieName cookie名
|
|
@@ -247,7 +256,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
247
256
|
if (typeof cookieName !== "string") {
|
|
248
257
|
throw new TypeError("Utils.GMCookie.get 参数cookieName 必须为字符串");
|
|
249
258
|
}
|
|
250
|
-
let cookies = this.
|
|
259
|
+
let cookies = this.getCookiesList();
|
|
251
260
|
let findValue = undefined;
|
|
252
261
|
for (const cookieItem of cookies) {
|
|
253
262
|
let item = cookieItem.trim();
|
|
@@ -293,7 +302,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
293
302
|
path: "/",
|
|
294
303
|
};
|
|
295
304
|
defaultOption = utils.assign(defaultOption, option);
|
|
296
|
-
let cookies = this.
|
|
305
|
+
let cookies = this.getCookiesList();
|
|
297
306
|
cookies.forEach((item) => {
|
|
298
307
|
item = item.trim();
|
|
299
308
|
let itemSplit = item.split("=");
|
|
@@ -344,7 +353,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
344
353
|
path: "/",
|
|
345
354
|
};
|
|
346
355
|
defaultOption = utils.assign(defaultOption, option);
|
|
347
|
-
let cookies = this.
|
|
356
|
+
let cookies = this.getCookiesList();
|
|
348
357
|
cookies.forEach((item) => {
|
|
349
358
|
item = item.trim();
|
|
350
359
|
let itemSplit = item.split("=");
|
|
@@ -383,7 +392,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
383
392
|
url: this.windowApi.window.location.href,
|
|
384
393
|
name: "",
|
|
385
394
|
value: "",
|
|
386
|
-
domain:
|
|
395
|
+
domain: "",
|
|
387
396
|
path: "/",
|
|
388
397
|
secure: true,
|
|
389
398
|
httpOnly: false,
|
|
@@ -402,6 +411,9 @@ System.register('Utils', [], (function (exports) {
|
|
|
402
411
|
";expires=" +
|
|
403
412
|
new Date(life).toGMTString() +
|
|
404
413
|
"; path=/";
|
|
414
|
+
if (utils.isNotNull(defaultOption.domain)) {
|
|
415
|
+
cookieStr += "; domain=" + defaultOption.domain;
|
|
416
|
+
}
|
|
405
417
|
this.windowApi.document.cookie = cookieStr;
|
|
406
418
|
}
|
|
407
419
|
catch (error) {
|
|
@@ -425,10 +437,13 @@ System.register('Utils', [], (function (exports) {
|
|
|
425
437
|
url: this.windowApi.window.location.href,
|
|
426
438
|
name: "",
|
|
427
439
|
path: "/",
|
|
428
|
-
firstPartyDomain:
|
|
440
|
+
firstPartyDomain: "",
|
|
429
441
|
};
|
|
430
442
|
defaultOption = utils.assign(defaultOption, option);
|
|
431
|
-
let cookieStr = `${defaultOption.name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=${defaultOption.path}
|
|
443
|
+
let cookieStr = `${defaultOption.name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=${defaultOption.path}`;
|
|
444
|
+
if (utils.isNotNull(defaultOption.firstPartyDomain)) {
|
|
445
|
+
cookieStr += `; domain=${defaultOption.firstPartyDomain};`;
|
|
446
|
+
}
|
|
432
447
|
this.windowApi.document.cookie = cookieStr;
|
|
433
448
|
}
|
|
434
449
|
catch (error) {
|
|
@@ -446,6 +461,9 @@ System.register('Utils', [], (function (exports) {
|
|
|
446
461
|
* @param cookieStr
|
|
447
462
|
*/
|
|
448
463
|
parseCookie(cookieStr) {
|
|
464
|
+
if (cookieStr.trim() === "") {
|
|
465
|
+
return [];
|
|
466
|
+
}
|
|
449
467
|
let cookies = cookieStr.split(";");
|
|
450
468
|
let result = [];
|
|
451
469
|
for (const cookieItem of cookies) {
|
|
@@ -5040,7 +5058,7 @@ System.register('Utils', [], (function (exports) {
|
|
|
5040
5058
|
this.windowApi = new WindowApi(option);
|
|
5041
5059
|
}
|
|
5042
5060
|
/** 版本号 */
|
|
5043
|
-
version = "2025.3.
|
|
5061
|
+
version = "2025.3.25";
|
|
5044
5062
|
addStyle(cssText) {
|
|
5045
5063
|
if (typeof cssText !== "string") {
|
|
5046
5064
|
throw new Error("Utils.addStyle 参数cssText 必须为String类型");
|