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