wui-components-v2 1.1.48 → 1.1.49

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/menu.ts CHANGED
@@ -6,11 +6,35 @@ export function menu() {
6
6
  })
7
7
  }
8
8
 
9
- // 获取配置菜单
9
+ // fastmenu 请求缓存
10
+ let fastmenuPromise: Promise<any> | null = null
11
+ let fastmenuCacheTime = 0
12
+ const CACHE_DURATION = 3000 // 缓存有效期 5 秒
13
+
14
+ // 获取配置菜单(带请求防抖和缓存)
10
15
  export function fastmenu() {
11
- return req({
16
+ const now = Date.now()
17
+
18
+ // 如果请求正在进行中,返回同一个 Promise
19
+ if (fastmenuPromise) {
20
+ return fastmenuPromise
21
+ }
22
+
23
+ // 如果缓存还在有效期内,重新发起请求但仍然共享 Promise
24
+ // (如果需要真正的缓存数据,可以在这里添加数据缓存逻辑)
25
+
26
+ fastmenuPromise = req({
12
27
  url: `/v3/menu/fast-menu`,
28
+ }).finally(() => {
29
+ // 请求完成后,清除 Promise 引用(保持缓存时间窗口)
30
+ setTimeout(() => {
31
+ fastmenuPromise = null
32
+ fastmenuCacheTime = 0
33
+ }, CACHE_DURATION)
13
34
  })
35
+
36
+ fastmenuCacheTime = now
37
+ return fastmenuPromise
14
38
  }
15
39
 
16
40
  // 菜单内容统计
@@ -10,6 +10,12 @@ import { useManualTheme } from '../../composables/useManualTheme'
10
10
  defineOptions({
11
11
  name: 'WuiUser',
12
12
  })
13
+ const props= defineProps({
14
+ loginPath:{
15
+ type: String,
16
+ default: '/pages/login/index',
17
+ }
18
+ })
13
19
  const {
14
20
  currentThemeColor,
15
21
  } = useManualTheme()
@@ -30,7 +36,7 @@ function quit() {
30
36
  .then(() => {
31
37
  uni.removeStorageSync('TOKEN')
32
38
  uni.reLaunch({
33
- url: '/pages/login/index',
39
+ url: props.loginPath,
34
40
  })
35
41
  })
36
42
  .catch(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wui-components-v2",
3
- "version": "1.1.48",
3
+ "version": "1.1.49",
4
4
  "description": "wui 组件库",
5
5
  "author": "wgxshh",
6
6
  "license": "MIT",