Layout.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <div :class="classObj" class="layout-wrapper">
  3. <NavBarTop />
  4. <!--left side-->
  5. <Sidebar v-if="settings.showLeftMenu" class="sidebar-container" />
  6. <!--right container-->
  7. <div class="main-container">
  8. <Navbar v-if="settings.showTopNavbar" />
  9. <!-- <TagsView v-if="settings.showTagsView" /> -->
  10. <AppMain />
  11. </div>
  12. </div>
  13. </template>
  14. <!--原理vue2.0-->
  15. <script lang="ts">
  16. /*可以设置默认的名字*/
  17. export default {
  18. name: 'Layout',
  19. }
  20. </script>
  21. <script setup lang="ts">
  22. import { Sidebar, AppMain, Navbar } from './components'
  23. import NavBarTop from './components/NavBarTop/index.vue'
  24. //import ResizeHook to listen page size that open or close
  25. import ResizeHook from './hook/ResizeHandler'
  26. import { useAppStore } from '@/store/app'
  27. const appStore = useAppStore()
  28. const opened = computed(() => {
  29. return appStore.sidebar.opened
  30. })
  31. const settings = computed(() => {
  32. return appStore.settings
  33. })
  34. const classObj = computed(() => {
  35. return {
  36. closeSidebar: !opened.value,
  37. hideSidebar: !settings.value.showLeftMenu,
  38. }
  39. })
  40. ResizeHook()
  41. </script>
  42. <style lang="scss" scoped>
  43. .main-container {
  44. min-height: 100%;
  45. transition: margin-left 0.28s;
  46. margin-left: var(--side-bar-width);
  47. position: relative;
  48. // border-left: 1px solid var(--layout-border-left-color);
  49. }
  50. .sidebar-container {
  51. transition: width 0.28s;
  52. width: var(--side-bar-width);
  53. background-color: var(--el-menu-bg-color);
  54. height: calc(100% - 48px);
  55. position: fixed;
  56. font-size: 0;
  57. top: 48px;
  58. bottom: 0;
  59. left: 0;
  60. z-index: 1001;
  61. overflow: hidden;
  62. }
  63. .closeSidebar {
  64. .sidebar-container {
  65. width: 54px;
  66. :deep .menuIcon {
  67. margin-right: 0 !important;
  68. }
  69. }
  70. .main-container {
  71. margin-left: 54px;
  72. }
  73. }
  74. .hideSidebar {
  75. .sidebar-container {
  76. width: 0;
  77. }
  78. .main-container {
  79. margin-left: 0;
  80. }
  81. }
  82. </style>