@minilo/utils 0.0.5 → 0.0.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.
Files changed (69) hide show
  1. package/dist/config/config.d.ts +3 -3
  2. package/dist/config/guider.d.ts +51 -67
  3. package/dist/config/index.d.ts +6 -6
  4. package/dist/config/storageManager.d.ts +41 -41
  5. package/dist/config/types.d.ts +18 -18
  6. package/dist/config/updateCssVariables.d.ts +11 -14
  7. package/dist/constrant/index.d.ts +5 -5
  8. package/dist/func/color.d.ts +5 -5
  9. package/dist/func/common.d.ts +8 -15
  10. package/dist/func/index.d.ts +4 -4
  11. package/dist/func/merge.d.ts +2 -2
  12. package/dist/hooks/helper.d.ts +6 -0
  13. package/dist/hooks/helper.d.ts.map +1 -0
  14. package/dist/hooks/helper.js +45 -0
  15. package/dist/hooks/helper.js.map +1 -0
  16. package/dist/hooks/index.d.ts +4 -5
  17. package/dist/hooks/index.d.ts.map +1 -1
  18. package/dist/hooks/index.js +4 -5
  19. package/dist/hooks/index.js.map +1 -1
  20. package/dist/hooks/useChartResize.d.ts +20 -0
  21. package/dist/hooks/useChartResize.d.ts.map +1 -0
  22. package/dist/hooks/useChartResize.js +67 -0
  23. package/dist/hooks/useChartResize.js.map +1 -0
  24. package/dist/hooks/useCountDown.d.ts +9 -0
  25. package/dist/hooks/useCountDown.d.ts.map +1 -0
  26. package/dist/hooks/useCountDown.js +42 -0
  27. package/dist/hooks/useCountDown.js.map +1 -0
  28. package/dist/hooks/useFormAutoSave.d.ts +2 -0
  29. package/dist/hooks/useFormAutoSave.d.ts.map +1 -0
  30. package/dist/hooks/useFormAutoSave.js +73 -0
  31. package/dist/hooks/useFormAutoSave.js.map +1 -0
  32. package/dist/hooks/useRouteCache.d.ts +2 -0
  33. package/dist/hooks/useRouteCache.d.ts.map +1 -0
  34. package/dist/hooks/useRouteCache.js +92 -0
  35. package/dist/hooks/useRouteCache.js.map +1 -0
  36. package/dist/hooks/useScroll.d.ts +15 -0
  37. package/dist/hooks/useScroll.d.ts.map +1 -0
  38. package/dist/hooks/useScroll.js +71 -0
  39. package/dist/hooks/useScroll.js.map +1 -0
  40. package/dist/hooks/useUpload.d.ts +17 -0
  41. package/dist/hooks/useUpload.d.ts.map +1 -0
  42. package/dist/hooks/useUpload.js +87 -0
  43. package/dist/hooks/useUpload.js.map +1 -0
  44. package/dist/index.d.ts +1 -0
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +1 -0
  47. package/dist/index.js.map +1 -1
  48. package/dist/request/index.d.ts +34 -16
  49. package/dist/request/index.d.ts.map +1 -1
  50. package/dist/request/index.js +15 -8
  51. package/dist/request/index.js.map +1 -1
  52. package/dist/tsconfig.tsbuildinfo +1 -1
  53. package/package.json +7 -2
  54. package/dist/hooks/useButtonPermission.d.ts +0 -9
  55. package/dist/hooks/useButtonPermission.d.ts.map +0 -1
  56. package/dist/hooks/useButtonPermission.js +0 -38
  57. package/dist/hooks/useButtonPermission.js.map +0 -1
  58. package/dist/hooks/useGuider.d.ts +0 -2
  59. package/dist/hooks/useGuider.d.ts.map +0 -1
  60. package/dist/hooks/useGuider.js +0 -5
  61. package/dist/hooks/useGuider.js.map +0 -1
  62. package/dist/hooks/useInitGlobalStyle.d.ts +0 -2
  63. package/dist/hooks/useInitGlobalStyle.d.ts.map +0 -1
  64. package/dist/hooks/useInitGlobalStyle.js +0 -80
  65. package/dist/hooks/useInitGlobalStyle.js.map +0 -1
  66. package/dist/hooks/useLogout.d.ts +0 -8
  67. package/dist/hooks/useLogout.d.ts.map +0 -1
  68. package/dist/hooks/useLogout.js +0 -55
  69. package/dist/hooks/useLogout.js.map +0 -1
@@ -1,3 +1,3 @@
1
- import type { Config } from './types'
2
- export declare const config: Config
3
- //# sourceMappingURL=config.d.ts.map
1
+ import type { Config } from './types';
2
+ export declare const config: Config;
3
+ //# sourceMappingURL=config.d.ts.map
@@ -1,70 +1,54 @@
1
- import type { Config, InitialOptions } from './types'
1
+ import type { Config, InitialOptions } from './types';
2
2
  declare class Guider {
3
- private cache
4
- private isInitialized
5
- private state
6
- constructor()
7
- initConfig({ config, namespace }: InitialOptions): void
8
- updateConfig(config?: Partial<Config>): void
9
- saveConfig(config: Config): void
10
- private loadConfig
11
- getConfig(): {
12
- readonly app?:
13
- | {
14
- readonly locale?: string | undefined
15
- readonly name?: string | undefined
16
- readonly defaultHomePath?: string | undefined
17
- readonly logo?: string | undefined
18
- }
19
- | undefined
20
- readonly theme?:
21
- | {
22
- readonly colorDestructive?: string | undefined
23
- readonly colorPrimary?: string | undefined
24
- readonly colorSuccess?: string | undefined
25
- readonly colorWarning?: string | undefined
26
- }
27
- | undefined
28
- readonly sidebar?:
29
- | {
30
- readonly collapse: boolean
31
- }
32
- | undefined
33
- readonly transition?:
34
- | {
35
- readonly progress: boolean
36
- }
37
- | undefined
38
- }
3
+ private cache;
4
+ private isInitialized;
5
+ private state;
6
+ constructor();
7
+ initConfig({ config, namespace }: InitialOptions): void;
8
+ updateConfig(config?: Partial<Config>): void;
9
+ saveConfig(config: Config): void;
10
+ private loadConfig;
11
+ getConfig(): {
12
+ readonly app?: {
13
+ readonly locale?: string | undefined;
14
+ readonly name?: string | undefined;
15
+ readonly defaultHomePath?: string | undefined;
16
+ readonly logo?: string | undefined;
17
+ } | undefined;
18
+ readonly theme?: {
19
+ readonly colorDestructive?: string | undefined;
20
+ readonly colorPrimary?: string | undefined;
21
+ readonly colorSuccess?: string | undefined;
22
+ readonly colorWarning?: string | undefined;
23
+ } | undefined;
24
+ readonly sidebar?: {
25
+ readonly collapse: boolean;
26
+ } | undefined;
27
+ readonly transition?: {
28
+ readonly progress: boolean;
29
+ } | undefined;
30
+ };
39
31
  }
40
- declare const guider: Guider
32
+ declare const guider: Guider;
41
33
  declare const userConfig: {
42
- readonly app?:
43
- | {
44
- readonly locale?: string | undefined
45
- readonly name?: string | undefined
46
- readonly defaultHomePath?: string | undefined
47
- readonly logo?: string | undefined
48
- }
49
- | undefined
50
- readonly theme?:
51
- | {
52
- readonly colorDestructive?: string | undefined
53
- readonly colorPrimary?: string | undefined
54
- readonly colorSuccess?: string | undefined
55
- readonly colorWarning?: string | undefined
56
- }
57
- | undefined
58
- readonly sidebar?:
59
- | {
60
- readonly collapse: boolean
61
- }
62
- | undefined
63
- readonly transition?:
64
- | {
65
- readonly progress: boolean
66
- }
67
- | undefined
68
- }
69
- export { Guider, userConfig, guider }
70
- //# sourceMappingURL=guider.d.ts.map
34
+ readonly app?: {
35
+ readonly locale?: string | undefined;
36
+ readonly name?: string | undefined;
37
+ readonly defaultHomePath?: string | undefined;
38
+ readonly logo?: string | undefined;
39
+ } | undefined;
40
+ readonly theme?: {
41
+ readonly colorDestructive?: string | undefined;
42
+ readonly colorPrimary?: string | undefined;
43
+ readonly colorSuccess?: string | undefined;
44
+ readonly colorWarning?: string | undefined;
45
+ } | undefined;
46
+ readonly sidebar?: {
47
+ readonly collapse: boolean;
48
+ } | undefined;
49
+ readonly transition?: {
50
+ readonly progress: boolean;
51
+ } | undefined;
52
+ };
53
+ export { Guider, userConfig, guider };
54
+ //# sourceMappingURL=guider.d.ts.map
@@ -1,6 +1,6 @@
1
- export * from './config'
2
- export * from './guider'
3
- export * from './updateCssVariables'
4
- export * from './storageManager'
5
- export * from './types'
6
- //# sourceMappingURL=index.d.ts.map
1
+ export * from './config';
2
+ export * from './guider';
3
+ export * from './updateCssVariables';
4
+ export * from './storageManager';
5
+ export * from './types';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -1,45 +1,45 @@
1
- type StorageType = 'localStorage' | 'sessionStorage'
1
+ type StorageType = 'localStorage' | 'sessionStorage';
2
2
  interface StorageManagerOptions {
3
- prefix?: string
4
- storageType?: StorageType
3
+ prefix?: string;
4
+ storageType?: StorageType;
5
5
  }
6
6
  declare class StorageManager {
7
- private prefix
8
- private storage
9
- constructor({ prefix, storageType }?: StorageManagerOptions)
10
- /**
11
- * 清除所有带前缀的存储项
12
- */
13
- clear(): void
14
- /**
15
- * 清除所有过期的存储项
16
- */
17
- clearExpiredItems(): void
18
- /**
19
- * 获取存储项
20
- * @param key 键
21
- * @param defaultValue 当项不存在或已过期时返回的默认值
22
- * @returns 值,如果项已过期或解析错误则返回默认值
23
- */
24
- getItem<T>(key: string, defaultValue?: null | T): null | T
25
- /**
26
- * 移除存储项
27
- * @param key 键
28
- */
29
- removeItem(key: string): void
30
- /**
31
- * 设置存储项
32
- * @param key 键
33
- * @param value 值
34
- * @param ttl 存活时间(毫秒)
35
- */
36
- setItem<T>(key: string, value: T, ttl?: number): void
37
- /**
38
- * 获取完整的存储键
39
- * @param key 原始键
40
- * @returns 带前缀的完整键
41
- */
42
- private getFullKey
7
+ private prefix;
8
+ private storage;
9
+ constructor({ prefix, storageType }?: StorageManagerOptions);
10
+ /**
11
+ * 清除所有带前缀的存储项
12
+ */
13
+ clear(): void;
14
+ /**
15
+ * 清除所有过期的存储项
16
+ */
17
+ clearExpiredItems(): void;
18
+ /**
19
+ * 获取存储项
20
+ * @param key 键
21
+ * @param defaultValue 当项不存在或已过期时返回的默认值
22
+ * @returns 值,如果项已过期或解析错误则返回默认值
23
+ */
24
+ getItem<T>(key: string, defaultValue?: null | T): null | T;
25
+ /**
26
+ * 移除存储项
27
+ * @param key 键
28
+ */
29
+ removeItem(key: string): void;
30
+ /**
31
+ * 设置存储项
32
+ * @param key 键
33
+ * @param value 值
34
+ * @param ttl 存活时间(毫秒)
35
+ */
36
+ setItem<T>(key: string, value: T, ttl?: number): void;
37
+ /**
38
+ * 获取完整的存储键
39
+ * @param key 原始键
40
+ * @returns 带前缀的完整键
41
+ */
42
+ private getFullKey;
43
43
  }
44
- export { StorageManager }
45
- //# sourceMappingURL=storageManager.d.ts.map
44
+ export { StorageManager };
45
+ //# sourceMappingURL=storageManager.d.ts.map
@@ -1,30 +1,30 @@
1
1
  interface InitialOptions {
2
- namespace: string
3
- config?: Partial<Config>
2
+ namespace: string;
3
+ config?: Partial<Config>;
4
4
  }
5
5
  interface ThemeConfig {
6
- colorDestructive?: string
7
- colorPrimary?: string
8
- colorSuccess?: string
9
- colorWarning?: string
6
+ colorDestructive?: string;
7
+ colorPrimary?: string;
8
+ colorSuccess?: string;
9
+ colorWarning?: string;
10
10
  }
11
11
  interface SidebarConfig {
12
- collapse: boolean
12
+ collapse: boolean;
13
13
  }
14
14
  interface TransitionConfig {
15
- progress: boolean
15
+ progress: boolean;
16
16
  }
17
17
  interface AppConfig {
18
- locale?: string
19
- name?: string
20
- defaultHomePath?: string
21
- logo?: string
18
+ locale?: string;
19
+ name?: string;
20
+ defaultHomePath?: string;
21
+ logo?: string;
22
22
  }
23
23
  interface Config {
24
- app?: AppConfig
25
- theme?: ThemeConfig
26
- sidebar?: SidebarConfig
27
- transition?: TransitionConfig
24
+ app?: AppConfig;
25
+ theme?: ThemeConfig;
26
+ sidebar?: SidebarConfig;
27
+ transition?: TransitionConfig;
28
28
  }
29
- export type { Config, InitialOptions }
30
- //# sourceMappingURL=types.d.ts.map
29
+ export type { Config, InitialOptions };
30
+ //# sourceMappingURL=types.d.ts.map
@@ -1,16 +1,13 @@
1
- import type { Config } from './types'
2
- declare function executeUpdateCSSVariables(
3
- variables: {
4
- [key: string]: string
5
- },
6
- id?: string
7
- ): void
1
+ import type { Config } from './types';
2
+ declare function executeUpdateCSSVariables(variables: {
3
+ [key: string]: string;
4
+ }, id?: string): void;
8
5
  interface ColorItem {
9
- alias?: string
10
- color?: string
11
- name?: string
6
+ alias?: string;
7
+ color?: string;
8
+ name?: string;
12
9
  }
13
- declare function generatorColorVariables(colorItems: ColorItem[]): Record<string, string>
14
- declare function updateCSSVariables(config: Config): void
15
- export { updateCSSVariables, executeUpdateCSSVariables, generatorColorVariables }
16
- //# sourceMappingURL=updateCssVariables.d.ts.map
10
+ declare function generatorColorVariables(colorItems: ColorItem[]): Record<string, string>;
11
+ declare function updateCSSVariables(config: Config): void;
12
+ export { updateCSSVariables, executeUpdateCSSVariables, generatorColorVariables };
13
+ //# sourceMappingURL=updateCssVariables.d.ts.map
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * @zh_CN 登录页面 url 地址
3
3
  */
4
- export declare const LOGIN_PATH = '/auth/login'
4
+ export declare const LOGIN_PATH = "/auth/login";
5
5
  export interface LanguageOption {
6
- label: string
7
- value: 'en-US' | 'zh-CN'
6
+ label: string;
7
+ value: 'en-US' | 'zh-CN';
8
8
  }
9
9
  /**
10
10
  * Supported languages
11
11
  */
12
- export declare const SUPPORT_LANGUAGES: LanguageOption[]
13
- //# sourceMappingURL=index.d.ts.map
12
+ export declare const SUPPORT_LANGUAGES: LanguageOption[];
13
+ //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,5 @@
1
- import { TinyColor } from '@ctrl/tinycolor'
2
- declare function convertToHsl(color: string): string
1
+ import { TinyColor } from '@ctrl/tinycolor';
2
+ declare function convertToHsl(color: string): string;
3
3
  /**
4
4
  * 将颜色转换为RGB颜色字符串
5
5
  * TinyColor无法处理hsl内包含'deg'、'grad'、'rad'或'turn'的字符串
@@ -8,6 +8,6 @@ declare function convertToHsl(color: string): string
8
8
  * @param str 表示HLS颜色值的字符串
9
9
  * @returns 如果颜色值有效,则返回对应的RGB颜色字符串;如果无效,则返回rgb(0, 0, 0)
10
10
  */
11
- declare function convertToRgb(str: string): string
12
- export { convertToHsl, convertToRgb, TinyColor }
13
- //# sourceMappingURL=color.d.ts.map
11
+ declare function convertToRgb(str: string): string;
12
+ export { convertToHsl, convertToRgb, TinyColor };
13
+ //# sourceMappingURL=color.d.ts.map
@@ -1,4 +1,4 @@
1
- import type { MenuDataItem, BreadcrumbItem, OptionItem } from '@minilo/types'
1
+ import type { MenuDataItem, BreadcrumbItem, OptionItem } from '@minilo/types';
2
2
  /**
3
3
  * @description 判断url是否是http或https
4
4
  * @author xieshuhong
@@ -6,7 +6,7 @@ import type { MenuDataItem, BreadcrumbItem, OptionItem } from '@minilo/types'
6
6
  * @param {string} url
7
7
  * @return {*}
8
8
  */
9
- export declare function isHttp(url: string): boolean
9
+ export declare function isHttp(url: string): boolean;
10
10
  /**
11
11
  * @description 递归查找当前path对应的所有层级路由,为面包屑提供数据
12
12
  * @author xieshuhong
@@ -16,11 +16,7 @@ export declare function isHttp(url: string): boolean
16
16
  * @param {BreadcrumbItem[]} [parentPaths=[]]
17
17
  * @return {*} {BreadcrumbItem[]}
18
18
  */
19
- export declare function findLevelRoutes(
20
- menuList: MenuDataItem[],
21
- targetPath: string,
22
- parentPaths?: BreadcrumbItem[]
23
- ): BreadcrumbItem[]
19
+ export declare function findLevelRoutes(menuList: MenuDataItem[], targetPath: string, parentPaths?: BreadcrumbItem[]): BreadcrumbItem[];
24
20
  /**
25
21
  * @description 查找菜单栏中当前path对应的菜单项
26
22
  * @author xieshuhong
@@ -29,7 +25,7 @@ export declare function findLevelRoutes(
29
25
  * @param {string} targetPath
30
26
  * @return {*} {(MenuDataItem | null)}
31
27
  */
32
- export declare function findMenuItem(items: MenuDataItem[], targetPath: string): MenuDataItem | null
28
+ export declare function findMenuItem(items: MenuDataItem[], targetPath: string): MenuDataItem | null;
33
29
  /**
34
30
  * @description 将options数组转换为对象,渲染
35
31
  * @author xieshuhong
@@ -38,10 +34,7 @@ export declare function findMenuItem(items: MenuDataItem[], targetPath: string):
38
34
  * @param {false} inverse 是否反向转换
39
35
  * @return {*} {(Record<string | number, string>)}
40
36
  */
41
- export declare function transOptionsToObject(
42
- options: OptionItem[],
43
- inverse?: false
44
- ): Record<string | number, string>
37
+ export declare function transOptionsToObject(options: OptionItem[], inverse?: false): Record<string | number, string>;
45
38
  /**
46
39
  * @description 根据多层级键路径从对象中获取值
47
40
  * @author xieshuhong
@@ -50,7 +43,7 @@ export declare function transOptionsToObject(
50
43
  * @param {any} [defaultValue] - 可选,路径不存在时返回的默认值
51
44
  * @returns {any} 路径对应的 value 或 defaultValue
52
45
  */
53
- export declare function getNestedValue(obj: any, path: string, defaultValue?: any): any
46
+ export declare function getNestedValue(obj: any, path: string, defaultValue?: any): any;
54
47
  /**
55
48
  * @description 将驼峰命名法转换为连字符命名法
56
49
  * @author xieshuhong
@@ -58,5 +51,5 @@ export declare function getNestedValue(obj: any, path: string, defaultValue?: an
58
51
  * @param {string} key
59
52
  * @return {*}
60
53
  */
61
- export declare function kebabCase(key: string): string
62
- //# sourceMappingURL=common.d.ts.map
54
+ export declare function kebabCase(key: string): string;
55
+ //# sourceMappingURL=common.d.ts.map
@@ -1,4 +1,4 @@
1
- export * from './color'
2
- export * from './merge'
3
- export * from './common'
4
- //# sourceMappingURL=index.d.ts.map
1
+ export * from './color';
2
+ export * from './merge';
3
+ export * from './common';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -1,2 +1,2 @@
1
- export { defu as merge } from 'defu'
2
- //# sourceMappingURL=merge.d.ts.map
1
+ export { defu as merge } from 'defu';
2
+ //# sourceMappingURL=merge.d.ts.map
@@ -0,0 +1,6 @@
1
+ export declare const compressImage: (file: File, options?: {
2
+ quality?: number;
3
+ maxWidth?: number;
4
+ maxHeight?: number;
5
+ }) => Promise<Blob | File>;
6
+ //# sourceMappingURL=helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../hooks/helper.ts"],"names":[],"mappings":"AAAA,eAOA,MAAM,aAAa,GACjB,MAAM,IAAI,EACV,UAAS;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,KACxE,OAAO,CAAC,IAAI,GAAG,IAAI,CA2CrB,CAAA"}
@@ -0,0 +1,45 @@
1
+ export /**
2
+ * @description
3
+ * @author xieshuhong
4
+ * @param {File} file 原始文件
5
+ * @param {{ quality?: number; maxWidth?: number; maxHeight?: number }} [options={}] 压缩选项
6
+ * @return {*} {(Promise<Blob | File>)} 压缩后的 Blob
7
+ */ const compressImage = (file, options = {}) => {
8
+ const { quality = 0.8, maxWidth, maxHeight } = options;
9
+ return new Promise((resolve, reject) => {
10
+ const reader = new FileReader();
11
+ reader.readAsDataURL(file);
12
+ reader.onload = (e) => {
13
+ const img = new Image();
14
+ img.src = e.target?.result;
15
+ img.onload = () => {
16
+ const canvas = document.createElement('canvas');
17
+ let width = img.width;
18
+ let height = img.height;
19
+ if (maxWidth && width > maxWidth) {
20
+ height = (maxWidth / width) * height;
21
+ width = maxWidth;
22
+ }
23
+ if (maxHeight && height > maxHeight) {
24
+ width = (maxHeight / height) * width;
25
+ height = maxHeight;
26
+ }
27
+ canvas.width = width;
28
+ canvas.height = height;
29
+ const ctx = canvas.getContext('2d');
30
+ ctx?.drawImage(img, 0, 0, width, height);
31
+ canvas.toBlob((blob) => {
32
+ if (blob) {
33
+ resolve(blob);
34
+ }
35
+ else {
36
+ reject(new Error('图片压缩失败'));
37
+ }
38
+ }, file.type, quality);
39
+ };
40
+ img.onerror = (err) => reject(err);
41
+ };
42
+ reader.onerror = (err) => reject(err);
43
+ });
44
+ };
45
+ //# sourceMappingURL=helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helper.js","sourceRoot":"","sources":["../../hooks/helper.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC;;;;;;GAMJ,CACH,MAAM,aAAa,GAAG,CACpB,IAAU,EACV,UAAuE,EAAE,EACnD,EAAE;IACxB,MAAM,EAAE,OAAO,GAAG,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,OAAO,CAAA;IACtD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAA;QAC/B,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;QAC1B,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE;YACpB,MAAM,GAAG,GAAG,IAAI,KAAK,EAAE,CAAA;YACvB,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,MAAM,EAAE,MAAgB,CAAA;YACpC,GAAG,CAAC,MAAM,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CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IACvC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"}
@@ -1,5 +1,4 @@
1
- export * from './useGuider'
2
- export * from './useInitGlobalStyle'
3
- export * from './useButtonPermission'
4
- export * from './useLogout'
5
- //# sourceMappingURL=index.d.ts.map
1
+ export * from './useChartResize';
2
+ export * from './useCountDown';
3
+ export * from './useScroll';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,sBAAsB,CAAA;AACpC,cAAc,uBAAuB,CAAA;AACrC,cAAc,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA"}
@@ -1,5 +1,4 @@
1
- export * from './useGuider'
2
- export * from './useInitGlobalStyle'
3
- export * from './useButtonPermission'
4
- export * from './useLogout'
5
- //# sourceMappingURL=index.js.map
1
+ export * from './useChartResize';
2
+ export * from './useCountDown';
3
+ export * from './useScroll';
4
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,sBAAsB,CAAA;AACpC,cAAc,uBAAuB,CAAA;AACrC,cAAc,aAAa,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA"}
@@ -0,0 +1,20 @@
1
+ import type { ChartInstance } from '@minilo/types';
2
+ export interface UseChartResizeReturn<T extends ChartInstance = ChartInstance> {
3
+ chartInstance: {
4
+ value: T | null;
5
+ };
6
+ resizeChart: () => void;
7
+ destroyChart: () => void;
8
+ refresh: () => void;
9
+ }
10
+ /**
11
+ * @description 图表自适应尺寸 Hooks(适配 ECharts/Chart.js 等)
12
+ * @author xieshuhong
13
+ * @export
14
+ * @template T
15
+ * @param {(string | HTMLElement)} container 图表容器(选择器/元素)
16
+ * @param {(container: HTMLElement) => T} initChart 图表初始化函数
17
+ * @return {*} {UseChartResizeReturn<T>} 图表实例和刷新方法
18
+ */
19
+ export default function useChartResize<T extends ChartInstance = ChartInstance>(container: string | HTMLElement, initChart: (container: HTMLElement) => T): UseChartResizeReturn<T>;
20
+ //# sourceMappingURL=useChartResize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useChartResize.d.ts","sourceRoot":"","sources":["../../hooks/useChartResize.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAElD,MAAM,WAAW,oBAAoB,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa;IAC3E,aAAa,EAAE;QAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAA;KAAE,CAAA;IAClC,WAAW,EAAE,MAAM,IAAI,CAAA;IACvB,YAAY,EAAE,MAAM,IAAI,CAAA;IACxB,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,EAC5E,SAAS,EAAE,MAAM,GAAG,WAAW,EAC/B,SAAS,EAAE,CAAC,SAAS,EAAE,WAAW,KAAK,CAAC,GACvC,oBAAoB,CAAC,CAAC,CAAC,CA2DzB"}
@@ -0,0 +1,67 @@
1
+ import { onMounted, onUnmounted, ref } from 'vue';
2
+ /**
3
+ * @description 图表自适应尺寸 Hooks(适配 ECharts/Chart.js 等)
4
+ * @author xieshuhong
5
+ * @export
6
+ * @template T
7
+ * @param {(string | HTMLElement)} container 图表容器(选择器/元素)
8
+ * @param {(container: HTMLElement) => T} initChart 图表初始化函数
9
+ * @return {*} {UseChartResizeReturn<T>} 图表实例和刷新方法
10
+ */
11
+ export default function useChartResize(container, initChart) {
12
+ const chartInstance = ref(null);
13
+ let resizeTimer = null;
14
+ // 获取容器元素
15
+ const getContainer = () => {
16
+ return typeof container === 'string'
17
+ ? document.querySelector(container)
18
+ : container;
19
+ };
20
+ // 初始化图表
21
+ const init = () => {
22
+ const el = getContainer();
23
+ if (!el)
24
+ return;
25
+ chartInstance.value = initChart(el);
26
+ };
27
+ // 重绘图表(防抖)
28
+ const resizeChart = () => {
29
+ clearTimeout(resizeTimer);
30
+ resizeTimer = setTimeout(() => {
31
+ if (chartInstance.value) {
32
+ chartInstance.value.resize();
33
+ }
34
+ }, 300);
35
+ };
36
+ // 销毁图表
37
+ const destroyChart = () => {
38
+ if (chartInstance.value) {
39
+ chartInstance.value.dispose();
40
+ chartInstance.value = null;
41
+ }
42
+ clearTimeout(resizeTimer);
43
+ };
44
+ // 监听容器尺寸变化
45
+ onMounted(() => {
46
+ init();
47
+ window.addEventListener('resize', resizeChart);
48
+ const el = getContainer();
49
+ if (el)
50
+ new ResizeObserver(resizeChart).observe(el);
51
+ });
52
+ // 组件卸载/销毁
53
+ onUnmounted(() => {
54
+ destroyChart();
55
+ window.removeEventListener('resize', resizeChart);
56
+ const el = getContainer();
57
+ if (el)
58
+ new ResizeObserver(resizeChart).unobserve(el);
59
+ });
60
+ return {
61
+ chartInstance: chartInstance,
62
+ resizeChart,
63
+ destroyChart,
64
+ refresh: init
65
+ };
66
+ }
67
+ //# sourceMappingURL=useChartResize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useChartResize.js","sourceRoot":"","sources":["../../hooks/useChartResize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAUjD;;;;;;;;GAQG;AACH,MAAM,CAAC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A;QACzB,IAAI,EAAE;YAAE,IAAI,cAAc,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;IACrD,CAAC,CAAC,CAAA;IAEF,UAAU;IACV,WAAW,CAAC,GAAG,EAAE;QACf,YAAY,EAAE,CAAA;QACd,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAA;QACjD,MAAM,EAAE,GAAG,YAAY,EAAE,CAAA;QACzB,IAAI,EAAE;YAAE,IAAI,cAAc,CAAC,WAAW,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;IACvD,CAAC,CAAC,CAAA;IAEF,OAAO;QACL,aAAa,EAAE,aAAoC;QACnD,WAAW;QACX,YAAY;QACZ,OAAO,EAAE,IAAI;KACd,CAAA;AACH,CAAC"}
@@ -0,0 +1,9 @@
1
+ export default function useCountdown(seconds: number): {
2
+ remaining: import("vue").Ref<number, number>;
3
+ isRunning: import("vue").Ref<boolean, boolean>;
4
+ formattedTime: import("vue").ComputedRef<string>;
5
+ start: () => void;
6
+ stop: () => void;
7
+ reset: (newSeconds?: number) => void;
8
+ };
9
+ //# sourceMappingURL=useCountDown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCountDown.d.ts","sourceRoot":"","sources":["../../hooks/useCountDown.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,OAAO,EAAE,MAAM;;;;;;;EA4CnD"}