index.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <n-layout-sider
  3. class="go-project-sider"
  4. bordered
  5. collapse-mode="width"
  6. show-trigger="bar"
  7. :collapsed="collapsed"
  8. :native-scrollbar="false"
  9. :collapsed-width="getAsideCollapsedWidth"
  10. :width="asideWidth"
  11. @collapse="collapsed = true"
  12. @expand="collapsed = false"
  13. >
  14. <div class="go-project-sider-flex">
  15. <aside>
  16. <n-space vertical class="go-project-sider-top">
  17. <project-layout-create :collapsed="collapsed"></project-layout-create>
  18. </n-space>
  19. <n-menu
  20. :value="menuValue"
  21. :options="menuOptions"
  22. :collapsed-width="getAsideCollapsedWidth"
  23. :collapsed-icon-size="22"
  24. :default-expanded-keys="defaultExpandedKeys"
  25. ></n-menu>
  26. </aside>
  27. <!-- 底部提示 -->
  28. <div class="sider-bottom">
  29. <project-layout-aside-footer :collapsed="collapsed"></project-layout-aside-footer>
  30. </div>
  31. </div>
  32. </n-layout-sider>
  33. </template>
  34. <script setup lang="ts">
  35. import { ref, computed, onMounted, onUnmounted, toRefs } from 'vue'
  36. import { ProjectLayoutCreate } from '../ProjectLayoutCreate/index'
  37. import { ProjectLayoutAsideFooter } from '../ProjectLayoutAsideFooter/index'
  38. import { asideWidth } from '@/settings/designSetting'
  39. import { useRoute } from 'vue-router'
  40. import { useSettingStore } from '@/store/modules/settingStore/settingStore'
  41. import { menuOptionsInit, expandedKeys } from './menu'
  42. const collapsed = ref<boolean>(false)
  43. const { getAsideCollapsedWidth } = toRefs(useSettingStore())
  44. const route = useRoute()
  45. const routeRame = computed(() => route.name)
  46. const menuValue = ref(routeRame)
  47. const menuOptions = menuOptionsInit()
  48. const defaultExpandedKeys = expandedKeys()
  49. const watchWidth = () => {
  50. const Width = document.body.clientWidth
  51. if (Width <= 950) {
  52. collapsed.value = true
  53. } else collapsed.value = false
  54. }
  55. onMounted(() => {
  56. window.addEventListener('resize', watchWidth)
  57. })
  58. onUnmounted(()=> {
  59. window.removeEventListener('resize', watchWidth)
  60. })
  61. </script>
  62. <style lang="scss" scoped>
  63. $siderHeight: 100vh;
  64. @include go(project) {
  65. &-sider {
  66. @include fetch-bg-color('aside-background-color');
  67. &-top {
  68. display: flex;
  69. align-items: center;
  70. justify-content: space-between;
  71. flex-direction: column;
  72. margin-top: 30px;
  73. margin-bottom: 20px;
  74. }
  75. &-flex {
  76. display: flex;
  77. flex-direction: column;
  78. justify-content: space-between;
  79. height: $siderHeight;
  80. }
  81. }
  82. &-layout-sider {
  83. height: $siderHeight;
  84. }
  85. .content-top {
  86. top: $--header-height;
  87. margin-top: 1px;
  88. }
  89. }
  90. </style>