|
@@ -11,7 +11,7 @@
|
|
|
theme="dark"
|
|
theme="dark"
|
|
|
mode="horizontal"
|
|
mode="horizontal"
|
|
|
:style="{ lineHeight: '64px' }"
|
|
:style="{ lineHeight: '64px' }"
|
|
|
- v-model:selectedKeys="selectedKeys1"
|
|
|
|
|
|
|
+ v-model:selectedKeys="selectedKeys"
|
|
|
>
|
|
>
|
|
|
<a-menu-item
|
|
<a-menu-item
|
|
|
v-for="route in appRouter.$state.router.navbar.route"
|
|
v-for="route in appRouter.$state.router.navbar.route"
|
|
@@ -31,18 +31,61 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup >
|
|
<script lang="ts" setup >
|
|
|
-import { ref } from 'vue'
|
|
|
|
|
|
|
+import { computed, onMounted, ref } from 'vue'
|
|
|
import { useAppRouter } from '@/store/router'
|
|
import { useAppRouter } from '@/store/router'
|
|
|
import user from './user.vue'
|
|
import user from './user.vue'
|
|
|
-// import logo from '@/assets/logo.png'
|
|
|
|
|
|
|
+import { useRouter, useRoute } from 'vue-router'
|
|
|
|
|
+import { routes } from '@/router/index'
|
|
|
|
|
|
|
|
const logoPng = require('@/assets/logo.png')
|
|
const logoPng = require('@/assets/logo.png')
|
|
|
|
|
|
|
|
|
|
+const router = useRouter()
|
|
|
|
|
+
|
|
|
|
|
+const route = useRoute()
|
|
|
|
|
+
|
|
|
const appRouter = useAppRouter()
|
|
const appRouter = useAppRouter()
|
|
|
|
|
|
|
|
-const selectedKeys1 = ref<string[]>([appRouter.$state.router.navbar.selectPath])
|
|
|
|
|
|
|
+console.log('router:', router.currentRoute)
|
|
|
|
|
+// [appRouter.$state.router.navbar.selectPath]
|
|
|
|
|
+
|
|
|
|
|
+const selectedKeys = ref<string[]>()
|
|
|
|
|
+
|
|
|
|
|
+const changeRouter = (path: string) => {
|
|
|
|
|
+ console.log('changeRouter:', path)
|
|
|
|
|
+
|
|
|
|
|
+ selectedKeys.value = path
|
|
|
|
|
+ appRouter.changeNavbar(path)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+console.log('routes', routes)
|
|
|
|
|
+
|
|
|
|
|
+const navbarRoutes = ['/', 'rts']
|
|
|
|
|
+
|
|
|
|
|
+// const active = computed(() => {
|
|
|
|
|
+// routes.forEach( item => {
|
|
|
|
|
+// item
|
|
|
|
|
+// })
|
|
|
|
|
+// })
|
|
|
|
|
+
|
|
|
|
|
+const hasCurrentRourte = (children: ROUTER.RoutesProps[]): boolean => {
|
|
|
|
|
+ let r = false
|
|
|
|
|
+ children.forEach(item => {
|
|
|
|
|
+ if (item.path === route.path) {
|
|
|
|
|
+ r = true
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ return r
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
-const changeRouter = (path: string) => appRouter.changeNavbar(path)
|
|
|
|
|
|
|
+onMounted(() => {
|
|
|
|
|
+ routes.forEach(item => {
|
|
|
|
|
+ if (hasCurrentRourte(item.children)) {
|
|
|
|
|
+ selectedKeys.value = [item.path]
|
|
|
|
|
+ appRouter.changeNavbar(item.path)
|
|
|
|
|
+ appRouter.changeSiderRoute()
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+})
|
|
|
|
|
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|