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