@utogether/utils 3.0.0-beta.0 → 3.0.0-beta.2
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/package.json +6 -6
- package/index.ts +0 -130
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@utogether/utils",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "3.0.0-beta.
|
|
4
|
+
"version": "3.0.0-beta.2",
|
|
5
5
|
"description": "",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
6
|
+
"main": "dist/utils.umd.js",
|
|
7
|
+
"module": "dist/utils.es.js",
|
|
8
|
+
"main1": "index.ts",
|
|
9
|
+
"module1": "index.ts",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"dev": "vite",
|
|
12
12
|
"build": "vite build",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"keywords": [],
|
|
24
24
|
"author": "levi7754@163.com",
|
|
25
25
|
"license": "ISC",
|
|
26
|
-
"
|
|
26
|
+
"dependencies": {
|
|
27
27
|
"localforage": "^1.10.0"
|
|
28
28
|
}
|
|
29
29
|
}
|
package/index.ts
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
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
|
-
};
|