@whitesev/utils 1.0.4 → 1.0.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.
Files changed (60) hide show
  1. package/dist/index.amd.js +5885 -1817
  2. package/dist/index.amd.js.map +1 -1
  3. package/dist/index.cjs.js +5533 -1467
  4. package/dist/index.cjs.js.map +1 -1
  5. package/dist/index.esm.js +5531 -1467
  6. package/dist/index.esm.js.map +1 -1
  7. package/dist/index.iife.js +5886 -1817
  8. package/dist/index.iife.js.map +1 -1
  9. package/dist/index.system.js +5897 -1826
  10. package/dist/index.system.js.map +1 -1
  11. package/dist/index.umd.js +5889 -1817
  12. package/dist/index.umd.js.map +1 -1
  13. package/dist/src/Dictionary.d.ts +82 -0
  14. package/dist/src/Hooks.d.ts +11 -0
  15. package/dist/src/Httpx.d.ts +1201 -0
  16. package/dist/src/LockFunction.d.ts +31 -0
  17. package/dist/src/Log.d.ts +96 -0
  18. package/dist/src/Progress.d.ts +37 -0
  19. package/dist/src/UtilsGMMenu.d.ts +156 -0
  20. package/dist/src/index.d.ts +20 -27
  21. package/dist/src/indexedDB.d.ts +73 -0
  22. package/dist/src/tryCatch.d.ts +31 -0
  23. package/package.json +36 -37
  24. package/rollup.config.js +0 -3
  25. package/src/Dictionary.ts +152 -0
  26. package/src/{Hooks/Hooks.js → Hooks.ts} +31 -17
  27. package/src/{Httpx/index.d.ts → Httpx.ts} +837 -46
  28. package/src/LockFunction.ts +62 -0
  29. package/src/Log.ts +281 -0
  30. package/src/Progress.ts +143 -0
  31. package/src/UtilsGMMenu.ts +681 -0
  32. package/src/index.ts +17 -29
  33. package/src/indexedDB.ts +421 -0
  34. package/src/tryCatch.ts +107 -0
  35. package/tsconfig.json +1 -1
  36. package/dist/src/Dictionary/Dictionary.d.ts +0 -85
  37. package/dist/src/Hooks/Hooks.d.ts +0 -5
  38. package/dist/src/Httpx/Httpx.d.ts +0 -50
  39. package/dist/src/LockFunction/LockFunction.d.ts +0 -16
  40. package/dist/src/Log/Log.d.ts +0 -66
  41. package/dist/src/Progress/Progress.d.ts +0 -6
  42. package/dist/src/UtilsGMMenu/UtilsGMMenu.d.ts +0 -119
  43. package/dist/src/indexedDB/indexedDB.d.ts +0 -165
  44. package/dist/src/tryCatch/tryCatch.d.ts +0 -31
  45. package/src/Dictionary/Dictionary.js +0 -157
  46. package/src/Dictionary/index.d.ts +0 -52
  47. package/src/Hooks/index.d.ts +0 -16
  48. package/src/Httpx/Httpx.js +0 -747
  49. package/src/LockFunction/LockFunction.js +0 -35
  50. package/src/LockFunction/index.d.ts +0 -47
  51. package/src/Log/Log.js +0 -256
  52. package/src/Log/index.d.ts +0 -91
  53. package/src/Progress/Progress.js +0 -98
  54. package/src/Progress/index.d.ts +0 -30
  55. package/src/UtilsGMMenu/UtilsGMMenu.js +0 -464
  56. package/src/UtilsGMMenu/index.d.ts +0 -224
  57. package/src/indexedDB/index.d.ts +0 -128
  58. package/src/indexedDB/indexedDB.js +0 -355
  59. package/src/tryCatch/index.d.ts +0 -6
  60. package/src/tryCatch/tryCatch.js +0 -100
@@ -1,464 +0,0 @@
1
- /**
2
- *
3
- * @param {UtilsGMMenuConstructorOptions} details
4
- */
5
- const GMMenu = function (details) {
6
- const GM_Api = {
7
- /**
8
- * 获取存储的数据
9
- * @type {GM_getValue}
10
- */
11
- getValue: details.GM_getValue,
12
- /**
13
- * 设置数据到存储
14
- * @type {GM_setValue}
15
- */
16
- setValue: details.GM_setValue,
17
- /**
18
- * 注册菜单
19
- * @type {GM_registerMenuCommand}
20
- */
21
- registerMenuCommand: details.GM_registerMenuCommand,
22
- /**
23
- * 卸载菜单
24
- * @type {GM_unregisterMenuCommand}
25
- */
26
- unregisterMenuCommand: details.GM_unregisterMenuCommand,
27
- };
28
- for (const keyName of Object.keys(GM_Api)) {
29
- if (typeof GM_Api[keyName] !== "function") {
30
- throw new Error(
31
- `Utils.GM_Menu 请在脚本开头加上 @grant ${keyName},且传入该对象`
32
- );
33
- }
34
- }
35
- /** 上下文 */
36
- const context = this;
37
-
38
- const MenuHandle = {
39
- $data: {
40
- /**
41
- * 菜单数据
42
- * @type {UtilsGMMenuOptionData[]}
43
- */
44
- data: [],
45
- /**
46
- * 本地存储的键名
47
- */
48
- key: "GM_Menu_Local_Map",
49
- },
50
- $default: {
51
- /** 自动刷新网页,默认为true */
52
- autoReload:
53
- typeof details.autoReload === "boolean" ? details.autoReload : true,
54
- /**
55
- * 菜单isStoreValue的默认值
56
- */
57
- isStoreValue: true,
58
- },
59
- $emoji: {
60
- /**
61
- * 菜单enable为true的emoji
62
- */
63
- success: "✅",
64
- /**
65
- * 菜单enable为false的emoji
66
- */
67
- error: "❌",
68
- },
69
- /**
70
- * 初始化数据
71
- */
72
- init() {
73
- for (let index = 0; index < this.$data.data.length; index++) {
74
- let menuOption = this.$data.data[index]["data"];
75
- menuOption.enable = Boolean(
76
- this.getLocalMenuData(menuOption.key, menuOption.enable)
77
- );
78
- if (typeof menuOption.showText !== "function") {
79
- menuOption.showText = (menuText, menuEnable) => {
80
- if (menuEnable) {
81
- return this.$emoji.success + " " + menuText;
82
- } else {
83
- return this.$emoji.error + " " + menuText;
84
- }
85
- };
86
- }
87
- }
88
- },
89
- /**
90
- * 注册油猴菜单
91
- * @param { ?UtilsGMMenuOptionData[] } menuOptions 如果存在,使用它
92
- */
93
- register(menuOptions) {
94
- if (menuOptions == null) {
95
- throw new TypeError("register菜单数据不能为空");
96
- }
97
- if (!Array.isArray(menuOptions)) {
98
- menuOptions = [menuOptions];
99
- }
100
- for (let index = 0; index < menuOptions.length; index++) {
101
- let cloneMenuOptionData = Utils.deepClone(menuOptions[index].data);
102
- const { showText, clickCallBack } =
103
- this.handleMenuData(cloneMenuOptionData);
104
- let menuId = GM_Api.registerMenuCommand(showText, clickCallBack);
105
- menuOptions[index].id = menuId;
106
- cloneMenuOptionData.deleteMenu = function () {
107
- GM_Api.unregisterMenuCommand(menuId);
108
- };
109
- Reflect.deleteProperty(menuOptions[index], "handleData");
110
- menuOptions[index].handleData = cloneMenuOptionData;
111
- }
112
- },
113
- /**
114
- * 获取本地存储菜单键值
115
- * @param {string} key 键
116
- * @returns {boolean}
117
- */
118
- getLocalMenuData(key, defaultValue) {
119
- let localData = GM_Api.getValue(this.$data.key, {});
120
- if (key in localData) {
121
- return localData[key];
122
- } else {
123
- return defaultValue;
124
- }
125
- },
126
- /**
127
- * 设置本地存储菜单键值
128
- * @param {string} key 键
129
- * @param {boolean} value 值
130
- */
131
- setLocalMenuData(key, value) {
132
- let localData = GM_Api.getValue(this.$data.key, {});
133
- localData[key] = value;
134
- GM_Api.setValue(this.$data.key, localData);
135
- },
136
- /**
137
- * 处理初始化配置
138
- * @param { UtilsGMMenuOption } menuOption
139
- */
140
- handleInitDetail(menuOption) {
141
- menuOption.enable = Boolean(
142
- this.getLocalMenuData(menuOption.key, menuOption.enable)
143
- );
144
- if (typeof menuOption.showText !== "function") {
145
- menuOption.showText = (menuText, menuEnable) => {
146
- if (menuEnable) {
147
- return this.$emoji.success + " " + menuText;
148
- } else {
149
- return this.$emoji.error + " " + menuText;
150
- }
151
- };
152
- }
153
- return menuOption;
154
- },
155
- /**
156
- * 对菜单数据进行处理
157
- * @param { UtilsGMMenuOption } menuOption
158
- */
159
- handleMenuData(menuOption) {
160
- let menuLocalDataItemKey = menuOption.key;
161
- /* 菜单默认开启的状态 */
162
- let defaultEnable = Boolean(
163
- this.getLocalMenuData(menuLocalDataItemKey, menuOption.enable)
164
- );
165
- /** 油猴菜单上显示的文本 */
166
- let showText = menuOption.showText(menuOption.text, defaultEnable);
167
- const that = this;
168
- const GMMenuOptions = {
169
- /**
170
- * 菜单的id
171
- */
172
- id: menuOption.id,
173
- /**
174
- * 点击菜单项后是否应关闭弹出菜单
175
- */
176
- autoClose: menuOption.autoClose,
177
- /**
178
- * 菜单项的可选访问键
179
- */
180
- accessKey: menuOption.accessKey,
181
- /**
182
- * 菜单项的鼠标悬浮上的工具提示
183
- */
184
- title: menuOption.title,
185
- };
186
- /* 点击菜单后触发callback后的网页是否刷新 */
187
- menuOption.autoReload =
188
- typeof menuOption.autoReload !== "boolean"
189
- ? this.$default.autoReload
190
- : menuOption.autoReload;
191
- /* 点击菜单后触发callback后的网页是否存储值 */
192
- menuOption.isStoreValue =
193
- typeof menuOption.isStoreValue !== "boolean"
194
- ? this.$default.isStoreValue
195
- : menuOption.isStoreValue;
196
- /**
197
- * 用户点击菜单后的回调函数
198
- * @param {MouseEvent|PointerEvent} event
199
- */
200
- function clickCallBack(event) {
201
- let localEnable = Boolean(
202
- that.getLocalMenuData(menuLocalDataItemKey, defaultEnable)
203
- );
204
- if (menuOption.isStoreValue) {
205
- that.setLocalMenuData(menuLocalDataItemKey, !localEnable);
206
- }
207
- if (typeof menuOption.callback === "function") {
208
- menuOption.callback({
209
- key: menuLocalDataItemKey,
210
- enable: !localEnable,
211
- oldEnable: localEnable,
212
- event: event,
213
- storeValue(value) {
214
- that.setLocalMenuData(menuLocalDataItemKey, value);
215
- },
216
- });
217
- }
218
- /* 不刷新网页就刷新菜单 */
219
- if (menuOption.autoReload) {
220
- window.location.reload();
221
- } else {
222
- context.update();
223
- }
224
- }
225
-
226
- return {
227
- showText,
228
- clickCallBack,
229
- };
230
- },
231
- /**
232
- * 获取目标菜单配置数据
233
- * @param {string} menuKey 菜单-键key
234
- */
235
- getMenuData(menuKey) {
236
- return this.$data.data.find((item) => item.data.key === menuKey);
237
- },
238
- /**
239
- * 获取目标菜单配置
240
- * @param {string} menuKey 菜单-键key
241
- */
242
- getMenuOption(menuKey) {
243
- return this.$data.data.find((item) => item.data.key === menuKey)?.data;
244
- },
245
- /**
246
- * 获取目标菜单处理后的配置
247
- * @param {string} menuKey 菜单-键key
248
- */
249
- getMenuHandledOption(menuKey) {
250
- return this.$data.data.find((item) => item.handleData.key === menuKey)
251
- ?.handleData;
252
- },
253
- };
254
-
255
- /**
256
- * 新增菜单数据
257
- * @param {UtilsGMMenuOption[]|UtilsGMMenuOption} paramData
258
- */
259
- this.add = function (paramData) {
260
- if (Array.isArray(paramData)) {
261
- for (const _paramData of paramData) {
262
- MenuHandle.$data.data.push({
263
- data: _paramData,
264
- id: void 0,
265
- });
266
- }
267
- } else {
268
- MenuHandle.$data.data.push({
269
- data: paramData,
270
- id: void 0,
271
- });
272
- }
273
- this.update();
274
- };
275
- /**
276
- * 更新菜单数据
277
- * @param { ?UtilsGMMenuOption[]|UtilsGMMenuOption } options 数据
278
- */
279
- this.update = function (options) {
280
- /**
281
- * @type {UtilsGMMenuOption[]}
282
- */
283
- let optionsList = [];
284
- if (Array.isArray(options)) {
285
- optionsList = [...optionsList, ...options];
286
- } else if (options != null) {
287
- optionsList = [...optionsList, options];
288
- }
289
- optionsList.forEach((item) => {
290
- let targetMenu = MenuHandle.getMenuOption(item.key);
291
- if (targetMenu) {
292
- Object.assign(targetMenu, item);
293
- }
294
- });
295
- MenuHandle.$data.data.forEach((value) => {
296
- if (value.handleData) {
297
- value.handleData.deleteMenu();
298
- }
299
- });
300
- MenuHandle.init();
301
- MenuHandle.register(MenuHandle.$data.data);
302
- };
303
- /**
304
- * 卸载菜单
305
- * @param {number} menuId 已注册的菜单id
306
- */
307
- this.delete = function (menuId) {
308
- GM_Api.unregisterMenuCommand(menuId);
309
- };
310
- /**
311
- * 根据键值获取enable值
312
- * @param {string} menuKey 菜单-键key
313
- * @returns {boolean}
314
- */
315
- this.get = function (menuKey) {
316
- return this.getEnable(menuKey);
317
- };
318
- /**
319
- * 根据键值获取enable值
320
- * @param {string} menuKey 菜单-键key
321
- * @returns {boolean}
322
- */
323
- this.getEnable = function (menuKey) {
324
- return MenuHandle.getMenuHandledOption(menuKey).enable;
325
- };
326
- /**
327
- * 根据键值获取text值
328
- * @param {string} menuKey 菜单-键key
329
- * @returns {string}
330
- */
331
- this.getText = function (menuKey) {
332
- return MenuHandle.getMenuHandledOption(menuKey).text;
333
- };
334
- /**
335
- * 根据键值获取showText函数的值
336
- * @param {string} menuKey 菜单-键key
337
- * @returns {string}
338
- */
339
- this.getShowTextValue = function (menuKey) {
340
- return MenuHandle.getMenuHandledOption(menuKey).showText(
341
- this.getText(menuKey),
342
- this.get(menuKey)
343
- );
344
- };
345
- /**
346
- * 获取当前已注册菜单的id
347
- * @param {string} menuKey
348
- * @returns {?number}
349
- */
350
- this.getMenuId = function (menuKey) {
351
- let result = null;
352
- for (let index = 0; index < MenuHandle.$data.data.length; index++) {
353
- const optionData = MenuHandle.$data.data[index];
354
- if (optionData.handleData.key === menuKey) {
355
- result = optionData.id;
356
- break;
357
- }
358
- }
359
- return result;
360
- };
361
- /**
362
- * 根据键值获取accessKey值
363
- * @param {string} menuKey 菜单-键key
364
- * @returns {?string}
365
- */
366
- this.getAccessKey = function (menuKey) {
367
- return MenuHandle.getMenuHandledOption(menuKey).accessKey;
368
- };
369
- /**
370
- * 根据键值获取autoClose值
371
- * @param {string} menuKey 菜单-键key
372
- * @returns {?boolean}
373
- */
374
- this.getAutoClose = function (menuKey) {
375
- return MenuHandle.getMenuHandledOption(menuKey).autoClose;
376
- };
377
- /**
378
- * 根据键值获取autoReload值
379
- * @param {string} menuKey 菜单-键key
380
- * @returns {boolean}
381
- */
382
- this.getAutoReload = function (menuKey) {
383
- return MenuHandle.getMenuHandledOption(menuKey).autoReload;
384
- };
385
- /**
386
- * 根据键值获取callback函数
387
- * @param {string} menuKey 菜单-键key
388
- * @returns {?Function}
389
- */
390
- this.getCallBack = function (menuKey) {
391
- return MenuHandle.getMenuHandledOption(menuKey).callback;
392
- };
393
- /**
394
- * 获取当enable为true时默认显示在菜单中前面的emoji图标
395
- * @returns {string}
396
- */
397
- this.getEnableTrueEmoji = function () {
398
- return MenuHandle.$emoji.success;
399
- };
400
- /**
401
- * 获取当enable为false时默认显示在菜单中前面的emoji图标
402
- * @returns {string}
403
- */
404
- this.getEnableFalseEmoji = function () {
405
- return MenuHandle.$emoji.error;
406
- };
407
- /**
408
- * 获取本地存储的菜单外部的键名
409
- * @param {string} keyName
410
- */
411
- this.getLocalStorageKeyName = function () {
412
- return MenuHandle.$data.key;
413
- };
414
- /**
415
- * 设置菜单的值
416
- * @param {string} menuKey 菜单-键key
417
- * @param {any} value 需要设置的值
418
- */
419
- this.setValue = function (menuKey, value) {
420
- MenuHandle.setLocalMenuData(menuKey, value);
421
- };
422
- /**
423
- * 设置菜单的值
424
- * @param {string} menuKey 菜单-键key
425
- * @param {boolean} value 需要设置的值
426
- */
427
- this.setEnable = function (menuKey, value) {
428
- this.setValue(menuKey, Boolean(value));
429
- };
430
- /**
431
- * 设置当enable为true时默认显示在菜单中前面的emoji图标
432
- * @param {string} emojiString
433
- */
434
- this.setEnableTrueEmoji = function (emojiString) {
435
- if (typeof emojiString !== "string") {
436
- throw new Error("参数emojiString必须是string类型");
437
- }
438
- MenuHandle.$emoji.success = emojiString;
439
- };
440
- /**
441
- * 设置当enable为false时默认显示在菜单中前面的emoji图标
442
- * @param {string} emojiString
443
- */
444
- this.setEnableFalseEmoji = function (emojiString) {
445
- if (typeof emojiString !== "string") {
446
- throw new Error("参数emojiString必须是string类型");
447
- }
448
- MenuHandle.$emoji.error = emojiString;
449
- };
450
- /**
451
- * 设置本地存储的菜单外部的键名
452
- * @param {string} keyName
453
- */
454
- this.setLocalStorageKeyName = function (keyName) {
455
- if (typeof keyName !== "string") {
456
- throw new Error("参数keyName必须是string类型");
457
- }
458
- MenuHandle.$data.key = keyName;
459
- };
460
-
461
- this.add(details?.data || []);
462
- };
463
-
464
- export { GMMenu };
@@ -1,224 +0,0 @@
1
- /**
2
- * 保存值到本地存储
3
- *
4
- * 可以使用Promise实际等待值的设置完成
5
- */
6
- declare function GM_setValue(
7
- name: string,
8
- value: any
9
- ): Promise<undefined> | undefined;
10
-
11
- /**
12
- * 获取本地存储的值
13
- */
14
- declare function GM_getValue<T extends any>(name: string, defaultValue?: T): T;
15
-
16
- /**
17
- * 注册功能到油猴菜单中
18
- */
19
- declare function GM_registerMenuCommand(
20
- name: string,
21
- listener: (event: PointerEvent | MouseEvent) => void,
22
- accessKey?: string
23
- ): number;
24
- /**
25
- * 从替换菜单中卸载某个菜单
26
- */
27
- declare function GM_unregisterMenuCommand(id: number): void;
28
-
29
- declare interface UtilsGMMenuClickCallBackData {
30
- /** 菜单键名 */
31
- key: string;
32
- /** 是否启用 */
33
- enable: boolean;
34
- /** 点击前的enable值 */
35
- oldEnable: boolean;
36
- /** 触发的事件 */
37
- event: MouseEvent | KeyboardEvent;
38
- /** 将enable值写入本地的回调,设置参数false就不保存到本地 */
39
- storeValue(enable: boolean): void;
40
- }
41
-
42
- declare interface UtilsGMMenuOption {
43
- /** 菜单的本地键key,不可重复,会覆盖 */
44
- key: string;
45
- /** 菜单的文本 */
46
- text: string;
47
- /** (可选)菜单的开启状态,默认为false */
48
- enable?: boolean;
49
- /** (可选)使用条件:TamperMonkey版本>5.0,如果id和已注册的菜单id相同,可修改当前已注册菜单的options */
50
- id?: number;
51
- /** (可选)An optional access key. Please see the description below. Either options or accessKey can be specified. */
52
- accessKey?: string;
53
- /** (可选)自动关闭菜单,可不设置 */
54
- autoClose?: boolean;
55
- /** 使用条件:TamperMonkey版本>5.0,使用菜单项的鼠标悬浮上的工具提示*/
56
- title?: string;
57
- /** (可选)点击菜单后自动刷新网页,默认为true */
58
- autoReload?: boolean;
59
- /** 菜单的显示文本,未设置的话则自动根据enable在前面加上图标 */
60
- showText(text: string, enable: boolean): string;
61
- /** 点击菜单的回调 */
62
- callback(data: UtilsGMMenuClickCallBackData): void;
63
- /** 是否允许菜单进行存储值,默认true允许 */
64
- isStoreValue?: boolean;
65
- }
66
-
67
- declare interface UtilsGMMenuHandledOption extends UtilsGMMenuOption {
68
- /**
69
- * 删除该菜单
70
- */
71
- deleteMenu(): void;
72
- }
73
-
74
- declare interface UtilsGMMenuOptionData {
75
- /**
76
- * 菜单id
77
- */
78
- id: number;
79
- /**
80
- * 菜单配置
81
- */
82
- data: UtilsGMMenuOption;
83
- /**
84
- * 处理后的菜单配置
85
- * 对autoReload进行处理,如果未赋值,按默认的true赋值
86
- * 对isStoreValue进行处理,如果未赋值,按默认的true赋值
87
- * 新增一个deleteMenu
88
- */
89
- handleData: UtilsGMMenuHandledOption;
90
- }
91
-
92
- declare interface UtilsGMMenuConstructorOptions {
93
- /** (可选)配置*/
94
- data?: UtilsGMMenuOption[];
95
- /** (可选)全局菜单点击菜单后自动刷新网页,默认为true */
96
- autoReload?: boolean;
97
- /** 油猴函数 @grant GM_getValue */
98
- GM_getValue: Function;
99
- /** 油猴函数 @grant GM_setValue */
100
- GM_setValue: Function;
101
- /** 油猴函数 @grant GM_registerMenuCommand */
102
- GM_registerMenuCommand: Function;
103
- /** 油猴函数 @grant GM_unregisterMenuCommand */
104
- GM_unregisterMenuCommand: Function;
105
- }
106
-
107
- /** GM_Menu */
108
- declare interface UtilsGMMenuConstructor {
109
- /**
110
- * 根据键值获取enable值
111
- * @param menuKey 菜单-键key
112
- **/
113
- get(menuKey: string): boolean;
114
- /**
115
- * 根据键值获取enable值
116
- * @param menuKey 菜单-键key
117
- **/
118
- getEnable(menuKey: string): boolean;
119
- /**
120
- * 根据键值获取text值
121
- * @param menuKey 菜单-键key
122
- **/
123
- getText(menuKey: string): string;
124
- /**
125
- * 根据键值获取showText函数的值
126
- * @param menuKey 菜单-键key
127
- **/
128
- getShowTextValue(menuKey: string): string;
129
- /**
130
- * 获取当前已注册菜单的id
131
- * @param menuKey 菜单-键key
132
- */
133
- getMenuId(menuKey: string): number | undefined;
134
- /**
135
- * 根据键值获取accessKey值
136
- * @param menuKey 菜单-键key
137
- */
138
- getAccessKey(menuKey: string): string | undefined;
139
- /**
140
- * 根据键值获取autoClose值
141
- * @param menuKey 菜单-键key
142
- */
143
- getAutoClose(menuKey: string): boolean | undefined;
144
- /**
145
- * 根据键值获取autoReload值
146
- * @param menuKey 菜单-键key
147
- */
148
- getAutoReload(menuKey: string): boolean;
149
- /**
150
- * 根据键值获取callback函数
151
- * @param menuKey 菜单-键key
152
- */
153
- getCallBack(menuKey: string): () => void | undefined;
154
- /**
155
- * 获取当enable为true时默认显示在菜单中前面的emoji图标
156
- */
157
- getEnableTrueEmoji(): string;
158
- /**
159
- * 获取当enable为false时默认显示在菜单中前面的emoji图标
160
- */
161
- getEnableFalseEmoji(): string;
162
- /**
163
- * 获取本地存储的菜单外部的键名
164
- * @param keyName
165
- */
166
- getLocalStorageKeyName(keyName: string): string;
167
- /**
168
- * 设置菜单的值
169
- * @param menuKey 菜单-键key
170
- * @param value 需要设置的值
171
- */
172
- setValue(menuKey: string, value: any): void;
173
- /**
174
- * 设置菜单的值
175
- * @param menuKey 菜单-键key
176
- * @param value 需要设置的值
177
- */
178
- setEnable(menuKey: string, value: boolean): void;
179
- /**
180
- * 设置当enable为true时默认显示在菜单中前面的emoji图标
181
- * @param emojiString
182
- */
183
- setEnableTrueEmoji(emojiString: string): void;
184
- /**
185
- * 设置当enable为false时默认显示在菜单中前面的emoji图标
186
- * @param emojiString
187
- */
188
- setEnableFalseEmoji(emojiString: string): void;
189
- /**
190
- * 设置本地存储的菜单外部的键名
191
- * @param keyName
192
- */
193
- setLocalStorageKeyName(keyName: string): void;
194
- /**
195
- * 新增菜单数据
196
- * @param paramData
197
- */
198
- add(paramData: UtilsGMMenuOption[] | UtilsGMMenuOption): void;
199
- /**
200
- * 更新菜单数据
201
- * 方式:先卸载全部的菜单,再重新注册菜单
202
- * @param options 数据
203
- */
204
- update(options?: UtilsGMMenuOption[] | UtilsGMMenuOption): Promise<void>;
205
- /**
206
- * 根据已注册菜单的id,来更新菜单配置,不会卸载菜单导致可能菜单选项可能会变化的情况
207
- * @param options 配置
208
- * @deprecated
209
- */
210
- updateOptionsWithId?(options?: UtilsGMMenuOption[] | UtilsGMMenuOption): void;
211
- /**
212
- * 卸载菜单
213
- * @param menuId 已注册的菜单id
214
- */
215
- delete(menuId: number): void;
216
- }
217
-
218
- /** GM_Menu */
219
- declare interface UtilsGMMenu {
220
- /**
221
- * @param details 传递的菜单配置
222
- */
223
- new (details: UtilsGMMenuConstructorOptions): UtilsGMMenuConstructor;
224
- }