@utogether/utils 2.8.2 → 3.0.0-beta.0

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/index.ts ADDED
@@ -0,0 +1,130 @@
1
+ /*
2
+ * @Author: wei.li
3
+ * @Date: 2022-06-30 10:12:41
4
+ * @LastEditors: levi7754 levi7754@163.com
5
+ * @LastEditTime: 2023-10-12 17:21:18
6
+ * @Description: file content
7
+ */
8
+
9
+ declare interface Fn<T = any, R = T> {
10
+ (...arg: T[]): R;
11
+ }
12
+ // @ts-expect-error
13
+ export { VxetableRender } from "./pkg/render.tsx";
14
+ export { useWatermark } from "./pkg/useWatermark";
15
+ export { useAttrs } from "./pkg/useAttrs";
16
+ export { useRender } from "./pkg/useRender";
17
+ export { useGlobal } from "./pkg/useGlobal";
18
+
19
+ export { addResizeListener, removeResizeListener } from "./pkg/resize";
20
+ export { buildUUID, buildShortUUID } from "./pkg/uuid";
21
+ export { getBrowserInfo, deviceDetection } from "./pkg/device";
22
+ export {
23
+ showMessage,
24
+ warnMessage,
25
+ successMessage,
26
+ errorMessage,
27
+ } from "./pkg/message";
28
+ export {
29
+ i18nColums,
30
+ formatItems,
31
+ formatGridItems,
32
+ formatRules,
33
+ } from "./pkg/formatData";
34
+ export {
35
+ extractPathList,
36
+ buildHierarchyTree,
37
+ getNodeByUniqueId,
38
+ appendFieldByUniqueId,
39
+ deleteTreeChildren,
40
+ } from "./pkg/useTree";
41
+ export { cookies } from "./pkg/cookie";
42
+ export { storageSession, dbstorage } from "./pkg/storage";
43
+ export { http } from "./pkg/http";
44
+ // 日期转换成农历
45
+ export { lunarCalendar } from "./pkg/lunarCalendar";
46
+ export { formats } from "./pkg/format";
47
+
48
+ import { ref } from "vue";
49
+
50
+ export {
51
+ openLink,
52
+ toggleClass,
53
+ removeClass,
54
+ addClass,
55
+ hasClass,
56
+ } from "./pkg/element";
57
+
58
+ import NProgress from "./pkg/progress";
59
+ import type { App, Plugin } from "vue";
60
+ import { storageLocal } from "./pkg/storage";
61
+ import iconSet from "./pkg/remixiconSet";
62
+
63
+ const withInstall = <T>(component) => {
64
+ const comp = component as any;
65
+ comp.install = (app: App) => {
66
+ app.component(comp.name || comp.__name, component);
67
+ };
68
+ return component as T & Plugin;
69
+ };
70
+
71
+ /**
72
+ * @description: 延迟函数
73
+ * @param {number} timeout 延时时间
74
+ * @deprecated 2.6版本废弃, 使用delay代替
75
+ * @return {*}
76
+ */
77
+ function sleep(timer = 64) {
78
+ return new Promise((resolve) => {
79
+ const time = setTimeout(() => {
80
+ window.clearTimeout(time);
81
+ resolve(timer);
82
+ }, timer);
83
+ });
84
+ }
85
+ /**
86
+ * @description: 延迟函数
87
+ * @param {number} timeout 延时时间
88
+ * @return {*}
89
+ */
90
+ export const delay = (timeout: number) =>
91
+ new Promise((resolve) => setTimeout(resolve, timeout));
92
+
93
+ export { withInstall, sleep, NProgress, storageLocal, iconSet };
94
+
95
+ export const useDark = () => {
96
+ const isDark = ref(document.documentElement.classList.contains("dark"));
97
+ return { isDark };
98
+ };
99
+
100
+ // 防抖函数
101
+ export const useDebounce = (fn: () => Fn, timeout: number) => {
102
+ let timmer;
103
+ return () => {
104
+ timmer ? clearTimeout(timmer) : null;
105
+ timmer = setTimeout(fn, timeout);
106
+ };
107
+ };
108
+ /**
109
+ * @description: 判断路径是否合法
110
+ * @param {string} path 服务路径
111
+ * @return {*} boolean
112
+ */
113
+ export function isUrl(path: string): boolean {
114
+ // @ts-ignore
115
+ const reg =
116
+ // eslint-disable-next-line no-useless-escape
117
+ /(((^http(s)?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/;
118
+ return reg.test(path);
119
+ }
120
+ /**
121
+ * @description: 根据值查找字典名称
122
+ * @param {*} dictCode 字典编码
123
+ * @param {*} val 数据值
124
+ * @return {*} 字典名称
125
+ */
126
+ export const getDictName = (dictCode, val) => {
127
+ if (!dictCode || !val) return null;
128
+ const dict = storageLocal.getItem("kLov");
129
+ return dict[dictCode]?.children.find((m) => val === m.dictCode)?.dictName;
130
+ };
package/package.json CHANGED
@@ -1,26 +1,29 @@
1
- {
2
- "name": "@utogether/utils",
3
- "private": false,
4
- "version": "2.8.2",
5
- "description": "",
6
- "main": "dist/utils.umd.js",
7
- "module": "dist/utils.umd.js",
8
- "scripts": {
9
- "dev": "vite",
10
- "build": "vite build",
11
- "build:less": "esno build/buildScss"
12
- },
13
- "files": [
14
- "dist/utils.umd.js",
15
- "dist/style.css",
16
- "dist/index.d.ts",
17
- "dist/pkg"
18
- ],
19
- "typings": "dist/index.d.ts",
20
- "keywords": [],
21
- "author": "levi7754@163.com",
22
- "license": "ISC",
23
- "dependencies": {
24
- "localforage": "^1.10.0"
25
- }
26
- }
1
+ {
2
+ "name": "@utogether/utils",
3
+ "private": false,
4
+ "version": "3.0.0-beta.0",
5
+ "description": "",
6
+ "main1": "dist/utils.umd.js",
7
+ "module1": "dist/utils.es.js",
8
+ "main": "index.ts",
9
+ "module": "index.ts",
10
+ "scripts": {
11
+ "dev": "vite",
12
+ "build": "vite build",
13
+ "build:less": "esno build/buildScss"
14
+ },
15
+ "files": [
16
+ "dist/utils.umd.js",
17
+ "dist/utils.es.js",
18
+ "dist/style.css",
19
+ "dist/index.d.ts",
20
+ "dist/pkg"
21
+ ],
22
+ "typings": "dist/index.d.ts",
23
+ "keywords": [],
24
+ "author": "levi7754@163.com",
25
+ "license": "ISC",
26
+ "devDependencies": {
27
+ "localforage": "^1.10.0"
28
+ }
29
+ }
package/dist/index.d.ts DELETED
@@ -1,56 +0,0 @@
1
- declare interface Fn<T = any, R = T> {
2
- (...arg: T[]): R;
3
- }
4
- export { VxetableRender } from "./pkg/render.tsx";
5
- export { useWatermark } from "./pkg/useWatermark";
6
- export { useAttrs } from "./pkg/useAttrs";
7
- export { useRender } from "./pkg/useRender";
8
- export { useGlobal } from "./pkg/useGlobal";
9
- export { addResizeListener, removeResizeListener } from "./pkg/resize";
10
- export { buildUUID, buildShortUUID } from "./pkg/uuid";
11
- export { getBrowserInfo, deviceDetection } from "./pkg/device";
12
- export { showMessage, warnMessage, successMessage, errorMessage, } from "./pkg/message";
13
- export { i18nColums, formatItems, formatGridItems, formatRules, } from "./pkg/formatData";
14
- export { extractPathList, buildHierarchyTree, getNodeByUniqueId, appendFieldByUniqueId, deleteTreeChildren, } from "./pkg/useTree";
15
- export { cookies } from "./pkg/cookie";
16
- export { storageSession, dbstorage } from "./pkg/storage";
17
- export { http } from "./pkg/http";
18
- export { lunarCalendar } from "./pkg/lunarCalendar";
19
- export { formats } from "./pkg/format";
20
- export { openLink, toggleClass, removeClass, addClass, hasClass, } from "./pkg/element";
21
- import NProgress from "./pkg/progress";
22
- import type { Plugin } from "vue";
23
- import { storageLocal } from "./pkg/storage";
24
- import iconSet from "./pkg/remixiconSet";
25
- declare const withInstall: <T>(component: any) => T & Plugin<any[]>;
26
- /**
27
- * @description: 延迟函数
28
- * @param {number} timeout 延时时间
29
- * @deprecated 2.6版本废弃, 使用delay代替
30
- * @return {*}
31
- */
32
- declare function sleep(timer?: number): Promise<unknown>;
33
- /**
34
- * @description: 延迟函数
35
- * @param {number} timeout 延时时间
36
- * @return {*}
37
- */
38
- export declare const delay: (timeout: number) => Promise<unknown>;
39
- export { withInstall, sleep, NProgress, storageLocal, iconSet };
40
- export declare const useDark: () => {
41
- isDark: import("vue").Ref<boolean>;
42
- };
43
- export declare const useDebounce: (fn: () => Fn, timeout: number) => () => void;
44
- /**
45
- * @description: 判断路径是否合法
46
- * @param {string} path 服务路径
47
- * @return {*} boolean
48
- */
49
- export declare function isUrl(path: string): boolean;
50
- /**
51
- * @description: 根据值查找字典名称
52
- * @param {*} dictCode 字典编码
53
- * @param {*} val 数据值
54
- * @return {*} 字典名称
55
- */
56
- export declare const getDictName: (dictCode: any, val: any) => any;