Skip to content

Commit

Permalink
fix: redirect bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kanyxmo committed Jul 9, 2024
1 parent 7bff562 commit c16972a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
12 changes: 6 additions & 6 deletions src/layout/components/columns/ma-columns-menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@
const classStyle = ref('flex flex-col parent-menu items-center rounded mt-1 text-gray-200 hover:bg-gray-700 dark:hover:text-gray-50 dark:hover:bg-blackgray-1')

onMounted(() => {
initMenu()
initMenu(true)
})

watch(() => route, v => {
initMenu()
initMenu(false)
}, { deep: true })

const initMenu = () => {
const initMenu = (init = true) => {
let current
if (route.matched[1]?.meta?.breadcrumb) {
current = route.matched[1].meta.breadcrumb[0].name
Expand All @@ -76,18 +76,18 @@
}
if (userStore.routers && userStore.routers.length > 0) {
userStore.routers.map((item, index) => {
if (item.name == current) loadMenu(item, index)
if (item.name == current) loadMenu(item, index, init)
})
}
}

const loadMenu = (bigMenu, index) => {
const loadMenu = (bigMenu, index, isInit = true) => {
if (bigMenu.meta.type === 'L') {
window.open(bigMenu.path)
return
}
if (bigMenu.children.length > 0) {
if (bigMenu.redirect) {
if (bigMenu.redirect && isInit) {
router.push(bigMenu.redirect)
}
MaMenuRef.value.loadChildMenu(bigMenu)
Expand Down
4 changes: 1 addition & 3 deletions src/layout/components/components/children-menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@
const routerPush = (menu) => {
if (menu.meta && menu.meta.type === 'L') {
window.open(menu.path)
} else if (menu.redirect) {
router.push(menu.redirect)
} else {
}else {
router.push(menu.path)
tagStore.addTag({ name: menu.name, title: menu.meta.title, path: menu.path })
}
Expand Down
13 changes: 8 additions & 5 deletions src/layout/components/mixed/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,32 +62,35 @@
const active = ref()

onMounted(() => {
initMenu()
initMenu(true)
})

watch(() => route, v => {
initMenu()
initMenu(false)
}, { deep: true })

const initMenu = () => {
const initMenu = (init = true) => {
if (route.matched[1]?.meta?.breadcrumb) {
active.value = route.matched[1].meta.breadcrumb[0].name
} else {
active.value = 'home'
}
if (userStore.routers && userStore.routers.length > 0) {
userStore.routers.map((item, index) => {
if (item.name == active.value) loadMenu(item)
if (item.name == active.value) loadMenu(item, init)
})
}
}

const loadMenu = (bigMenu) => {
const loadMenu = (bigMenu, isInit = true) => {
if (bigMenu.meta.type === 'L') {
window.open(bigMenu.path)
return
}
if (bigMenu.children.length > 0) {
if (bigMenu.redirect && isInit) {
router.push(bigMenu.redirect)
}
MaMenuRef.value.loadChildMenu(bigMenu)
showMenu.value = true
} else {
Expand Down

0 comments on commit c16972a

Please sign in to comment.