xto-fronted 0.4.99 → 0.4.100
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/dist/index-B-lMqzxZ.js +479 -0
- package/dist/index-BJlOXgu5.js +515 -0
- package/dist/index-DgffG7KK.js +641 -0
- package/dist/index-DkOqM4e2.js +3147 -0
- package/dist/index-zKJLxthI.js +189 -0
- package/dist/index.js +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/Layout/Sidebar.vue +23 -3
package/package.json
CHANGED
|
@@ -36,13 +36,32 @@ const displayMenuList = computed(() => props.menuList.length > 0 ? props.menuLis
|
|
|
36
36
|
const isCollapsed = computed(() => appStore.isCollapsed)
|
|
37
37
|
const activeMenu = computed(() => route.path)
|
|
38
38
|
|
|
39
|
-
//
|
|
39
|
+
// 获取菜单的唯一标识(优先使用 menuId,其次 menuCode,最后 menuUrl)
|
|
40
|
+
const getMenuKey = (menu: any): string => {
|
|
41
|
+
return menu.menuId || menu.menuCode || menu.menuUrl || ''
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// 菜单展开状态持久化(基于当前菜单列表的标识)
|
|
40
45
|
const OPENED_MENUS_KEY = 'sidebar_opened_menus'
|
|
41
|
-
const
|
|
46
|
+
const MENU_LIST_KEY = 'sidebar_menu_list_key'
|
|
47
|
+
|
|
48
|
+
// 获取当前菜单列表的唯一标识
|
|
49
|
+
const getCurrentMenuListKey = (): string => {
|
|
50
|
+
return displayMenuList.value.map(getMenuKey).join(',')
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// 初始化展开状态:只有当菜单列表相同时才恢复之前的展开状态
|
|
54
|
+
const savedMenuListKey = local.get<string>(MENU_LIST_KEY) || ''
|
|
55
|
+
const currentKey = getCurrentMenuListKey()
|
|
56
|
+
const initialOpenedMenus = savedMenuListKey === currentKey
|
|
57
|
+
? (local.get<string[]>(OPENED_MENUS_KEY) || [])
|
|
58
|
+
: []
|
|
59
|
+
const openedMenus = ref<string[]>(initialOpenedMenus)
|
|
42
60
|
|
|
43
61
|
// 监听变化并持久化
|
|
44
62
|
watch(openedMenus, (val) => {
|
|
45
63
|
local.set(OPENED_MENUS_KEY, val)
|
|
64
|
+
local.set(MENU_LIST_KEY, getCurrentMenuListKey())
|
|
46
65
|
}, { deep: true })
|
|
47
66
|
|
|
48
67
|
// 递归查找当前路由对应的父菜单路径
|
|
@@ -81,8 +100,9 @@ watch(displayMenuList, (newList, oldList) => {
|
|
|
81
100
|
if (newList !== oldList) {
|
|
82
101
|
openedMenus.value = []
|
|
83
102
|
local.set(OPENED_MENUS_KEY, [])
|
|
103
|
+
local.set(MENU_LIST_KEY, getCurrentMenuListKey())
|
|
84
104
|
}
|
|
85
|
-
})
|
|
105
|
+
}, { immediate: false })
|
|
86
106
|
|
|
87
107
|
// 菜单主题相关
|
|
88
108
|
const menuBgColor = computed(() => appStore.isDark ? '#1d1e1f' : '#fff')
|