@whitesev/utils 1.3.4 → 1.3.6
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 +12 -1
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +12 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +12 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +12 -1
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +12 -1
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +12 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/src/Utils.d.ts +12 -0
- package/dist/src/UtilsCore.d.ts +1 -1
- package/dist/src/UtilsGMCookie.d.ts +26 -2
- package/package.json +1 -1
- package/src/Utils.ts +21 -1
- package/src/UtilsCore.ts +1 -2
- package/src/UtilsGMCookie.ts +2 -2
package/dist/src/Utils.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { Log } from "./Log";
|
|
|
11
11
|
import { Progress } from "./Progress";
|
|
12
12
|
import { UtilsDictionary } from "./Dictionary";
|
|
13
13
|
import type { DOMUtils_EventType } from "./Event";
|
|
14
|
+
import type { UtilsCoreOption } from "./UtilsCore";
|
|
14
15
|
export declare var unsafeWindow: Window & typeof globalThis;
|
|
15
16
|
export type JSTypeMap = {
|
|
16
17
|
string: string;
|
|
@@ -110,6 +111,10 @@ export declare interface Vue2Context extends AnyObject {
|
|
|
110
111
|
mode: string;
|
|
111
112
|
resolveHooks: ((...args: any[]) => any)[];
|
|
112
113
|
currentRoute: AnyObject;
|
|
114
|
+
/**
|
|
115
|
+
* 传空就移除上一个监听
|
|
116
|
+
*/
|
|
117
|
+
afterEach: ((to: Vue2Context["$route"], from: Vue2Context["$route"]) => void) | null;
|
|
113
118
|
};
|
|
114
119
|
$ssrContext: AnyObject;
|
|
115
120
|
$watch: (key: string | string[], handler: (this: any, newVal: any, oldVal: any) => void, options?: {
|
|
@@ -118,6 +123,7 @@ export declare interface Vue2Context extends AnyObject {
|
|
|
118
123
|
}) => void;
|
|
119
124
|
}
|
|
120
125
|
declare class Utils {
|
|
126
|
+
constructor(option?: UtilsCoreOption);
|
|
121
127
|
/** 版本号 */
|
|
122
128
|
version: string;
|
|
123
129
|
/**
|
|
@@ -1792,6 +1798,12 @@ declare class Utils {
|
|
|
1792
1798
|
* > 111;
|
|
1793
1799
|
*/
|
|
1794
1800
|
watchObject(target: AnyObject, propertyName: string, getCallBack: (value: any) => void, setCallBack: (value: any) => void): void;
|
|
1801
|
+
/**
|
|
1802
|
+
* 创建一个新的Utils实例
|
|
1803
|
+
* @param option
|
|
1804
|
+
* @returns
|
|
1805
|
+
*/
|
|
1806
|
+
createUtils(option?: UtilsCoreOption): Utils;
|
|
1795
1807
|
}
|
|
1796
1808
|
declare let utils: Utils;
|
|
1797
1809
|
export { utils as Utils };
|
package/dist/src/UtilsCore.d.ts
CHANGED
|
@@ -21,6 +21,30 @@ declare interface UtilsGMCookieListOptions {
|
|
|
21
21
|
/** 需要检索的Cookie的路径,默认为"/" */
|
|
22
22
|
path: string;
|
|
23
23
|
}
|
|
24
|
+
declare interface UtilsGMCookieSetOptions {
|
|
25
|
+
/** 默认为当前的url */
|
|
26
|
+
url?: string;
|
|
27
|
+
/** 默认为当前的域名(window.location.hostname) */
|
|
28
|
+
domain?: string;
|
|
29
|
+
/** 需要检索的Cookie的名字 */
|
|
30
|
+
name?: string;
|
|
31
|
+
/** 需要检索的Cookie的路径,默认为"/" */
|
|
32
|
+
path?: string;
|
|
33
|
+
/** 值 */
|
|
34
|
+
value?: string | number;
|
|
35
|
+
/** 确保Cookie只在通过安全协议(如HTTPS)的情况下传输 */
|
|
36
|
+
secure?: boolean;
|
|
37
|
+
/** 是否防止JavaScript代码访问Cookie */
|
|
38
|
+
httpOnly?: boolean;
|
|
39
|
+
/** Cookie过期时间,默认为30天 */
|
|
40
|
+
expirationDate?: number;
|
|
41
|
+
}
|
|
42
|
+
declare interface UtilsGMCookieDeleteOptions {
|
|
43
|
+
/** 默认为当前的url */
|
|
44
|
+
url: string;
|
|
45
|
+
/** 需要检索的Cookie的名字 */
|
|
46
|
+
name: string;
|
|
47
|
+
}
|
|
24
48
|
declare class UtilsGMCookie {
|
|
25
49
|
/**
|
|
26
50
|
* 获取单个cookie
|
|
@@ -45,12 +69,12 @@ declare class UtilsGMCookie {
|
|
|
45
69
|
* @param paramDetails 配置
|
|
46
70
|
* @param callback 设置操作后的回调(成功/失败)
|
|
47
71
|
*/
|
|
48
|
-
set(paramDetails: Partial<
|
|
72
|
+
set(paramDetails: Partial<UtilsGMCookieSetOptions>, callback?: (error?: Error) => void): void;
|
|
49
73
|
/**
|
|
50
74
|
* 删除Cookie
|
|
51
75
|
* @param paramDetails 配置
|
|
52
76
|
* @param callback 删除操作后的回调(成功/失败)
|
|
53
77
|
*/
|
|
54
|
-
delete(paramDetails: Partial<
|
|
78
|
+
delete(paramDetails: Partial<UtilsGMCookieDeleteOptions>, callback?: (error?: Error) => void): void;
|
|
55
79
|
}
|
|
56
80
|
export { UtilsGMCookie };
|
package/package.json
CHANGED
package/src/Utils.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { Progress } from "./Progress";
|
|
|
14
14
|
import { TryCatch } from "./TryCatch";
|
|
15
15
|
import { UtilsDictionary } from "./Dictionary";
|
|
16
16
|
import type { DOMUtils_EventType } from "./Event";
|
|
17
|
+
import type { UtilsCoreOption } from "./UtilsCore";
|
|
17
18
|
|
|
18
19
|
export declare var unsafeWindow: Window & typeof globalThis;
|
|
19
20
|
|
|
@@ -121,6 +122,13 @@ export declare interface Vue2Context extends AnyObject {
|
|
|
121
122
|
mode: string;
|
|
122
123
|
resolveHooks: ((...args: any[]) => any)[];
|
|
123
124
|
currentRoute: AnyObject;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* 传空就移除上一个监听
|
|
128
|
+
*/
|
|
129
|
+
afterEach:
|
|
130
|
+
| ((to: Vue2Context["$route"], from: Vue2Context["$route"]) => void)
|
|
131
|
+
| null;
|
|
124
132
|
};
|
|
125
133
|
$ssrContext: AnyObject;
|
|
126
134
|
|
|
@@ -135,8 +143,11 @@ export declare interface Vue2Context extends AnyObject {
|
|
|
135
143
|
}
|
|
136
144
|
|
|
137
145
|
class Utils {
|
|
146
|
+
constructor(option?: UtilsCoreOption) {
|
|
147
|
+
UtilsCore.init(option);
|
|
148
|
+
}
|
|
138
149
|
/** 版本号 */
|
|
139
|
-
version = "2024.5
|
|
150
|
+
version = "2024.6.5";
|
|
140
151
|
|
|
141
152
|
/**
|
|
142
153
|
* 在页面中增加style元素,如果html节点存在子节点,添加子节点第一个,反之,添加到html节点的子节点最后一个
|
|
@@ -4875,6 +4886,15 @@ class Utils {
|
|
|
4875
4886
|
});
|
|
4876
4887
|
}
|
|
4877
4888
|
}
|
|
4889
|
+
|
|
4890
|
+
/**
|
|
4891
|
+
* 创建一个新的Utils实例
|
|
4892
|
+
* @param option
|
|
4893
|
+
* @returns
|
|
4894
|
+
*/
|
|
4895
|
+
createUtils(option?: UtilsCoreOption) {
|
|
4896
|
+
return new Utils(option);
|
|
4897
|
+
}
|
|
4878
4898
|
}
|
|
4879
4899
|
|
|
4880
4900
|
let utils = new Utils();
|
package/src/UtilsCore.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare interface UtilsCoreOption {
|
|
1
|
+
export declare interface UtilsCoreOption {
|
|
2
2
|
document: Document;
|
|
3
3
|
window: Window;
|
|
4
4
|
globalThis: typeof globalThis;
|
|
@@ -6,7 +6,6 @@ declare interface UtilsCoreOption {
|
|
|
6
6
|
top: Window;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
const UtilsCoreDefaultEnv: UtilsCoreOption = {
|
|
11
10
|
document: document,
|
|
12
11
|
window: window,
|
package/src/UtilsGMCookie.ts
CHANGED
|
@@ -197,7 +197,7 @@ class UtilsGMCookie {
|
|
|
197
197
|
* @param callback 设置操作后的回调(成功/失败)
|
|
198
198
|
*/
|
|
199
199
|
set(
|
|
200
|
-
paramDetails: Partial<
|
|
200
|
+
paramDetails: Partial<UtilsGMCookieSetOptions>,
|
|
201
201
|
callback = (error?: Error) => {}
|
|
202
202
|
) {
|
|
203
203
|
try {
|
|
@@ -237,7 +237,7 @@ class UtilsGMCookie {
|
|
|
237
237
|
* @param callback 删除操作后的回调(成功/失败)
|
|
238
238
|
*/
|
|
239
239
|
delete(
|
|
240
|
-
paramDetails: Partial<
|
|
240
|
+
paramDetails: Partial<UtilsGMCookieDeleteOptions>,
|
|
241
241
|
callback = (error?: Error) => {}
|
|
242
242
|
) {
|
|
243
243
|
try {
|