feat: 升级stylelint依赖并修复相关问题
- 更新stylelint到16.x版本 - 修复postcss版本冲突 - 解决循环依赖问题 - 优化代码类型定义
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
<template>
|
||||
<a-layout class="layout" :class="{ mobile: appStore.hideMenu }">
|
||||
<div v-if="navbar" class="layout-navbar">
|
||||
<NavBar :menus="topMenus" :selected-key="topSelectedKey" @menu-click="handleMenuClick" />
|
||||
<NavBar
|
||||
:menus="topMenus"
|
||||
:selected-key="topSelectedKey"
|
||||
@menu-click="handleMenuClick"
|
||||
/>
|
||||
</div>
|
||||
<a-layout>
|
||||
<a-layout>
|
||||
@@ -66,32 +70,37 @@
|
||||
|
||||
// 动态获取顶栏和侧边栏菜单
|
||||
const topMenus = computed(() => {
|
||||
return router.getRoutes().filter(el => el.meta.isFirst && el.children?.length);
|
||||
return router
|
||||
.getRoutes()
|
||||
.filter((el) => el.meta.isFirst && el.children?.length);
|
||||
});
|
||||
const topSelectedKey = ref('');
|
||||
|
||||
const findTopMenu = (currentRoute: any) => {
|
||||
return topMenus.value.find(el => currentRoute.path.startsWith(el.path));
|
||||
return topMenus.value.find((el) => currentRoute.path.startsWith(el.path));
|
||||
};
|
||||
|
||||
watch(() => route.path, (newPath) => {
|
||||
const currentTopMenu = findTopMenu(route);
|
||||
if (currentTopMenu) {
|
||||
topSelectedKey.value = currentTopMenu.path;
|
||||
appStore.updateSettings({ serverMenu: currentTopMenu.children });
|
||||
|
||||
// 确保左侧菜单能正确识别当前路由
|
||||
// 延迟一下,确保菜单数据更新后再触发路由监听
|
||||
setTimeout(() => {
|
||||
// 强制触发菜单组件的路由监听
|
||||
const currentRoute = router.currentRoute.value;
|
||||
if (currentRoute.name) {
|
||||
// 这里可以添加一些调试信息
|
||||
console.log('Current route:', currentRoute.name, 'Path:', currentRoute.path);
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
}, { immediate: true });
|
||||
watch(
|
||||
() => route.path,
|
||||
(newPath) => {
|
||||
const currentTopMenu = findTopMenu(route);
|
||||
if (currentTopMenu) {
|
||||
topSelectedKey.value = currentTopMenu.path;
|
||||
appStore.updateSettings({ serverMenu: currentTopMenu.children });
|
||||
|
||||
// 确保左侧菜单能正确识别当前路由
|
||||
// 延迟一下,确保菜单数据更新后再触发路由监听
|
||||
setTimeout(() => {
|
||||
// 强制触发菜单组件的路由监听
|
||||
const currentRoute = router.currentRoute.value;
|
||||
if (currentRoute.name) {
|
||||
// 路由切换完成,菜单应该能正确识别当前路由
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
const navbarHeight = `60px`;
|
||||
const navbar = computed(() => appStore.navbar);
|
||||
@@ -107,7 +116,7 @@
|
||||
const paddingStyle = computed(() => {
|
||||
const paddingLeft =
|
||||
renderMenu.value && !hideMenu.value
|
||||
? { paddingLeft: `${(menuWidth.value + 10)}px` }
|
||||
? { paddingLeft: `${menuWidth.value + 10}px` }
|
||||
: {};
|
||||
const paddingTop = navbar.value ? { paddingTop: navbarHeight } : {};
|
||||
return { ...paddingLeft, ...paddingTop };
|
||||
@@ -131,7 +140,7 @@
|
||||
drawerVisible.value = !drawerVisible.value;
|
||||
});
|
||||
const handleMenuClick = (key: string) => {
|
||||
const currentTopMenu = topMenus.value.find(el => el.path === key);
|
||||
const currentTopMenu = topMenus.value.find((el) => el.path === key);
|
||||
if (currentTopMenu?.children?.length) {
|
||||
router.push({ name: currentTopMenu.children[0].name });
|
||||
appStore.updateSettings({ serverMenu: currentTopMenu.children });
|
||||
|
||||
Reference in New Issue
Block a user