feat: 调整菜单跳转 支持外链跳转

ysnc
程 明锐 2026-01-12 14:39:43 +08:00
parent ba3b23c98b
commit bbfaf46ca9
1 changed files with 14 additions and 6 deletions

View File

@ -9,6 +9,9 @@
</ul>
</template>
<script>
import { isExternalLink } from '@/utils/resolvePath'
import { openWindow } from './sidebar/useLink'
export default {
props: {
pageConfigs: Object
@ -44,7 +47,7 @@ export default {
return this.$route.meta.hiddenSide
}
},
created() {},
// created() {},
methods: {
getStyle(item) {
if (item.selected) {
@ -55,11 +58,11 @@ export default {
}
},
getJumpRoute(data) {
const route = data[0]
if (route.children) {
const route = data?.[0]
if (route?.children) {
return this.getJumpRoute(route.children)
}
return route.path
return route?.path
},
// flag:
resetMenu(flag) {
@ -78,16 +81,21 @@ export default {
const menu = this.menuData.find((cell) => cell.id === item.id)
menu.selected = true
//
const menus = menu.children.filter((item) => !item.hidden)
const menus = menu.children?.filter((item) => !item.hidden) || []
if (menus.length) {
this.$store.commit('SETTING_SIDE_MENU', menu.children)
this.$store.commit('SETTING_BASE_PATH', menu.path)
} else {
this.resetMenu(true)
}
if (isExternalLink(menu.path)) {
openWindow(menu.path)
return
}
//
if (flag) {
this.$router.push({ path: this.getJumpRoute(menu.children) })
this.$router.push({ path: this.getJumpRoute(menu?.children) })
}
},
initMenu() {