wui-components-v2 1.0.13 → 1.0.14
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/api/core/index.ts +74 -0
- package/api/index.ts +2 -13
- package/api/login.ts +51 -0
- package/api/menu.ts +7 -0
- package/components/demo-block/demo-block.vue +66 -0
- package/components/global-loading/GlobalLoading.md +366 -0
- package/components/global-loading/global-loading.vue +55 -0
- package/components/global-message/GlobalMessage.md +570 -0
- package/components/global-message/global-message.vue +64 -0
- package/components/global-toast/GlobalToast.md +261 -0
- package/components/global-toast/global-toast.vue +56 -0
- package/components/login/login.vue +22 -0
- package/components/login-form/login-form.vue +106 -0
- package/components/menus/menus.vue +180 -0
- package/components/privacy-popup/privacy-popup.vue +178 -0
- package/components/{system-settings.vue → system-settings/system-settings.vue} +3 -2
- package/composables/types/user.ts +5 -0
- package/composables/useGlobalLoading.ts +46 -0
- package/composables/useGlobalMessage.ts +54 -0
- package/composables/useGlobalToast.ts +62 -0
- package/composables/useTheme.ts +1 -1
- package/composables/useUser.ts +21 -0
- package/index.ts +3 -2
- package/package.json +6 -1
- package/store/userStore.ts +22 -0
- package/utils/index.ts +9 -0
- package/utils/rsaEncrypt.ts +10 -0
- package/api/core/handlers.ts +0 -106
- package/api/core/instance.ts +0 -60
- package/api/core/middleware.ts +0 -92
package/api/core/middleware.ts
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 延迟加载中间件
|
|
3
|
-
* 延迟显示加载状态,防止快速请求导致的闪烁
|
|
4
|
-
* @param delay 显示加载状态前的延迟时间(毫秒)
|
|
5
|
-
* @returns Alova 中间件
|
|
6
|
-
*/
|
|
7
|
-
export function createDelayLoadingMiddleware(delay = 300) {
|
|
8
|
-
return async (context: any, next: any) => {
|
|
9
|
-
context.controlLoading()
|
|
10
|
-
|
|
11
|
-
const { loading } = context.proxyStates
|
|
12
|
-
|
|
13
|
-
const timer = setTimeout(() => {
|
|
14
|
-
loading.v = true
|
|
15
|
-
}, delay)
|
|
16
|
-
|
|
17
|
-
await next()
|
|
18
|
-
|
|
19
|
-
loading.v = false
|
|
20
|
-
clearTimeout(timer)
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* 全局加载中间件
|
|
26
|
-
* 为所有请求显示全局加载指示器,支持延迟显示
|
|
27
|
-
*
|
|
28
|
-
* 使用示例:
|
|
29
|
-
* ```typescript
|
|
30
|
-
* // 1. 基本用法
|
|
31
|
-
* const { send: submit } = useRequest(method, {
|
|
32
|
-
* middleware: createGlobalLoadingMiddleware()
|
|
33
|
-
* });
|
|
34
|
-
*
|
|
35
|
-
* // 2. 自定义延迟时间和加载文本
|
|
36
|
-
* const { send: submit } = useRequest(method, {
|
|
37
|
-
* middleware: createGlobalLoadingMiddleware({
|
|
38
|
-
* delay: 500, // 延迟 500ms 显示加载指示器,防止闪烁
|
|
39
|
-
* loadingText: '正在提交...', // 自定义加载文本
|
|
40
|
-
* })
|
|
41
|
-
* });
|
|
42
|
-
* ```
|
|
43
|
-
*
|
|
44
|
-
* @param options 加载选项
|
|
45
|
-
* @param options.delay 显示加载指示器前的延迟时间(毫秒),默认 300ms
|
|
46
|
-
* @param options.loadingText 加载指示器显示的文本,默认为 'Loading...'
|
|
47
|
-
* @returns Alova 中间件
|
|
48
|
-
*/
|
|
49
|
-
export function createGlobalLoadingMiddleware(options: {
|
|
50
|
-
delay?: number
|
|
51
|
-
loadingText?: string
|
|
52
|
-
} = {}) {
|
|
53
|
-
const {
|
|
54
|
-
delay = 0,
|
|
55
|
-
loadingText = 'Loading...',
|
|
56
|
-
} = options
|
|
57
|
-
|
|
58
|
-
return async (ctx: any, next: any) => {
|
|
59
|
-
// 自行控制loading
|
|
60
|
-
ctx.controlLoading()
|
|
61
|
-
|
|
62
|
-
const globalLoading = useGlobalLoading()
|
|
63
|
-
let timer: ReturnType<typeof setTimeout> | null = null
|
|
64
|
-
|
|
65
|
-
// 如果delay为0或未设置,直接显示loading
|
|
66
|
-
if (delay <= 0) {
|
|
67
|
-
globalLoading.loading(loadingText)
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
// 延迟特定时间显示全局loading
|
|
71
|
-
timer = setTimeout(() => {
|
|
72
|
-
globalLoading.loading(loadingText)
|
|
73
|
-
}, delay)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
try {
|
|
77
|
-
await next()
|
|
78
|
-
}
|
|
79
|
-
finally {
|
|
80
|
-
// 清除定时器并关闭loading
|
|
81
|
-
if (timer) {
|
|
82
|
-
clearTimeout(timer)
|
|
83
|
-
}
|
|
84
|
-
globalLoading.close()
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// 导出延迟加载中间件作为默认中间件
|
|
90
|
-
export const defaultMiddleware = createDelayLoadingMiddleware()
|
|
91
|
-
|
|
92
|
-
export default defaultMiddleware
|