101 lines
2.5 KiB
Vue
Raw Normal View History

2021-12-18 16:36:43 +08:00
<template>
<n-layout-sider
2021-12-20 13:36:54 +08:00
class="go-project-sider"
2021-12-18 16:36:43 +08:00
bordered
collapse-mode="width"
2021-12-18 22:05:00 +08:00
show-trigger="bar"
2021-12-18 16:36:43 +08:00
:collapsed="collapsed"
:native-scrollbar="false"
2022-01-08 15:00:52 +08:00
:collapsed-width="getAsideCollapsedWidth"
2021-12-18 16:36:43 +08:00
:width="asideWidth"
@collapse="collapsed = true"
@expand="collapsed = false"
>
<div class="go-project-sider-flex">
<aside>
<n-space vertical class="go-project-sider-top">
<Create :collapsed="collapsed"></Create>
2021-12-18 16:36:43 +08:00
</n-space>
<n-menu
:value="menuValue"
:options="menuOptions"
2022-01-08 15:00:52 +08:00
:collapsed-width="getAsideCollapsedWidth"
2021-12-18 16:36:43 +08:00
:collapsed-icon-size="22"
2021-12-18 22:05:00 +08:00
:default-expanded-keys="defaultExpandedKeys"
></n-menu>
2021-12-18 16:36:43 +08:00
</aside>
<!-- 底部提示 -->
<div class="sider-bottom">
<AsideFooter :collapsed="collapsed"></AsideFooter>
2021-12-18 16:36:43 +08:00
</div>
</div>
</n-layout-sider>
</template>
<script setup lang="ts">
2022-01-20 21:25:35 +08:00
import { ref, computed, onMounted, onUnmounted, toRefs } from 'vue'
2021-12-18 16:36:43 +08:00
import { Create } from '../Create/index'
import { AsideFooter } from '../AsideFooter/index'
import { asideWidth, asideCollapsedWidth } from '@/settings/designSetting'
import { useRoute } from 'vue-router'
2022-01-15 16:07:46 +08:00
import { useSettingStore } from '@/store/modules/settingStore/settingStore'
2022-01-08 15:00:52 +08:00
import { menuOptionsInit, expandedKeys } from './menu'
2021-12-18 16:36:43 +08:00
2021-12-18 22:05:00 +08:00
const collapsed = ref<boolean>(false)
2022-01-15 16:07:46 +08:00
const { getAsideCollapsedWidth } = toRefs(useSettingStore())
2021-12-18 16:36:43 +08:00
const route = useRoute()
const routeRame = computed(() => route.name)
const menuValue = ref(routeRame)
const menuOptions = menuOptionsInit()
2021-12-18 22:05:00 +08:00
const defaultExpandedKeys = expandedKeys()
const watchWidth = () => {
const Width = document.body.clientWidth
if (Width <= 950) {
collapsed.value = true
} else collapsed.value = false
}
onMounted(() => {
window.addEventListener('resize', watchWidth)
})
2022-01-20 21:25:35 +08:00
onUnmounted(()=> {
window.removeEventListener('resize', watchWidth)
})
2021-12-18 16:36:43 +08:00
</script>
<style lang="scss" scoped>
$siderHeight: 100vh;
@include go(project) {
&-sider {
2022-01-06 13:45:51 +08:00
@include filter-bg-color('aside-background-color');
2021-12-18 16:36:43 +08:00
&-top {
display: flex;
align-items: center;
justify-content: space-between;
flex-direction: column;
margin-top: 30px;
margin-bottom: 20px;
}
&-flex {
display: flex;
flex-direction: column;
justify-content: space-between;
height: $siderHeight;
}
}
&-layout-sider {
height: $siderHeight;
}
.content-top {
top: $--header-height;
margin-top: 1px;
}
}
</style>