|
|
@@ -1,6 +1,37 @@
|
|
|
<template>
|
|
|
+ <div
|
|
|
+ class="mobile-sider"
|
|
|
+ v-if="isMobile"
|
|
|
+ >
|
|
|
+ <div></div>
|
|
|
+ <a-layout-sider
|
|
|
+ :trigger="null"
|
|
|
+ v-model:collapsed="collapsed"
|
|
|
+ collapsible
|
|
|
+ :style="{backgroundColor: bgColor, overflow: 'hidden'}"
|
|
|
+ breakpoint="lg"
|
|
|
+ >
|
|
|
+ <div class="logo" >
|
|
|
+ <img :src="logoPng" alt="">
|
|
|
+ </div>
|
|
|
+ <a-menu
|
|
|
+ v-model:selectedKeys="selectedKeys"
|
|
|
+ :openKeys="openKeys"
|
|
|
+ mode="inline"
|
|
|
+ :style="{ borderRight: 0 }"
|
|
|
+ >
|
|
|
+ <sidebar-item
|
|
|
+ :item="route"
|
|
|
+ v-for="route in sidebarRoute"
|
|
|
+ :key="route.path"
|
|
|
+ :base-path="route.path"
|
|
|
+ />
|
|
|
+ </a-menu>
|
|
|
+ </a-layout-sider>
|
|
|
+ </div>
|
|
|
|
|
|
<a-layout-sider
|
|
|
+ v-else
|
|
|
:trigger="null"
|
|
|
v-model:collapsed="collapsed"
|
|
|
collapsible
|
|
|
@@ -30,15 +61,17 @@
|
|
|
<script lang="ts" setup >
|
|
|
|
|
|
import { ref, computed, watch } from 'vue'
|
|
|
-
|
|
|
import SidebarItem from './SidebarItem.vue'
|
|
|
import { useRouter, useRoute } from 'vue-router'
|
|
|
import { useDesignStore } from '@/store'
|
|
|
+import { useDeviceType } from '@/hooks'
|
|
|
|
|
|
const logoPng = require('@/assets/logo.png')
|
|
|
|
|
|
const designStore = useDesignStore()
|
|
|
|
|
|
+const isMobile = useDeviceType()
|
|
|
+
|
|
|
const bgColor = computed(() => designStore.theme ? '#141414' : '#fff')
|
|
|
|
|
|
const route = useRoute()
|
|
|
@@ -56,7 +89,7 @@ const openKeys = ref<string[]>()
|
|
|
watch(
|
|
|
() => route.path,
|
|
|
() => {
|
|
|
- sidebarRoute.value = router.getRoutes().find(item => item.path === route.matched[0].path)?.children
|
|
|
+ sidebarRoute.value = isMobile ? router.getRoutes() : router.getRoutes().find(item => item.path === route.matched[0].path)?.children
|
|
|
selectedKeys.value = [route.path]
|
|
|
openKeys.value = [route.matched[1].path]
|
|
|
},
|
|
|
@@ -86,4 +119,12 @@ watch(
|
|
|
height: 50px;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+.mobile-sider {
|
|
|
+ width: 100vw;
|
|
|
+ height: 100vh;
|
|
|
+ background-color: rgba(0, 0, 0, 130);
|
|
|
+ pointer-events: none;
|
|
|
+}
|
|
|
+
|
|
|
</style>
|