|
@@ -31,28 +31,23 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup >
|
|
<script lang="ts" setup >
|
|
|
-import { computed, onMounted, ref } from 'vue'
|
|
|
|
|
|
|
+import { computed, ref } from 'vue'
|
|
|
import { useAppRouter } from '@/store/router'
|
|
import { useAppRouter } from '@/store/router'
|
|
|
import user from './user.vue'
|
|
import user from './user.vue'
|
|
|
-import { useRouter, useRoute } from 'vue-router'
|
|
|
|
|
-import { routes } from '@/router/index'
|
|
|
|
|
|
|
+import { useRoute, useRouter } from 'vue-router'
|
|
|
import { IconTsx } from '@/components/MicroComponents/index'
|
|
import { IconTsx } from '@/components/MicroComponents/index'
|
|
|
import { useDesignStore } from '@/store'
|
|
import { useDesignStore } from '@/store'
|
|
|
|
|
|
|
|
-const logoPng = require('@/assets/logo.png')
|
|
|
|
|
|
|
+const route = useRoute()
|
|
|
|
|
|
|
|
const router = useRouter()
|
|
const router = useRouter()
|
|
|
|
|
|
|
|
-const route = useRoute()
|
|
|
|
|
-
|
|
|
|
|
const appRouter = useAppRouter()
|
|
const appRouter = useAppRouter()
|
|
|
|
|
|
|
|
-const selectedKeys = ref<string[]>()
|
|
|
|
|
|
|
+const selectedKeys = ref<string[]>([route.matched[0].path])
|
|
|
|
|
|
|
|
const designStore = useDesignStore()
|
|
const designStore = useDesignStore()
|
|
|
|
|
|
|
|
-console.log('designStore:', !!designStore.theme, designStore.theme)
|
|
|
|
|
-
|
|
|
|
|
const iconName = computed(() => designStore.theme ? 'sun' : 'moon')
|
|
const iconName = computed(() => designStore.theme ? 'sun' : 'moon')
|
|
|
|
|
|
|
|
const headerBgColor = computed(() => designStore.theme ? '#141414' : '#fff')
|
|
const headerBgColor = computed(() => designStore.theme ? '#141414' : '#fff')
|
|
@@ -66,48 +61,13 @@ const changeRouter = (route: ROUTER.RoutesProps) => {
|
|
|
window.open(route.path)
|
|
window.open(route.path)
|
|
|
} else {
|
|
} else {
|
|
|
selectedKeys.value = [route.path]
|
|
selectedKeys.value = [route.path]
|
|
|
- appRouter.changeNavbar(route.path, '')
|
|
|
|
|
|
|
+ router.push(route.path)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-const hasCurrentRourte = (children: ROUTER.RoutesProps[]): boolean => {
|
|
|
|
|
- let r = false
|
|
|
|
|
- children.forEach(item => {
|
|
|
|
|
- if (item.path === route.path) {
|
|
|
|
|
- r = true
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (item.children && item.children.length) {
|
|
|
|
|
- item.children.forEach(_ => {
|
|
|
|
|
- if (_.path === route.path) {
|
|
|
|
|
- r = true
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
- return r
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-onMounted(() => {
|
|
|
|
|
- routes.forEach(item => {
|
|
|
|
|
- if (item.children && hasCurrentRourte(item.children)) {
|
|
|
|
|
- selectedKeys.value = [item.path]
|
|
|
|
|
- appRouter.changeNavbar(item.path, 'init')
|
|
|
|
|
- appRouter.changeSiderRoute()
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
-})
|
|
|
|
|
-
|
|
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="less" scoped >
|
|
<style lang="less" scoped >
|
|
|
-.header {
|
|
|
|
|
- // width: 100%;
|
|
|
|
|
- // position: absolute;
|
|
|
|
|
- // z-index: 2;
|
|
|
|
|
- // background-color: #fff;
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
|
|
.df-center {
|
|
.df-center {
|
|
|
display: flex;
|
|
display: flex;
|