From 9888eb4278a2c74f8533b468bba958cfffb7b125 Mon Sep 17 00:00:00 2001 From: birt <2499248221@qq.com> Date: 星期日, 13 四月 2025 22:12:11 +0800 Subject: [PATCH] 折叠 --- zhitan-vue/src/components/TopNav/index.vue | 13 ++----------- zhitan-vue/src/layout/index.vue | 16 ++++++++++------ zhitan-vue/src/router/index.js | 8 +------- 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/zhitan-vue/src/components/TopNav/index.vue b/zhitan-vue/src/components/TopNav/index.vue index 85bc9e8..774132d 100644 --- a/zhitan-vue/src/components/TopNav/index.vue +++ b/zhitan-vue/src/components/TopNav/index.vue @@ -167,12 +167,7 @@ return; } - if (key === '/index' || key === '/') { - // 棣栭〉鏃舵樉绀烘姌鍙犵殑渚ц竟鏍忥紝鑰屼笉鏄殣钘� - router.push({ path: key }); - appStore.showCollapsedSidebar(); - return; - } + // 妫�鏌ユ槸鍚︽湁瀛愯矾鐢� if (route && route.children && route.children.length > 0) { @@ -258,11 +253,7 @@ function activeRoutes(key) { let routes = []; - if (key === '/index' || key === '/') { - // 棣栭〉鏃舵樉绀烘姌鍙犵殑渚ц竟鏍忥紝鑰屼笉鏄殣钘� - appStore.showCollapsedSidebar(); - return []; - } + // 鏌ユ壘鍖归厤鐨勮矾鐢� if (childrenMenus.value && childrenMenus.value.length > 0) { diff --git a/zhitan-vue/src/layout/index.vue b/zhitan-vue/src/layout/index.vue index 7cb8e3e..00a46f1 100644 --- a/zhitan-vue/src/layout/index.vue +++ b/zhitan-vue/src/layout/index.vue @@ -119,21 +119,25 @@ // 鐩戝惉璺敱鍙樺寲锛屽鐞嗛椤电殑渚ц竟鏍忔樉绀� watchEffect(() => { - // 妫�鏌ユ槸鍚︽槸棣栭〉璺敱 - if (route.path === '/index' || route.path === '/') { + // 妫�鏌ユ槸鍚︽槸棣栭〉璺敱锛屼絾鎺掗櫎/index/index瀛愯矾鐢� + if ((route.path === '/index' || route.path === '/') && route.path !== '/index/index') { // 棣栭〉璺敱锛岀‘淇濅晶杈规爮涓嶉殣钘忥紝浣嗙姸鎬佹槸鎶樺彔鐨� - appStore.showCollapsedSidebar() + appStore.toggleSideBarHide(false) // 鏀逛负涓嶉殣钘忎晶杈规爮 } else if (route.meta && route.meta.showSidebar === false) { // 濡傛灉璺敱鏄庣‘鎸囧畾闅愯棌渚ц竟鏍� appStore.toggleSideBarHide(true) + } else { + // 鍏朵粬璺敱锛岀‘淇濅晶杈规爮鍙 + appStore.toggleSideBarHide(false) } }) // 缁勪欢鎸傝浇鏃讹紝纭繚棣栭〉渚ц竟鏍忕姸鎬佹纭� onMounted(() => { - // 濡傛灉褰撳墠鏄椤碉紝纭繚渚ц竟鏍忔槸鎶樺彔鐨勮�屼笉鏄殣钘忕殑 - if (route.path === '/index' || route.path === '/') { - appStore.showCollapsedSidebar() + // 濡傛灉褰撳墠鏄椤碉紝纭繚渚ц竟鏍忓彲瑙� + if (route.path === '/index/index') { + appStore.toggleSideBarHide(false) + appStore.sidebar.opened = true } }) diff --git a/zhitan-vue/src/router/index.js b/zhitan-vue/src/router/index.js index 154b3be..42dcb70 100644 --- a/zhitan-vue/src/router/index.js +++ b/zhitan-vue/src/router/index.js @@ -67,13 +67,7 @@ path: '/index', component: () => import('@/views/index'), name: 'Index', - meta: { title: '棣栭〉', icon: 'dashboard', affix: true, showSidebar: true, breadcrumb: false }, - beforeEnter: (to, from, next) => { - // 鑾峰彇app store骞惰缃晶杈规爮涓烘姌鍙犵姸鎬� - const appStore = useAppStore() - appStore.showCollapsedSidebar() - next() - } + meta: { title: '棣栭〉', icon: 'dashboard', affix: true, showSidebar: true, breadcrumb: false } } ] }, -- Gitblit v1.9.3