fast-element-plus 1.0.0-alpha.0 → 1.0.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/package.json +24 -121
- package/Fast.png +0 -0
- package/LICENSE +0 -201
- package/README.md +0 -158
- package/README.zh.md +0 -158
- package/dist/index.iife.js +0 -2
- package/dist/index.iife.js.map +0 -1
- package/dist/index.umd.js +0 -2
- package/dist/index.umd.js.map +0 -1
- package/es/components/icon/index.d.ts +0 -20
- package/es/components/icon/index.mjs +0 -9
- package/es/components/icon/index.mjs.map +0 -1
- package/es/components/icon/src/icon.d.ts +0 -61
- package/es/components/icon/src/icon.mjs +0 -81
- package/es/components/icon/src/icon.mjs.map +0 -1
- package/es/components/index.d.ts +0 -1
- package/es/components/index.mjs +0 -5
- package/es/components/index.mjs.map +0 -1
- package/es/constants/index.d.ts +0 -2
- package/es/constants/index.mjs +0 -7
- package/es/constants/index.mjs.map +0 -1
- package/es/constants/mime.d.ts +0 -61
- package/es/constants/mime.mjs +0 -62
- package/es/constants/mime.mjs.map +0 -1
- package/es/constants/regex.d.ts +0 -78
- package/es/constants/regex.mjs +0 -79
- package/es/constants/regex.mjs.map +0 -1
- package/es/directives/clickCopy/index.d.ts +0 -2
- package/es/directives/clickCopy/index.mjs +0 -39
- package/es/directives/clickCopy/index.mjs.map +0 -1
- package/es/directives/clickDebounce/index.d.ts +0 -2
- package/es/directives/clickDebounce/index.mjs +0 -21
- package/es/directives/clickDebounce/index.mjs.map +0 -1
- package/es/directives/clickDraggable/index.d.ts +0 -2
- package/es/directives/clickDraggable/index.mjs +0 -39
- package/es/directives/clickDraggable/index.mjs.map +0 -1
- package/es/directives/clickIconCopy/index.d.ts +0 -2
- package/es/directives/clickIconCopy/index.mjs +0 -57
- package/es/directives/clickIconCopy/index.mjs.map +0 -1
- package/es/directives/clickLongpress/index.d.ts +0 -2
- package/es/directives/clickLongpress/index.mjs +0 -43
- package/es/directives/clickLongpress/index.mjs.map +0 -1
- package/es/directives/clickThrottle/index.d.ts +0 -2
- package/es/directives/clickThrottle/index.mjs +0 -32
- package/es/directives/clickThrottle/index.mjs.map +0 -1
- package/es/directives/index.d.ts +0 -6
- package/es/directives/index.mjs +0 -15
- package/es/directives/index.mjs.map +0 -1
- package/es/fast-element-plus/component.d.ts +0 -3
- package/es/fast-element-plus/component.mjs +0 -6
- package/es/fast-element-plus/component.mjs.map +0 -1
- package/es/fast-element-plus/directive.d.ts +0 -2
- package/es/fast-element-plus/directive.mjs +0 -11
- package/es/fast-element-plus/directive.mjs.map +0 -1
- package/es/fast-element-plus/element-plus.d.ts +0 -2
- package/es/fast-element-plus/element-plus.mjs +0 -113
- package/es/fast-element-plus/element-plus.mjs.map +0 -1
- package/es/fast-element-plus/fast-element-plus.d.ts +0 -3
- package/es/fast-element-plus/fast-element-plus.mjs +0 -12
- package/es/fast-element-plus/fast-element-plus.mjs.map +0 -1
- package/es/fast-element-plus/make-installer.d.ts +0 -7
- package/es/fast-element-plus/make-installer.mjs +0 -30
- package/es/fast-element-plus/make-installer.mjs.map +0 -1
- package/es/fast-element-plus/version.d.ts +0 -4
- package/es/fast-element-plus/version.mjs +0 -5
- package/es/fast-element-plus/version.mjs.map +0 -1
- package/es/hooks/index.d.ts +0 -2
- package/es/hooks/index.mjs +0 -7
- package/es/hooks/index.mjs.map +0 -1
- package/es/hooks/useLoading/index.d.ts +0 -4
- package/es/hooks/useLoading/index.mjs +0 -35
- package/es/hooks/useLoading/index.mjs.map +0 -1
- package/es/hooks/useOverlay/index.d.ts +0 -4
- package/es/hooks/useOverlay/index.mjs +0 -27
- package/es/hooks/useOverlay/index.mjs.map +0 -1
- package/es/hooks/useScreenFull/index.d.ts +0 -0
- package/es/index.d.ts +0 -16
- package/es/index.es.d.ts +0 -6
- package/es/index.mjs +0 -82
- package/es/index.mjs.map +0 -1
- package/es/settings/index.d.ts +0 -79
- package/es/settings/index.mjs +0 -35
- package/es/settings/index.mjs.map +0 -1
- package/es/stores/index.d.ts +0 -4
- package/es/stores/index.mjs +0 -7
- package/es/stores/index.mjs.map +0 -1
- package/es/utils/base64.d.ts +0 -10
- package/es/utils/base64.mjs +0 -106
- package/es/utils/base64.mjs.map +0 -1
- package/es/utils/click.d.ts +0 -14
- package/es/utils/click.mjs +0 -35
- package/es/utils/click.mjs.map +0 -1
- package/es/utils/color.d.ts +0 -31
- package/es/utils/color.mjs +0 -73
- package/es/utils/color.mjs.map +0 -1
- package/es/utils/console.d.ts +0 -21
- package/es/utils/console.mjs +0 -19
- package/es/utils/console.mjs.map +0 -1
- package/es/utils/deviceId.d.ts +0 -9
- package/es/utils/deviceId.mjs +0 -27
- package/es/utils/deviceId.mjs.map +0 -1
- package/es/utils/errorHandler.d.ts +0 -4
- package/es/utils/errorHandler.mjs +0 -42
- package/es/utils/errorHandler.mjs.map +0 -1
- package/es/utils/form.d.ts +0 -78
- package/es/utils/form.mjs +0 -218
- package/es/utils/form.mjs.map +0 -1
- package/es/utils/index.d.ts +0 -10
- package/es/utils/index.mjs +0 -29
- package/es/utils/index.mjs.map +0 -1
- package/es/utils/storage.d.ts +0 -79
- package/es/utils/storage.mjs +0 -219
- package/es/utils/storage.mjs.map +0 -1
- package/es/utils/string.d.ts +0 -33
- package/es/utils/string.mjs +0 -119
- package/es/utils/string.mjs.map +0 -1
- package/es/utils/vue/func.d.ts +0 -7
- package/es/utils/vue/func.mjs +0 -17
- package/es/utils/vue/func.mjs.map +0 -1
- package/es/utils/vue/index.d.ts +0 -6
- package/es/utils/vue/index.mjs +0 -17
- package/es/utils/vue/index.mjs.map +0 -1
- package/es/utils/vue/install.d.ts +0 -5
- package/es/utils/vue/install.mjs +0 -31
- package/es/utils/vue/install.mjs.map +0 -1
- package/es/utils/vue/props.d.ts +0 -10
- package/es/utils/vue/props.mjs +0 -14
- package/es/utils/vue/props.mjs.map +0 -1
- package/es/utils/vue/slots.d.ts +0 -11
- package/es/utils/vue/slots.mjs +0 -7
- package/es/utils/vue/slots.mjs.map +0 -1
- package/es/utils/vue/useRender.d.ts +0 -7
- package/es/utils/vue/useRender.mjs +0 -12
- package/es/utils/vue/useRender.mjs.map +0 -1
- package/es/utils/vue/with.d.ts +0 -6
- package/es/utils/vue/with.mjs +0 -7
- package/es/utils/vue/with.mjs.map +0 -1
- package/global.d.ts +0 -3
- package/lib/components/icon/index.d.ts +0 -20
- package/lib/components/icon/index.js +0 -2
- package/lib/components/icon/index.js.map +0 -1
- package/lib/components/icon/src/icon.d.ts +0 -61
- package/lib/components/icon/src/icon.js +0 -2
- package/lib/components/icon/src/icon.js.map +0 -1
- package/lib/components/index.d.ts +0 -1
- package/lib/components/index.js +0 -2
- package/lib/components/index.js.map +0 -1
- package/lib/constants/index.d.ts +0 -2
- package/lib/constants/index.js +0 -2
- package/lib/constants/index.js.map +0 -1
- package/lib/constants/mime.d.ts +0 -61
- package/lib/constants/mime.js +0 -2
- package/lib/constants/mime.js.map +0 -1
- package/lib/constants/regex.d.ts +0 -78
- package/lib/constants/regex.js +0 -2
- package/lib/constants/regex.js.map +0 -1
- package/lib/directives/clickCopy/index.d.ts +0 -2
- package/lib/directives/clickCopy/index.js +0 -2
- package/lib/directives/clickCopy/index.js.map +0 -1
- package/lib/directives/clickDebounce/index.d.ts +0 -2
- package/lib/directives/clickDebounce/index.js +0 -2
- package/lib/directives/clickDebounce/index.js.map +0 -1
- package/lib/directives/clickDraggable/index.d.ts +0 -2
- package/lib/directives/clickDraggable/index.js +0 -2
- package/lib/directives/clickDraggable/index.js.map +0 -1
- package/lib/directives/clickIconCopy/index.d.ts +0 -2
- package/lib/directives/clickIconCopy/index.js +0 -2
- package/lib/directives/clickIconCopy/index.js.map +0 -1
- package/lib/directives/clickLongpress/index.d.ts +0 -2
- package/lib/directives/clickLongpress/index.js +0 -2
- package/lib/directives/clickLongpress/index.js.map +0 -1
- package/lib/directives/clickThrottle/index.d.ts +0 -2
- package/lib/directives/clickThrottle/index.js +0 -2
- package/lib/directives/clickThrottle/index.js.map +0 -1
- package/lib/directives/index.d.ts +0 -6
- package/lib/directives/index.js +0 -2
- package/lib/directives/index.js.map +0 -1
- package/lib/fast-element-plus/component.d.ts +0 -3
- package/lib/fast-element-plus/component.js +0 -2
- package/lib/fast-element-plus/component.js.map +0 -1
- package/lib/fast-element-plus/directive.d.ts +0 -2
- package/lib/fast-element-plus/directive.js +0 -2
- package/lib/fast-element-plus/directive.js.map +0 -1
- package/lib/fast-element-plus/element-plus.d.ts +0 -2
- package/lib/fast-element-plus/element-plus.js +0 -2
- package/lib/fast-element-plus/element-plus.js.map +0 -1
- package/lib/fast-element-plus/fast-element-plus.d.ts +0 -3
- package/lib/fast-element-plus/fast-element-plus.js +0 -2
- package/lib/fast-element-plus/fast-element-plus.js.map +0 -1
- package/lib/fast-element-plus/make-installer.d.ts +0 -7
- package/lib/fast-element-plus/make-installer.js +0 -2
- package/lib/fast-element-plus/make-installer.js.map +0 -1
- package/lib/fast-element-plus/version.d.ts +0 -4
- package/lib/fast-element-plus/version.js +0 -2
- package/lib/fast-element-plus/version.js.map +0 -1
- package/lib/hooks/index.d.ts +0 -2
- package/lib/hooks/index.js +0 -2
- package/lib/hooks/index.js.map +0 -1
- package/lib/hooks/useLoading/index.d.ts +0 -4
- package/lib/hooks/useLoading/index.js +0 -2
- package/lib/hooks/useLoading/index.js.map +0 -1
- package/lib/hooks/useOverlay/index.d.ts +0 -4
- package/lib/hooks/useOverlay/index.js +0 -2
- package/lib/hooks/useOverlay/index.js.map +0 -1
- package/lib/hooks/useScreenFull/index.d.ts +0 -0
- package/lib/index.d.ts +0 -16
- package/lib/index.es.d.ts +0 -6
- package/lib/index.js +0 -2
- package/lib/index.js.map +0 -1
- package/lib/settings/index.d.ts +0 -79
- package/lib/settings/index.js +0 -2
- package/lib/settings/index.js.map +0 -1
- package/lib/stores/index.d.ts +0 -4
- package/lib/stores/index.js +0 -2
- package/lib/stores/index.js.map +0 -1
- package/lib/utils/base64.d.ts +0 -10
- package/lib/utils/base64.js +0 -2
- package/lib/utils/base64.js.map +0 -1
- package/lib/utils/click.d.ts +0 -14
- package/lib/utils/click.js +0 -2
- package/lib/utils/click.js.map +0 -1
- package/lib/utils/color.d.ts +0 -31
- package/lib/utils/color.js +0 -2
- package/lib/utils/color.js.map +0 -1
- package/lib/utils/console.d.ts +0 -21
- package/lib/utils/console.js +0 -2
- package/lib/utils/console.js.map +0 -1
- package/lib/utils/deviceId.d.ts +0 -9
- package/lib/utils/deviceId.js +0 -2
- package/lib/utils/deviceId.js.map +0 -1
- package/lib/utils/errorHandler.d.ts +0 -4
- package/lib/utils/errorHandler.js +0 -2
- package/lib/utils/errorHandler.js.map +0 -1
- package/lib/utils/form.d.ts +0 -78
- package/lib/utils/form.js +0 -2
- package/lib/utils/form.js.map +0 -1
- package/lib/utils/index.d.ts +0 -10
- package/lib/utils/index.js +0 -2
- package/lib/utils/index.js.map +0 -1
- package/lib/utils/storage.d.ts +0 -79
- package/lib/utils/storage.js +0 -2
- package/lib/utils/storage.js.map +0 -1
- package/lib/utils/string.d.ts +0 -33
- package/lib/utils/string.js +0 -2
- package/lib/utils/string.js.map +0 -1
- package/lib/utils/vue/func.d.ts +0 -7
- package/lib/utils/vue/func.js +0 -2
- package/lib/utils/vue/func.js.map +0 -1
- package/lib/utils/vue/index.d.ts +0 -6
- package/lib/utils/vue/index.js +0 -2
- package/lib/utils/vue/index.js.map +0 -1
- package/lib/utils/vue/install.d.ts +0 -5
- package/lib/utils/vue/install.js +0 -2
- package/lib/utils/vue/install.js.map +0 -1
- package/lib/utils/vue/props.d.ts +0 -10
- package/lib/utils/vue/props.js +0 -2
- package/lib/utils/vue/props.js.map +0 -1
- package/lib/utils/vue/slots.d.ts +0 -11
- package/lib/utils/vue/slots.js +0 -2
- package/lib/utils/vue/slots.js.map +0 -1
- package/lib/utils/vue/useRender.d.ts +0 -7
- package/lib/utils/vue/useRender.js +0 -2
- package/lib/utils/vue/useRender.js.map +0 -1
- package/lib/utils/vue/with.d.ts +0 -6
- package/lib/utils/vue/with.js +0 -2
- package/lib/utils/vue/with.js.map +0 -1
- package/types/env.d.ts +0 -45
- package/types/runtime-core.d.ts +0 -52
- package/types/shims-vue.d.ts +0 -20
package/es/utils/storage.mjs
DELETED
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
import { fastOptions } from "../settings/index.mjs";
|
|
2
|
-
import "./index.mjs";
|
|
3
|
-
import { base64Util } from "./base64.mjs";
|
|
4
|
-
import { consoleError } from "./console.mjs";
|
|
5
|
-
const CACHE_PREFIX = "fast__";
|
|
6
|
-
const CACHE_EXPIRE_SUFFIX = "__Expire";
|
|
7
|
-
const Local = {
|
|
8
|
-
/**
|
|
9
|
-
* 设置
|
|
10
|
-
* @param key 缓存的Key
|
|
11
|
-
* @param val 缓存值
|
|
12
|
-
* @param expire 过期时间,单位分钟
|
|
13
|
-
* @param encrypt 是否对缓存的数据加密
|
|
14
|
-
*/
|
|
15
|
-
set(key, val, expire, encrypt) {
|
|
16
|
-
try {
|
|
17
|
-
encrypt ?? (encrypt = fastOptions.storageCrypto);
|
|
18
|
-
if (expire) {
|
|
19
|
-
if (isNaN(expire) || expire < 1) {
|
|
20
|
-
throw new Error("有效期应为一个有效数值");
|
|
21
|
-
}
|
|
22
|
-
const expireData = {
|
|
23
|
-
time: Date.now(),
|
|
24
|
-
expire
|
|
25
|
-
};
|
|
26
|
-
const expireJson = JSON.stringify(expireData);
|
|
27
|
-
window.localStorage.setItem(`${CACHE_PREFIX}${key}${CACHE_EXPIRE_SUFFIX}`, expireJson);
|
|
28
|
-
}
|
|
29
|
-
let valJson = JSON.stringify(val);
|
|
30
|
-
if (encrypt) {
|
|
31
|
-
valJson = base64Util.toBase64(valJson);
|
|
32
|
-
}
|
|
33
|
-
window.localStorage.setItem(`${CACHE_PREFIX}${key}`, valJson);
|
|
34
|
-
} catch (error) {
|
|
35
|
-
consoleError("Local", error);
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
/**
|
|
39
|
-
* 获取
|
|
40
|
-
* @param key 缓存的Key
|
|
41
|
-
* @param decrypt 是否对缓存的数据解密
|
|
42
|
-
* @returns {T} 传入的对象类型,默认为 string
|
|
43
|
-
*/
|
|
44
|
-
get(key, decrypt) {
|
|
45
|
-
try {
|
|
46
|
-
decrypt ?? (decrypt = fastOptions.storageCrypto);
|
|
47
|
-
let valJson = window.localStorage.getItem(`${CACHE_PREFIX}${key}`);
|
|
48
|
-
if (valJson) {
|
|
49
|
-
if (decrypt) {
|
|
50
|
-
valJson = base64Util.base64ToStr(valJson);
|
|
51
|
-
}
|
|
52
|
-
const expireJson = window.localStorage.getItem(`${CACHE_PREFIX}${key}${CACHE_EXPIRE_SUFFIX}`);
|
|
53
|
-
if (expireJson) {
|
|
54
|
-
const expireData = JSON.parse(expireJson);
|
|
55
|
-
if (Date.now() > expireData.time + expireData.expire * 60 * 1e3) {
|
|
56
|
-
window.localStorage.removeItem(`${CACHE_PREFIX}${key}`);
|
|
57
|
-
window.localStorage.removeItem(`${CACHE_PREFIX}${key}${CACHE_EXPIRE_SUFFIX}`);
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
try {
|
|
62
|
-
return JSON.parse(valJson);
|
|
63
|
-
} catch {
|
|
64
|
-
return valJson;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return null;
|
|
68
|
-
} catch (error) {
|
|
69
|
-
consoleError("Local", error);
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
/**
|
|
73
|
-
* 移除
|
|
74
|
-
* @param key 缓存的Key
|
|
75
|
-
*/
|
|
76
|
-
remove(key) {
|
|
77
|
-
try {
|
|
78
|
-
window.localStorage.removeItem(`${CACHE_PREFIX}${key}`);
|
|
79
|
-
window.localStorage.removeItem(`${CACHE_PREFIX}${key}${CACHE_EXPIRE_SUFFIX}`);
|
|
80
|
-
} catch (error) {
|
|
81
|
-
consoleError("Local", error);
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
/**
|
|
85
|
-
* 根据前缀移除
|
|
86
|
-
* @param key 缓存的Key
|
|
87
|
-
*/
|
|
88
|
-
removeByPrefix(key) {
|
|
89
|
-
try {
|
|
90
|
-
for (const itemKey in window.localStorage) {
|
|
91
|
-
if (itemKey.indexOf(`${CACHE_PREFIX}${key}`) !== -1) {
|
|
92
|
-
window.localStorage.removeItem(itemKey);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
} catch (error) {
|
|
96
|
-
consoleError("Local", error);
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
/**
|
|
100
|
-
* 移除全部
|
|
101
|
-
*/
|
|
102
|
-
clear() {
|
|
103
|
-
try {
|
|
104
|
-
window.localStorage.clear();
|
|
105
|
-
} catch (error) {
|
|
106
|
-
consoleError("Local", error);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
const Session = {
|
|
111
|
-
/**
|
|
112
|
-
* 设置会话缓存
|
|
113
|
-
* @param key 缓存的Key
|
|
114
|
-
* @param val 缓存值
|
|
115
|
-
* @param expire 过期时间,单位分钟
|
|
116
|
-
* @param encrypt 是否对缓存的数据加密
|
|
117
|
-
*/
|
|
118
|
-
set(key, val, expire, encrypt) {
|
|
119
|
-
try {
|
|
120
|
-
encrypt ?? (encrypt = fastOptions.storageCrypto);
|
|
121
|
-
if (expire) {
|
|
122
|
-
if (isNaN(expire) || expire < 1) {
|
|
123
|
-
throw new Error("有效期应为一个有效数值");
|
|
124
|
-
}
|
|
125
|
-
const expireData = {
|
|
126
|
-
time: Date.now(),
|
|
127
|
-
expire
|
|
128
|
-
};
|
|
129
|
-
const expireJson = JSON.stringify(expireData);
|
|
130
|
-
window.sessionStorage.setItem(`${CACHE_PREFIX}${key}${CACHE_EXPIRE_SUFFIX}`, expireJson);
|
|
131
|
-
}
|
|
132
|
-
let valJson = JSON.stringify(val);
|
|
133
|
-
if (encrypt) {
|
|
134
|
-
valJson = base64Util.toBase64(valJson);
|
|
135
|
-
}
|
|
136
|
-
window.sessionStorage.setItem(`${CACHE_PREFIX}${key}`, valJson);
|
|
137
|
-
} catch (error) {
|
|
138
|
-
consoleError("Session", error);
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
/**
|
|
142
|
-
* 获取会话缓存
|
|
143
|
-
* @param key 缓存的Key
|
|
144
|
-
* @param decrypt 是否对缓存的数据解密
|
|
145
|
-
* @returns {T} 传入的对象类型,默认为 string
|
|
146
|
-
*/
|
|
147
|
-
get(key, decrypt) {
|
|
148
|
-
try {
|
|
149
|
-
decrypt ?? (decrypt = fastOptions.storageCrypto);
|
|
150
|
-
let valJson = window.sessionStorage.getItem(`${CACHE_PREFIX}${key}`);
|
|
151
|
-
if (valJson) {
|
|
152
|
-
if (decrypt) {
|
|
153
|
-
valJson = base64Util.base64ToStr(valJson);
|
|
154
|
-
}
|
|
155
|
-
const expireJson = window.sessionStorage.getItem(`${CACHE_PREFIX}${key}${CACHE_EXPIRE_SUFFIX}`);
|
|
156
|
-
if (expireJson) {
|
|
157
|
-
const expireData = JSON.parse(expireJson);
|
|
158
|
-
if (Date.now() > expireData.time + expireData.expire * 60 * 1e3) {
|
|
159
|
-
window.sessionStorage.removeItem(`${CACHE_PREFIX}${key}`);
|
|
160
|
-
window.sessionStorage.removeItem(`${CACHE_PREFIX}${key}${CACHE_EXPIRE_SUFFIX}`);
|
|
161
|
-
return null;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
try {
|
|
165
|
-
return JSON.parse(valJson);
|
|
166
|
-
} catch {
|
|
167
|
-
return valJson;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
return null;
|
|
171
|
-
} catch (error) {
|
|
172
|
-
consoleError("Session", error);
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
/**
|
|
176
|
-
* 移除会话缓存
|
|
177
|
-
* @param key 缓存的Key
|
|
178
|
-
*/
|
|
179
|
-
remove(key) {
|
|
180
|
-
try {
|
|
181
|
-
window.sessionStorage.removeItem(`${CACHE_PREFIX}${key}`);
|
|
182
|
-
window.sessionStorage.removeItem(`${CACHE_PREFIX}${key}${CACHE_EXPIRE_SUFFIX}`);
|
|
183
|
-
} catch (error) {
|
|
184
|
-
consoleError("Session", error);
|
|
185
|
-
}
|
|
186
|
-
},
|
|
187
|
-
/**
|
|
188
|
-
* 根据前缀移除会话缓存
|
|
189
|
-
* @param key 缓存的Key
|
|
190
|
-
*/
|
|
191
|
-
removeByPrefix(key) {
|
|
192
|
-
try {
|
|
193
|
-
for (const itemKey in window.sessionStorage) {
|
|
194
|
-
if (itemKey.indexOf(`${CACHE_PREFIX}${key}`) !== -1) {
|
|
195
|
-
window.sessionStorage.removeItem(itemKey);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
} catch (error) {
|
|
199
|
-
consoleError("Session", error);
|
|
200
|
-
}
|
|
201
|
-
},
|
|
202
|
-
/**
|
|
203
|
-
* 移除全部会话缓存
|
|
204
|
-
*/
|
|
205
|
-
clear() {
|
|
206
|
-
try {
|
|
207
|
-
window.sessionStorage.clear();
|
|
208
|
-
} catch (error) {
|
|
209
|
-
consoleError("Session", error);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
export {
|
|
214
|
-
CACHE_EXPIRE_SUFFIX,
|
|
215
|
-
CACHE_PREFIX,
|
|
216
|
-
Local,
|
|
217
|
-
Session
|
|
218
|
-
};
|
|
219
|
-
//# sourceMappingURL=storage.mjs.map
|
package/es/utils/storage.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage.mjs","sources":["../../../packages/utils/storage.ts"],"sourcesContent":["/**\n * 本地缓存\n */\n\nimport { fastOptions } from \"@fast-element-plus/settings\";\nimport { base64Util, consoleError } from \"@fast-element-plus/utils\";\n\n/**\n * 本地缓存前缀 Key\n */\nexport const CACHE_PREFIX = \"fast__\";\n\n/**\n * 本地缓存过期值后缀 Key\n */\nexport const CACHE_EXPIRE_SUFFIX = \"__Expire\";\n\n/**\n * window.localStorage\n */\nexport const Local = {\n\t/**\n\t * 设置\n\t * @param key 缓存的Key\n\t * @param val 缓存值\n\t * @param expire 过期时间,单位分钟\n\t * @param encrypt 是否对缓存的数据加密\n\t */\n\tset(key: string, val: any, expire?: number, encrypt?: boolean): void {\n\t\ttry {\n\t\t\tencrypt ??= fastOptions.storageCrypto;\n\t\t\t// 判断是否存在缓存过期时间\n\t\t\tif (expire) {\n\t\t\t\tif (isNaN(expire) || expire < 1) {\n\t\t\t\t\tthrow new Error(\"有效期应为一个有效数值\");\n\t\t\t\t}\n\t\t\t\t// 设置过期时间的缓存\n\t\t\t\tconst expireData = {\n\t\t\t\t\ttime: Date.now(),\n\t\t\t\t\texpire,\n\t\t\t\t};\n\t\t\t\tconst expireJson = JSON.stringify(expireData);\n\t\t\t\twindow.localStorage.setItem(`${CACHE_PREFIX}${key}${CACHE_EXPIRE_SUFFIX}`, expireJson);\n\t\t\t}\n\t\t\tlet valJson = JSON.stringify(val);\n\t\t\tif (encrypt) {\n\t\t\t\tvalJson = base64Util.toBase64(valJson);\n\t\t\t}\n\t\t\twindow.localStorage.setItem(`${CACHE_PREFIX}${key}`, valJson);\n\t\t} catch (error) {\n\t\t\tconsoleError(\"Local\", error);\n\t\t}\n\t},\n\t/**\n\t * 获取\n\t * @param key 缓存的Key\n\t * @param decrypt 是否对缓存的数据解密\n\t * @returns {T} 传入的对象类型,默认为 string\n\t */\n\tget<T = string>(key: string, decrypt?: boolean): T {\n\t\ttry {\n\t\t\tdecrypt ??= fastOptions.storageCrypto;\n\t\t\t// 获取缓存 JSON 字符串\n\t\t\tlet valJson = window.localStorage.getItem(`${CACHE_PREFIX}${key}`);\n\t\t\tif (valJson) {\n\t\t\t\t// 判断是否解密\n\t\t\t\tif (decrypt) {\n\t\t\t\t\tvalJson = base64Util.base64ToStr(valJson);\n\t\t\t\t}\n\t\t\t\t// 尝试获取缓存过期时间的 JSON 字符串\n\t\t\t\tconst expireJson = window.localStorage.getItem(`${CACHE_PREFIX}${key}${CACHE_EXPIRE_SUFFIX}`);\n\t\t\t\t// 判断是否存在过期时间\n\t\t\t\tif (expireJson) {\n\t\t\t\t\tconst expireData = JSON.parse(expireJson) as anyObj;\n\t\t\t\t\tif (Date.now() > expireData.time + expireData.expire * 60 * 1000) {\n\t\t\t\t\t\t// 过期了,删除对应的缓存数据\n\t\t\t\t\t\twindow.localStorage.removeItem(`${CACHE_PREFIX}${key}`);\n\t\t\t\t\t\twindow.localStorage.removeItem(`${CACHE_PREFIX}${key}${CACHE_EXPIRE_SUFFIX}`);\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\treturn JSON.parse(valJson) as T;\n\t\t\t\t} catch {\n\t\t\t\t\treturn valJson as T;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t} catch (error) {\n\t\t\tconsoleError(\"Local\", error);\n\t\t}\n\t},\n\t/**\n\t * 移除\n\t * @param key 缓存的Key\n\t */\n\tremove(key: string): void {\n\t\ttry {\n\t\t\twindow.localStorage.removeItem(`${CACHE_PREFIX}${key}`);\n\t\t\twindow.localStorage.removeItem(`${CACHE_PREFIX}${key}${CACHE_EXPIRE_SUFFIX}`);\n\t\t} catch (error) {\n\t\t\tconsoleError(\"Local\", error);\n\t\t}\n\t},\n\t/**\n\t * 根据前缀移除\n\t * @param key 缓存的Key\n\t */\n\tremoveByPrefix(key: string): void {\n\t\ttry {\n\t\t\tfor (const itemKey in window.localStorage) {\n\t\t\t\tif (itemKey.indexOf(`${CACHE_PREFIX}${key}`) !== -1) {\n\t\t\t\t\twindow.localStorage.removeItem(itemKey);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsoleError(\"Local\", error);\n\t\t}\n\t},\n\t/**\n\t * 移除全部\n\t */\n\tclear(): void {\n\t\ttry {\n\t\t\twindow.localStorage.clear();\n\t\t} catch (error) {\n\t\t\tconsoleError(\"Local\", error);\n\t\t}\n\t},\n};\n\n/**\n * window.sessionStorage\n */\nexport const Session = {\n\t/**\n\t * 设置会话缓存\n\t * @param key 缓存的Key\n\t * @param val 缓存值\n\t * @param expire 过期时间,单位分钟\n\t * @param encrypt 是否对缓存的数据加密\n\t */\n\tset(key: string, val: any, expire?: number, encrypt?: boolean): void {\n\t\ttry {\n\t\t\tencrypt ??= fastOptions.storageCrypto;\n\t\t\t// 判断是否存在缓存过期时间\n\t\t\tif (expire) {\n\t\t\t\tif (isNaN(expire) || expire < 1) {\n\t\t\t\t\tthrow new Error(\"有效期应为一个有效数值\");\n\t\t\t\t}\n\t\t\t\t// 设置过期时间的缓存\n\t\t\t\tconst expireData = {\n\t\t\t\t\ttime: Date.now(),\n\t\t\t\t\texpire,\n\t\t\t\t};\n\t\t\t\tconst expireJson = JSON.stringify(expireData);\n\t\t\t\twindow.sessionStorage.setItem(`${CACHE_PREFIX}${key}${CACHE_EXPIRE_SUFFIX}`, expireJson);\n\t\t\t}\n\t\t\tlet valJson = JSON.stringify(val);\n\t\t\tif (encrypt) {\n\t\t\t\tvalJson = base64Util.toBase64(valJson);\n\t\t\t}\n\t\t\twindow.sessionStorage.setItem(`${CACHE_PREFIX}${key}`, valJson);\n\t\t} catch (error) {\n\t\t\tconsoleError(\"Session\", error);\n\t\t}\n\t},\n\t/**\n\t * 获取会话缓存\n\t * @param key 缓存的Key\n\t * @param decrypt 是否对缓存的数据解密\n\t * @returns {T} 传入的对象类型,默认为 string\n\t */\n\tget<T = string>(key: string, decrypt?: boolean): T {\n\t\ttry {\n\t\t\tdecrypt ??= fastOptions.storageCrypto;\n\t\t\t// 获取缓存 JSON 字符串\n\t\t\tlet valJson = window.sessionStorage.getItem(`${CACHE_PREFIX}${key}`);\n\t\t\tif (valJson) {\n\t\t\t\t// 判断是否解密\n\t\t\t\tif (decrypt) {\n\t\t\t\t\tvalJson = base64Util.base64ToStr(valJson);\n\t\t\t\t}\n\t\t\t\t// 尝试获取缓存过期时间的 JSON 字符串\n\t\t\t\tconst expireJson = window.sessionStorage.getItem(`${CACHE_PREFIX}${key}${CACHE_EXPIRE_SUFFIX}`);\n\t\t\t\t// 判断是否存在过期时间\n\t\t\t\tif (expireJson) {\n\t\t\t\t\tconst expireData = JSON.parse(expireJson) as anyObj;\n\t\t\t\t\tif (Date.now() > expireData.time + expireData.expire * 60 * 1000) {\n\t\t\t\t\t\t// 过期了,删除对应的缓存数据\n\t\t\t\t\t\twindow.sessionStorage.removeItem(`${CACHE_PREFIX}${key}`);\n\t\t\t\t\t\twindow.sessionStorage.removeItem(`${CACHE_PREFIX}${key}${CACHE_EXPIRE_SUFFIX}`);\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\treturn JSON.parse(valJson) as T;\n\t\t\t\t} catch {\n\t\t\t\t\treturn valJson as T;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t} catch (error) {\n\t\t\tconsoleError(\"Session\", error);\n\t\t}\n\t},\n\t/**\n\t * 移除会话缓存\n\t * @param key 缓存的Key\n\t */\n\tremove(key: string): void {\n\t\ttry {\n\t\t\twindow.sessionStorage.removeItem(`${CACHE_PREFIX}${key}`);\n\t\t\twindow.sessionStorage.removeItem(`${CACHE_PREFIX}${key}${CACHE_EXPIRE_SUFFIX}`);\n\t\t} catch (error) {\n\t\t\tconsoleError(\"Session\", error);\n\t\t}\n\t},\n\t/**\n\t * 根据前缀移除会话缓存\n\t * @param key 缓存的Key\n\t */\n\tremoveByPrefix(key: string): void {\n\t\ttry {\n\t\t\tfor (const itemKey in window.sessionStorage) {\n\t\t\t\tif (itemKey.indexOf(`${CACHE_PREFIX}${key}`) !== -1) {\n\t\t\t\t\twindow.sessionStorage.removeItem(itemKey);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsoleError(\"Session\", error);\n\t\t}\n\t},\n\t/**\n\t * 移除全部会话缓存\n\t */\n\tclear(): void {\n\t\ttry {\n\t\t\tw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AAAA,EAKA,OAAO,KAAmB;AACrB,QAAA;AACH,aAAO,eAAe,WAAW,GAAG,YAAY,GAAG,GAAG,EAAE;AACjD,aAAA,eAAe,WAAW,GAAG,YAAY,GAAG,GAAG,GAAG,mBAAmB,EAAE;AAAA,aACtE,OAAO;AACf,mBAAa,WAAW,KAAK;AAAA,IAC9B;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA,eAAe,KAAmB;AAC7B,QAAA;AACQ,iBAAA,WAAW,OAAO,gBAAgB;AACxC,YAAA,QAAQ,QAAQ,GAAG,YAAY,GAAG,GAAG,EAAE,MAAM,IAAI;AAC7C,iBAAA,eAAe,WAAW,OAAO;AAAA,QACzC;AAAA,MACD;AAAA,aACQ,OAAO;AACf,mBAAa,WAAW,KAAK;AAAA,IAC9B;AAAA,EACD;AAAA;AAAA;AAAA;AAAA,EAIA,QAAc;AACT,QAAA;AACH,aAAO,eAAe;aACd,OAAO;AACf,mBAAa,WAAW,KAAK;AAAA,IAC9B;AAAA,EACD;AACD;"}
|
package/es/utils/string.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 字符串工具类
|
|
3
|
-
*/
|
|
4
|
-
export declare const stringUtil: {
|
|
5
|
-
/**
|
|
6
|
-
* 根据当前时间生成问候语
|
|
7
|
-
*/
|
|
8
|
-
getGreet(): string;
|
|
9
|
-
/**
|
|
10
|
-
* 对象URL参数化
|
|
11
|
-
*/
|
|
12
|
-
objectToQueryString(obj: any): string;
|
|
13
|
-
/**
|
|
14
|
-
* 获取Url参数
|
|
15
|
-
*/
|
|
16
|
-
getUrlParams(url: string): Record<string, any>;
|
|
17
|
-
/**
|
|
18
|
-
* 是否为JSON字符串
|
|
19
|
-
*/
|
|
20
|
-
isJson(value: string): boolean;
|
|
21
|
-
/**
|
|
22
|
-
* 生成随机字符串
|
|
23
|
-
*/
|
|
24
|
-
generateRandomString(length: number): string;
|
|
25
|
-
/**
|
|
26
|
-
* @description 生成唯一 uuid
|
|
27
|
-
*/
|
|
28
|
-
generateUUID(): string;
|
|
29
|
-
/**
|
|
30
|
-
* 复制
|
|
31
|
-
*/
|
|
32
|
-
copy(value: string): Promise<void>;
|
|
33
|
-
};
|
package/es/utils/string.mjs
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { isString } from "lodash-es";
|
|
2
|
-
const stringUtil = {
|
|
3
|
-
/**
|
|
4
|
-
* 根据当前时间生成问候语
|
|
5
|
-
*/
|
|
6
|
-
getGreet() {
|
|
7
|
-
const now = /* @__PURE__ */ new Date();
|
|
8
|
-
const hour = now.getHours();
|
|
9
|
-
let greet = "";
|
|
10
|
-
if (hour < 5) {
|
|
11
|
-
greet = "夜深了,注意身体哦!";
|
|
12
|
-
} else if (hour < 9) {
|
|
13
|
-
greet = "早上好!欢迎回来!";
|
|
14
|
-
} else if (hour < 12) {
|
|
15
|
-
greet = "上午好!欢迎回来!";
|
|
16
|
-
} else if (hour < 14) {
|
|
17
|
-
greet = "中午好!欢迎回来!";
|
|
18
|
-
} else if (hour < 18) {
|
|
19
|
-
greet = "下午好!欢迎回来!";
|
|
20
|
-
} else if (hour < 24) {
|
|
21
|
-
greet = "晚上好!欢迎回来!";
|
|
22
|
-
} else {
|
|
23
|
-
greet = "您好!欢迎回来!";
|
|
24
|
-
}
|
|
25
|
-
return greet;
|
|
26
|
-
},
|
|
27
|
-
/**
|
|
28
|
-
* 对象URL参数化
|
|
29
|
-
*/
|
|
30
|
-
objectToQueryString(obj) {
|
|
31
|
-
let params = "";
|
|
32
|
-
for (const key in obj) {
|
|
33
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
34
|
-
if (params !== "") {
|
|
35
|
-
params += "&";
|
|
36
|
-
}
|
|
37
|
-
params += `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return params;
|
|
41
|
-
},
|
|
42
|
-
/**
|
|
43
|
-
* 获取Url参数
|
|
44
|
-
*/
|
|
45
|
-
getUrlParams(url) {
|
|
46
|
-
const regex = /[?&][^=?&]+=[^?&]+/g;
|
|
47
|
-
const params = {};
|
|
48
|
-
let match;
|
|
49
|
-
while ((match = regex.exec(url)) !== null) {
|
|
50
|
-
const [key, value] = match[0].substring(1).split("=");
|
|
51
|
-
params[key] = decodeURIComponent(value);
|
|
52
|
-
}
|
|
53
|
-
return params;
|
|
54
|
-
},
|
|
55
|
-
/**
|
|
56
|
-
* 是否为JSON字符串
|
|
57
|
-
*/
|
|
58
|
-
isJson(value) {
|
|
59
|
-
if (!isString(value)) return false;
|
|
60
|
-
value = value.replace(/\s/g, "").replace(/\n|\r/, "");
|
|
61
|
-
if (/^\{(.*?)\}$/.test(value)) return /"(.*?)":(.*?)/g.test(value);
|
|
62
|
-
if (/^\[(.*?)\]$/.test(value)) {
|
|
63
|
-
return value.replace(/^\[/, "").replace(/\]$/, "").replace(/},{/g, "}\n{").split(/\n/).map((s) => {
|
|
64
|
-
return stringUtil.isJson(s);
|
|
65
|
-
}).reduce((prev, curr) => {
|
|
66
|
-
return !!curr;
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
return false;
|
|
70
|
-
},
|
|
71
|
-
/**
|
|
72
|
-
* 生成随机字符串
|
|
73
|
-
*/
|
|
74
|
-
generateRandomString(length) {
|
|
75
|
-
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
76
|
-
let randomString = "";
|
|
77
|
-
for (let i = 0; i < length; i++) {
|
|
78
|
-
const randomIndex = Math.floor(Math.random() * characters.length);
|
|
79
|
-
randomString += characters.charAt(randomIndex);
|
|
80
|
-
}
|
|
81
|
-
return randomString;
|
|
82
|
-
},
|
|
83
|
-
/**
|
|
84
|
-
* @description 生成唯一 uuid
|
|
85
|
-
*/
|
|
86
|
-
generateUUID() {
|
|
87
|
-
let uuid = "";
|
|
88
|
-
for (let i = 0; i < 32; i++) {
|
|
89
|
-
const random = Math.random() * 16 | 0;
|
|
90
|
-
if (i === 8 || i === 12 || i === 16 || i === 20) uuid += "-";
|
|
91
|
-
uuid += (i === 12 ? 4 : i === 16 ? random & 3 | 8 : random).toString(16);
|
|
92
|
-
}
|
|
93
|
-
return uuid;
|
|
94
|
-
},
|
|
95
|
-
/**
|
|
96
|
-
* 复制
|
|
97
|
-
*/
|
|
98
|
-
async copy(value) {
|
|
99
|
-
if ((navigator == null ? void 0 : navigator.clipboard) && window.isSecureContext) {
|
|
100
|
-
await navigator.clipboard.writeText(value);
|
|
101
|
-
} else {
|
|
102
|
-
const textareaEl = document.createElement("textarea");
|
|
103
|
-
textareaEl.value = value;
|
|
104
|
-
textareaEl.style.position = "absolute";
|
|
105
|
-
textareaEl.style.opacity = "0";
|
|
106
|
-
textareaEl.style.left = "-999999px";
|
|
107
|
-
textareaEl.style.top = "-999999px";
|
|
108
|
-
document.body.appendChild(textareaEl);
|
|
109
|
-
textareaEl.focus();
|
|
110
|
-
textareaEl.select();
|
|
111
|
-
document.execCommand("copy");
|
|
112
|
-
textareaEl.remove();
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
export {
|
|
117
|
-
stringUtil
|
|
118
|
-
};
|
|
119
|
-
//# sourceMappingURL=string.mjs.map
|
package/es/utils/string.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"string.mjs","sources":["../../../packages/utils/string.ts"],"sourcesContent":["import { isString } from \"lodash-es\";\n\n/**\n * 字符串工具类\n */\nexport const stringUtil = {\n\t/**\n\t * 根据当前时间生成问候语\n\t */\n\tgetGreet(): string {\n\t\tconst now = new Date();\n\t\tconst hour = now.getHours();\n\t\tlet greet = \"\";\n\n\t\tif (hour < 5) {\n\t\t\tgreet = \"夜深了,注意身体哦!\";\n\t\t} else if (hour < 9) {\n\t\t\tgreet = \"早上好!\" + \"欢迎回来!\";\n\t\t} else if (hour < 12) {\n\t\t\tgreet = \"上午好!\" + \"欢迎回来!\";\n\t\t} else if (hour < 14) {\n\t\t\tgreet = \"中午好!\" + \"欢迎回来!\";\n\t\t} else if (hour < 18) {\n\t\t\tgreet = \"下午好!\" + \"欢迎回来!\";\n\t\t} else if (hour < 24) {\n\t\t\tgreet = \"晚上好!\" + \"欢迎回来!\";\n\t\t} else {\n\t\t\tgreet = \"您好!\" + \"欢迎回来!\";\n\t\t}\n\t\treturn greet;\n\t},\n\t/**\n\t * 对象URL参数化\n\t */\n\tobjectToQueryString(obj: any): string {\n\t\tlet params = \"\";\n\t\tfor (const key in obj) {\n\t\t\tif (Object.prototype.hasOwnProperty.call(obj, key)) {\n\t\t\t\tif (params !== \"\") {\n\t\t\t\t\tparams += \"&\";\n\t\t\t\t}\n\t\t\t\tparams += `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`;\n\t\t\t}\n\t\t}\n\t\treturn params;\n\t},\n\t/**\n\t * 获取Url参数\n\t */\n\tgetUrlParams(url: string): Record<string, any> {\n\t\tconst regex = /[?&][^=?&]+=[^?&]+/g;\n\t\tconst params: Record<string, any> = {};\n\n\t\tlet match;\n\t\twhile ((match = regex.exec(url)) !== null) {\n\t\t\tconst [key, value] = match[0].substring(1).split(\"=\");\n\t\t\tparams[key] = decodeURIComponent(value);\n\t\t}\n\n\t\treturn params;\n\t},\n\t/**\n\t * 是否为JSON字符串\n\t */\n\tisJson(value: string): boolean {\n\t\tif (!isString(value)) return false;\n\n\t\tvalue = value.replace(/\\s/g, \"\").replace(/\\n|\\r/, \"\");\n\n\t\tif (/^\\{(.*?)\\}$/.test(value)) return /\"(.*?)\":(.*?)/g.test(value);\n\n\t\tif (/^\\[(.*?)\\]$/.test(value)) {\n\t\t\treturn value\n\t\t\t\t.replace(/^\\[/, \"\")\n\t\t\t\t.replace(/\\]$/, \"\")\n\t\t\t\t.replace(/},{/g, \"}\\n{\")\n\t\t\t\t.split(/\\n/)\n\t\t\t\t.map((s) => {\n\t\t\t\t\treturn stringUtil.isJson(s);\n\t\t\t\t})\n\t\t\t\t.reduce((prev, curr) => {\n\t\t\t\t\treturn !!curr;\n\t\t\t\t});\n\t\t}\n\n\t\treturn false;\n\t},\n\t/**\n\t * 生成随机字符串\n\t */\n\tgenerateRandomString(length: number): string {\n\t\tconst characters = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";\n\t\tlet randomString = \"\";\n\t\tfor (let i = 0; i < length; i++) {\n\t\t\tconst randomIndex = Math.floor(Math.random() * characters.length);\n\t\t\trandomString += characters.charAt(randomIndex);\n\t\t}\n\t\treturn randomString;\n\t},\n\t/**\n\t * @description 生成唯一 uuid\n\t */\n\tgenerateUUID(): string {\n\t\tlet uuid = \"\";\n\t\tfor (let i = 0; i < 32; i++) {\n\t\t\tconst random = (Math.random() * 16) | 0;\n\t\t\tif (i === 8 || i === 12 || i === 16 || i === 20) uuid += \"-\";\n\t\t\tuuid += (i === 12 ? 4 : i === 16 ? (random & 3) | 8 : random).toString(16);\n\t\t}\n\t\treturn uuid;\n\t},\n\t/**\n\t * 复制\n\t */\n\tasync copy(value: string): Promise<void> {\n\t\t// navigator.clipboard 需要https等安全上下文\n\t\tif (navigator?.clipboard && window.isSecureContext) {\n\t\t\tawait navigator.clipboard.writeText(value);\n\t\t} else {\n\t\t\tconst textareaEl = document.createElement(\"textarea\");\n\t\t\ttextareaEl.value = value;\n\t\t\t// 使文本域不显示\n\t\t\ttextareaEl.style.position = \"absolute\";\n\t\t\ttextareaEl.style.opacity = \"0\";\n\t\t\ttextareaEl.style.left = \"-999999px\";\n\t\t\ttextareaEl.style.top = \"-999999px\";\n\t\t\tdocument.body.appendChild(textareaEl);\n\t\t\ttextareaEl.focus();\n\t\t\ttextareaEl.select();\n\t\t\tdocument.execCommand(\"copy\");\n\t\t\ttextareaEl.remove();\n\t\t}\n\t},\n};\n"],"names":[],"mappings":";AAKO,MAAM,aAAa;AAAA;AAAA;AAAA;AAAA,EAIzB,WAAmB;AACZ,U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AAM;AAC3B,iBAAW,OAAO;AAAA,IACnB;AAAA,EACD;AACD;"}
|
package/es/utils/vue/func.d.ts
DELETED
package/es/utils/vue/func.mjs
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import "../index.mjs";
|
|
2
|
-
import { consoleError } from "../console.mjs";
|
|
3
|
-
const execAsyncFunction = (fn, ...args) => {
|
|
4
|
-
if (!fn) return Promise.resolve(void 0);
|
|
5
|
-
if (fn.constructor.name !== "AsyncFunction") {
|
|
6
|
-
consoleError("execAsyncFunction", "必须为 Promise 异步方法");
|
|
7
|
-
throw new Error("必须为 Promise 异步方法");
|
|
8
|
-
}
|
|
9
|
-
return fn(...args).then((res) => res).catch((error) => {
|
|
10
|
-
consoleError("execAsyncFunction", error);
|
|
11
|
-
return Promise.reject(error);
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
export {
|
|
15
|
-
execAsyncFunction
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=func.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"func.mjs","sources":["../../../../packages/utils/vue/func.ts"],"sourcesContent":["/**\n * 执行异步方法\n * @param fn 要执行的异步方法\n * @param args 参数\n */\n\nimport { consoleError } from \"@fast-element-plus/utils\";\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nconst execAsyncFunction = <T = void>(fn: Function, ...args: any[]): Promise<T> => {\n\tif (!fn) return Promise.resolve(undefined);\n\tif (fn.constructor.name !== \"AsyncFunction\") {\n\t\tconsoleError(\"execAsyncFunction\", \"必须为 Promise 异步方法\");\n\t\tthrow new Error(\"必须为 Promise 异步方法\");\n\t}\n\treturn fn(...args)\n\t\t.then((res) => res)\n\t\t.catch((error) => {\n\t\t\tconsoleError(\"execAsyncFunction\", error);\n\t\t\treturn Promise.reject(error);\n\t\t});\n};\n\nexport { execAsyncFunction };\n"],"names":[],"mappings":";;AASM,MAAA,oBAAoB,CAAW,OAAiB,SAA4B;AACjF,MAAI,CAAC,GAAW,QAAA,QAAQ,QAAQ,MAAS;AACrC,MAAA,GAAG,YAAY,SAAS,iBAAiB;AAC5C,iBAAa,qBAAqB,kBAAkB;AAC9C,UAAA,IAAI,MAAM,kBAAkB;AAAA,EACnC;AACO,SAAA,GAAG,GAAG,IAAI,EACf,KAAK,CAAC,QAAQ,GAAG,EACjB,MAAM,CAAC,UAAU;AACjB,iBAAa,qBAAqB,KAAK;AAChC,WAAA,QAAQ,OAAO,KAAK;AAAA,EAAA,CAC3B;AACH;"}
|
package/es/utils/vue/index.d.ts
DELETED
package/es/utils/vue/index.mjs
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { execAsyncFunction } from "./func.mjs";
|
|
2
|
-
import { withInstall, withInstallDirective, withNoopInstall } from "./install.mjs";
|
|
3
|
-
import { useProps } from "./props.mjs";
|
|
4
|
-
import { makeSlots } from "./slots.mjs";
|
|
5
|
-
import { useRender } from "./useRender.mjs";
|
|
6
|
-
import { withDefineType } from "./with.mjs";
|
|
7
|
-
export {
|
|
8
|
-
execAsyncFunction,
|
|
9
|
-
makeSlots,
|
|
10
|
-
useProps,
|
|
11
|
-
useRender,
|
|
12
|
-
withDefineType,
|
|
13
|
-
withInstall,
|
|
14
|
-
withInstallDirective,
|
|
15
|
-
withNoopInstall
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { Directive, Plugin } from 'vue';
|
|
2
|
-
export type TSXWithInstall<T> = T & Plugin;
|
|
3
|
-
export declare const withInstall: <T, E extends Record<string, any>>(main: T, extra?: E) => TSXWithInstall<T> & E;
|
|
4
|
-
export declare const withNoopInstall: <T>(component: T) => TSXWithInstall<T>;
|
|
5
|
-
export declare const withInstallDirective: <T extends Directive>(directive: T, name: string) => TSXWithInstall<T>;
|
package/es/utils/vue/install.mjs
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const NOOP = () => {
|
|
2
|
-
};
|
|
3
|
-
const withInstall = (main, extra) => {
|
|
4
|
-
main.install = (app) => {
|
|
5
|
-
for (const comp of [main, ...Object.values(extra ?? {})]) {
|
|
6
|
-
app.component(comp.name, comp);
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
if (extra) {
|
|
10
|
-
for (const [key, comp] of Object.entries(extra)) {
|
|
11
|
-
main[key] = comp;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return main;
|
|
15
|
-
};
|
|
16
|
-
const withNoopInstall = (component) => {
|
|
17
|
-
component.install = NOOP;
|
|
18
|
-
return component;
|
|
19
|
-
};
|
|
20
|
-
const withInstallDirective = (directive, name) => {
|
|
21
|
-
directive.install = (app) => {
|
|
22
|
-
app.directive(name, directive);
|
|
23
|
-
};
|
|
24
|
-
return directive;
|
|
25
|
-
};
|
|
26
|
-
export {
|
|
27
|
-
withInstall,
|
|
28
|
-
withInstallDirective,
|
|
29
|
-
withNoopInstall
|
|
30
|
-
};
|
|
31
|
-
//# sourceMappingURL=install.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"install.mjs","sources":["../../../../packages/utils/vue/install.ts"],"sourcesContent":["import type { App, Directive, Plugin } from \"vue\";\n\nexport type TSXWithInstall<T> = T & Plugin;\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nconst NOOP = (): void => {};\n\nexport const withInstall = <T, E extends Record<string, any>>(main: T, extra?: E): TSXWithInstall<T> & E => {\n\t(main as TSXWithInstall<T>).install = (app): void => {\n\t\tfor (const comp of [main, ...Object.values(extra ?? {})]) {\n\t\t\tapp.component(comp.name, comp);\n\t\t}\n\t};\n\n\tif (extra) {\n\t\tfor (const [key, comp] of Object.entries(extra)) {\n\t\t\t(main as any)[key] = comp;\n\t\t}\n\t}\n\treturn main as TSXWithInstall<T> & E;\n};\n\nexport const withNoopInstall = <T>(component: T): TSXWithInstall<T> => {\n\t(component as TSXWithInstall<T>).install = NOOP;\n\n\treturn component as TSXWithInstall<T>;\n};\n\nexport const withInstallDirective = <T extends Directive>(directive: T, name: string): TSXWithInstall<T> => {\n\t(directive as TSXWithInstall<T>).install = (app: App): void => {\n\t\tapp.directive(name, directive);\n\t};\n\n\treturn directive as TSXWithInstall<T>;\n};\n"],"names":[],"mappings":"AAKA,MAAM,OAAO,MAAY;AAAC;AAEb,MAAA,cAAc,CAAmC,MAAS,UAAqC;AAC1G,OAA2B,UAAU,CAAC,QAAc;AACzC,eAAA,QAAQ,CAAC,MAAM,GAAG,OAAO,OAAO,SAAS,CAAE,CAAA,CAAC,GAAG;AACrD,UAAA,UAAU,KAAK,MAAM,IAAI;AAAA,IAC9B;AAAA,EAAA;AAGD,MAAI,OAAO;AACV,eAAW,CAAC,KAAK,IAAI,KAAK,OAAO,QAAQ,KAAK,GAAG;AAC/C,WAAa,GAAG,IAAI;AAAA,IACtB;AAAA,EACD;AACO,SAAA;AACR;AAEa,MAAA,kBAAkB,CAAI,cAAoC;AACrE,YAAgC,UAAU;AAEpC,SAAA;AACR;AAEa,MAAA,uBAAuB,CAAsB,WAAc,SAAoC;AAC1G,YAAgC,UAAU,CAAC,QAAmB;AAC1D,QAAA,UAAU,MAAM,SAAS;AAAA,EAAA;AAGvB,SAAA;AACR;"}
|
package/es/utils/vue/props.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ComputedRef } from 'vue';
|
|
2
|
-
/**
|
|
3
|
-
* 构建 props
|
|
4
|
-
* @param props props
|
|
5
|
-
* @param rawProps 原生 props
|
|
6
|
-
* @param ignoreRawProps 忽略 原生 props 的 key
|
|
7
|
-
* @param mergeProps 合并的 props,固定的值,即使在外部props中传入了也没用
|
|
8
|
-
*/
|
|
9
|
-
declare const useProps: <T extends Record<string, unknown>, RT extends Record<string, unknown>>(props: T, rawProps?: RT, ignoreRawProps?: (keyof RT)[], mergeProps?: Partial<Record<keyof RT, unknown>>) => ComputedRef<Record<string, unknown>>;
|
|
10
|
-
export { useProps };
|
package/es/utils/vue/props.mjs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { computed } from "vue";
|
|
2
|
-
import { omit, pick } from "lodash-es";
|
|
3
|
-
const useProps = (props, rawProps, ignoreRawProps, mergeProps) => {
|
|
4
|
-
if (!props) return computed(() => ({}));
|
|
5
|
-
return computed(() => {
|
|
6
|
-
const omittedRawProps = rawProps ? omit(rawProps, ignoreRawProps ?? []) : {};
|
|
7
|
-
const pickedProps = pick(props, Object.keys(omittedRawProps));
|
|
8
|
-
return { ...pickedProps, ...mergeProps ?? {} };
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
export {
|
|
12
|
-
useProps
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=props.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"props.mjs","sources":["../../../../packages/utils/vue/props.ts"],"sourcesContent":["import type { ComputedRef } from \"vue\";\nimport { computed } from \"vue\";\nimport { omit, pick } from \"lodash-es\";\n\n/**\n * 构建 props\n * @param props props\n * @param rawProps 原生 props\n * @param ignoreRawProps 忽略 原生 props 的 key\n * @param mergeProps 合并的 props,固定的值,即使在外部props中传入了也没用\n */\nconst useProps = <T extends Record<string, unknown>, RT extends Record<string, unknown>>(\n\tprops: T,\n\trawProps?: RT,\n\tignoreRawProps?: (keyof RT)[],\n\tmergeProps?: Partial<Record<keyof RT, unknown>>\n): ComputedRef<Record<string, unknown>> => {\n\tif (!props) return computed(() => ({}));\n\n\treturn computed<Record<string, unknown>>(() => {\n\t\tconst omittedRawProps = rawProps ? omit(rawProps, ignoreRawProps ?? []) : {};\n\t\tconst pickedProps = pick(props, Object.keys(omittedRawProps)) as Record<string, unknown>;\n\t\treturn { ...pickedProps, ...(mergeProps ?? {}) };\n\t});\n};\n\nexport { useProps };\n"],"names":[],"mappings":";;AAWA,MAAM,WAAW,CAChB,OACA,UACA,gBACA,eAC0C;AAC1C,MAAI,CAAC,MAAO,QAAO,SAAS,OAAO,CAAA,EAAG;AAEtC,SAAO,SAAkC,MAAM;AACxC,UAAA,kBAAkB,WAAW,KAAK,UAAU,kBAAkB,CAAA,CAAE,IAAI;AAC1E,UAAM,cAAc,KAAK,OAAO,OAAO,KAAK,eAAe,CAAC;AAC5D,WAAO,EAAE,GAAG,aAAa,GAAI,cAAc,CAAI,EAAA;AAAA,EAAA,CAC/C;AACF;"}
|
package/es/utils/vue/slots.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { SlotsType, VNode } from 'vue';
|
|
2
|
-
type RawSlots = Record<string, unknown>;
|
|
3
|
-
type VueSlots<T> = [T] extends [never] ? () => VNode[] : (arg: T) => VNode[];
|
|
4
|
-
type MakeSlots<T extends RawSlots> = {
|
|
5
|
-
[K in keyof T]: VueSlots<T[K]>;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* 构建 slots
|
|
9
|
-
*/
|
|
10
|
-
declare const makeSlots: <Slots extends RawSlots>() => SlotsType<Partial<MakeSlots<Slots>>>;
|
|
11
|
-
export { makeSlots };
|
package/es/utils/vue/slots.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"slots.mjs","sources":["../../../../packages/utils/vue/slots.ts"],"sourcesContent":["import type { SlotsType, VNode } from \"vue\";\n\ntype RawSlots = Record<string, unknown>;\n\ntype VueSlots<T> = [T] extends [never] ? () => VNode[] : (arg: T) => VNode[];\n\ntype MakeSlots<T extends RawSlots> = {\n\t[K in keyof T]: VueSlots<T[K]>;\n};\n\n/**\n * 构建 slots\n */\nconst makeSlots = <Slots extends RawSlots>(): SlotsType<Partial<MakeSlots<Slots>>> => {\n\treturn Object as SlotsType<Partial<MakeSlots<Slots>>>;\n};\n\nexport { makeSlots };\n"],"names":[],"mappings":"AAaA,MAAM,YAAY,MAAoE;AAC9E,SAAA;AACR;"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { getCurrentInstance } from "vue";
|
|
2
|
-
const useRender = (render) => {
|
|
3
|
-
const vm = getCurrentInstance();
|
|
4
|
-
if (!vm) {
|
|
5
|
-
throw new Error("useRender must be called from inside a setup function");
|
|
6
|
-
}
|
|
7
|
-
vm.render = render;
|
|
8
|
-
};
|
|
9
|
-
export {
|
|
10
|
-
useRender
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=useRender.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useRender.mjs","sources":["../../../../packages/utils/vue/useRender.ts"],"sourcesContent":["import type { VNode } from \"vue\";\nimport { getCurrentInstance } from \"vue\";\n\n/**\n * 使用渲染\n * @description 为了解决使用 TSX 语法返回渲染函数,状态不会出现在 vue.js devtools 中\n */\nconst useRender = (render: () => VNode): void => {\n\tconst vm = getCurrentInstance() as any;\n\tif (!vm) {\n\t\tthrow new Error(\"useRender must be called from inside a setup function\");\n\t}\n\tvm.render = render;\n};\n\nexport { useRender };\n"],"names":[],"mappings":";AAOM,MAAA,YAAY,CAAC,WAA8B;AAChD,QAAM,KAAK;AACX,MAAI,CAAC,IAAI;AACF,UAAA,IAAI,MAAM,uDAAuD;AAAA,EACxE;AACA,KAAG,SAAS;AACb;"}
|
package/es/utils/vue/with.d.ts
DELETED
package/es/utils/vue/with.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"with.mjs","sources":["../../../../packages/utils/vue/with.ts"],"sourcesContent":["/**\n * 定义类型数据\n * @description 传入什么就返回什么,用来定义reactive或其他对象的响应式数据\n */\nconst withDefineType = <T>(data: T): T => {\n\treturn data;\n};\n\nexport { withDefineType };\n"],"names":[],"mappings":"AAIM,MAAA,iBAAiB,CAAI,SAAe;AAClC,SAAA;AACR;"}
|
package/global.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { ExtractPropTypes } from 'vue';
|
|
2
|
-
import { faIconProps, default as Icon } from './src/icon';
|
|
3
|
-
export declare const FaIcon: import('../../utils').TSXWithInstall<import('vue').DefineComponent<ExtractPropTypes<{
|
|
4
|
-
name: {
|
|
5
|
-
type: StringConstructor;
|
|
6
|
-
required: boolean;
|
|
7
|
-
};
|
|
8
|
-
size: import('vue').PropType<number | string>;
|
|
9
|
-
color: StringConstructor;
|
|
10
|
-
}>, void, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<ExtractPropTypes<{
|
|
11
|
-
name: {
|
|
12
|
-
type: StringConstructor;
|
|
13
|
-
required: boolean;
|
|
14
|
-
};
|
|
15
|
-
size: import('vue').PropType<number | string>;
|
|
16
|
-
color: StringConstructor;
|
|
17
|
-
}>> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>> & Record<string, any>;
|
|
18
|
-
export default FaIcon;
|
|
19
|
-
export type GIconInstance = InstanceType<typeof Icon>;
|
|
20
|
-
export type GIconProps = ExtractPropTypes<typeof faIconProps>;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),require("../../utils/index.js");const e=require("./src/icon.js"),t=require("../../utils/vue/install.js").withInstall(e.default);exports.FaIcon=t,exports.default=t;
|
|
2
|
-
//# sourceMappingURL=index.js.map
|