This commit is contained in:
13218645326 2023-12-10 00:37:51 +08:00
parent d71f3dac09
commit 4eb561a822
4 changed files with 21 additions and 11 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<subMenu :menuList="menuInfo.menuList" :collapse="menuInfo.collapse" :backgroundColor="menuInfo.backgroundColor" <subMenu :menuList="menuInfo.menuList" :collapse="menuInfo.collapse" :backgroundColor="menuInfo.backgroundColor"
:textColor="menuInfo.textColor" :activeTextColor="menuInfo.activeTextColor" :defaultActive="menuInfo.defaultActive" :textColor="menuInfo.textColor" :activeTextColor="menuInfo.activeTextColor" :defaultActive="navStore.defaultActive"
:defaultOpeneds="menuInfo.defaultOpeneds" :uniqueOpened="menuInfo.uniqueOpened" :menuTrigger="menuInfo.menuTrigger" :defaultOpeneds="menuInfo.defaultOpeneds" :uniqueOpened="menuInfo.uniqueOpened" :menuTrigger="menuInfo.menuTrigger"
:router="menuInfo.router" :collapseTransition="menuInfo.collapseTransition" :popperEffect="menuInfo.popperEffect" :router="menuInfo.router" :collapseTransition="menuInfo.collapseTransition" :popperEffect="menuInfo.popperEffect"
:isCustomLink="menuInfo.isCustomLink" :customLinkCallBack="menuInfo.customLinkCallBack"></subMenu> :isCustomLink="menuInfo.isCustomLink" :customLinkCallBack="menuInfo.customLinkCallBack"></subMenu>
@ -33,6 +33,7 @@ const menuInfo: any = reactive({
router.push({ router.push({
name: ev.path name: ev.path
}) })
navStore.setDefaultActive(ev)
navStore.addNavTarget(ev) navStore.addNavTarget(ev)
} }
}) })
@ -53,9 +54,9 @@ const initRouteList = () => {
// console.log("menuInfo.menuList",menuInfo.menuList) // console.log("menuInfo.menuList",menuInfo.menuList)
menuInfo.defaultOpeneds.push() menuInfo.defaultOpeneds.push()
const routes: any = list const routes: any = list
console.log("routes", routes) console.log("routes", router)
const currentNav = routes[0] const currentNav = routes.find((ele:any)=>ele.meta.folder).children[0]
if (navStore.topNavList) { if (navStore.topNavList.length == 0) {
let firstNav = { let firstNav = {
title: currentNav.meta.title, title: currentNav.meta.title,
name: currentNav.name, name: currentNav.name,

View File

@ -6,20 +6,20 @@ const routes: Array<RouteRecordRaw> = [
path: '/', path: '/',
name: 'home', name: 'home',
component: () => import('views/AppMain.vue'), component: () => import('views/AppMain.vue'),
redirect: '/index/swiperConfig',
meta: { meta: {
title: '主页面', title: '主页面',
keepAlive: true, keepAlive: true,
AuthFlag: true, AuthFlag: true,
routeListRoot: true routeListRoot: true
}, },
children: [] children: [],
redirect: '/index/enterpriseType',
}, },
{ {
path: '/index', path: '/index',
name: 'index', name: 'index',
component: () => import('views/AppMain.vue'), component: () => import('views/AppMain.vue'),
redirect: '/index/swiperConfig',
meta: { meta: {
title: '主页面', title: '主页面',
keepAlive: true, keepAlive: true,

View File

@ -46,7 +46,8 @@ export const list: any = [
meta: { meta: {
title: '企业管理', title: '企业管理',
keepAlive: true, keepAlive: true,
AuthFlag: true AuthFlag: true,
folder:true
}, },
children: [ children: [
@ -100,7 +101,8 @@ export const list: any = [
meta: { meta: {
title: '企业装备管理', title: '企业装备管理',
keepAlive: true, keepAlive: true,
AuthFlag: true AuthFlag: true,
folder:true
}, },
children: [ children: [
// { // {

View File

@ -4,7 +4,8 @@ export const comNavStore = defineStore('main_com_nav', {
return { return {
topNavList: [] as any, //loading控制, topNavList: [] as any, //loading控制,
maxNavCount: 8, maxNavCount: 8,
currentNav:'' currentNav:'',
defaultActive:''
} }
}, },
getters: {}, getters: {},
@ -31,7 +32,13 @@ export const comNavStore = defineStore('main_com_nav', {
setCurrentNav(ev:any){ setCurrentNav(ev:any){
console.log("setCurrentNav") console.log("setCurrentNav")
this.currentNav = ev this.currentNav = ev
} ,
setDefaultActive(ev:any){
console.log("setCurrentNav")
this.defaultActive = ev.path+'&&'+ev.title
} }
}, },
persist: { persist: {
enabled: true, // 开启数据缓存 enabled: true, // 开启数据缓存
@ -41,7 +48,7 @@ export const comNavStore = defineStore('main_com_nav', {
key: 'main_com_nav', key: 'main_com_nav',
storage: sessionStorage, //缓存模式 可选 localStorage sessionStorage storage: sessionStorage, //缓存模式 可选 localStorage sessionStorage
// state 中的字段名,按组打包储存 // state 中的字段名,按组打包储存
paths: ['topNavList'] //需要缓存的字段 与 state中相关联 paths: ['topNavList','currentNav','defaultActive'] //需要缓存的字段 与 state中相关联
} }
] ]
} }