|
|
@@ -11,16 +11,16 @@
|
|
|
theme="dark"
|
|
|
mode="horizontal"
|
|
|
:style="{ lineHeight: '64px' }"
|
|
|
- v-model:selectedKeys="selectedKeys"
|
|
|
+ :selectedKeys="selectedKeys"
|
|
|
>
|
|
|
<a-menu-item
|
|
|
v-for="route in appRouter.$state.router.navbar.route"
|
|
|
:key="route.path"
|
|
|
- @click="changeRouter(route.path)"
|
|
|
+ @click="changeRouter(route)"
|
|
|
>
|
|
|
{{route.name}}
|
|
|
</a-menu-item>
|
|
|
- </a-menu>
|
|
|
+ </a-menu>
|
|
|
</a-col>
|
|
|
<a-col :span="1" >
|
|
|
<user />
|
|
|
@@ -31,7 +31,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup >
|
|
|
-import { computed, onMounted, ref } from 'vue'
|
|
|
+import { onMounted, ref } from 'vue'
|
|
|
import { useAppRouter } from '@/store/router'
|
|
|
import user from './user.vue'
|
|
|
import { useRouter, useRoute } from 'vue-router'
|
|
|
@@ -47,9 +47,13 @@ const appRouter = useAppRouter()
|
|
|
|
|
|
const selectedKeys = ref<string[]>()
|
|
|
|
|
|
-const changeRouter = (path: string) => {
|
|
|
- selectedKeys.value = [path]
|
|
|
- appRouter.changeNavbar(path, '')
|
|
|
+const changeRouter = (route: ROUTER.RoutesProps) => {
|
|
|
+ if (route.link) {
|
|
|
+ window.open(route.path)
|
|
|
+ } else {
|
|
|
+ selectedKeys.value = [route.path]
|
|
|
+ appRouter.changeNavbar(route.path, '')
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
const hasCurrentRourte = (children: ROUTER.RoutesProps[]): boolean => {
|
|
|
@@ -73,7 +77,7 @@ const hasCurrentRourte = (children: ROUTER.RoutesProps[]): boolean => {
|
|
|
|
|
|
onMounted(() => {
|
|
|
routes.forEach(item => {
|
|
|
- if (hasCurrentRourte(item.children)) {
|
|
|
+ if (item.children && hasCurrentRourte(item.children)) {
|
|
|
selectedKeys.value = [item.path]
|
|
|
appRouter.changeNavbar(item.path, 'init')
|
|
|
appRouter.changeSiderRoute()
|