feat: 调整菜单跳转 支持外链跳转
parent
ba3b23c98b
commit
bbfaf46ca9
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue