This commit is contained in:
lcw
2025-10-28 18:26:31 +08:00
parent 240934b2c9
commit eb27d2bd11
234 changed files with 467 additions and 464 deletions

View File

@ -1,5 +1,5 @@
<template>
<el-sub-menu v-if="route.children.length > 0" :index="route.path">
<el-sub-menu v-if="route.children?.length > 0" :index="route.path">
<template #title>
<MenuItem :title="route.meta.title" :icon="route.meta.icon"></MenuItem>
</template>
@ -15,6 +15,9 @@
<script setup>
import MenuItem from './MenuItem.vue'
import { defineProps } from 'vue';
// 导入自身组件以支持递归调用
import { defineAsyncComponent } from 'vue'
const SideBarItem = defineAsyncComponent(() => import('./SideBarItem.vue'))
defineProps({
route: {

View File

@ -27,17 +27,25 @@ const store = useStore();
const router = useRouter();
const routes = computed(() => {
const fRoutes = filterRoutes(router.getRoutes());
console.log(fRoutes);
return generateMenus(fRoutes);
});
if (!store.getters.token) {
router.push("/login");
}
// 改进路由初始化逻辑,避免无限刷新
if (router.getRoutes().length <= 7 && store.state.permission.routeReady <= 1) {
store.commit("user/setIsReady", {});
setTimeout(() => {
router.go(0);
}, 200);
// 使用一次性标记避免无限刷新
if (!window.routerInitialized) {
window.routerInitialized = true;
setTimeout(() => {
router.go(0);
}, 200);
}
}
//默认激活项
const route = useRoute();
const activeMenu = computed(() => {

View File

@ -2,8 +2,10 @@
<el-scrollbar>
<div class="meunAside noScollLine">
<div style="height:100px"></div>
<div style="height: calc(100% - 100px);"><SideBarMenu></SideBarMenu></div>
<div style="height: calc(100% - 100px);">
<SideBarMenu></SideBarMenu>
</div>
</div>
</el-scrollbar>
</template>