cwg-page-wrapper.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <view :class="['page-wrapper', { dark: isDark }]">
  3. <cwg-match-media :min-width="991" v-if="!isLoginPage">
  4. <view class="left-sidebar">
  5. <cwg-sidebar />
  6. <cwg-submenu v-if="sidebarVisible" @submenu-click="onSubmenuClick" />
  7. </view>
  8. </cwg-match-media>
  9. <cwg-progress />
  10. <view class="page-content">
  11. <cwg-match-media :min-width="991" v-if="!isLoginPage">
  12. <cwg-pc-header @toggle-sidebar="toggleSidebar" />
  13. </cwg-match-media>
  14. <cwg-match-media :max-width="991">
  15. <cwg-header v-if="!isHeaderFixed" />
  16. </cwg-match-media>
  17. <view class="content-wrapper">
  18. <slot />
  19. </view>
  20. <view :style="{ height: isTabBarPage ? '60px' : '0px' }" />
  21. </view>
  22. <cwg-match-media :max-width="991">
  23. <cwg-tab-bar v-model:isTabBarPage="isTabBarPage" />
  24. </cwg-match-media>
  25. </view>
  26. </template>
  27. <script setup lang="ts">
  28. import { ref, watch, computed } from "vue";
  29. import { onLoad, onShow } from '@dcloudio/uni-app'
  30. import { updateRoute } from '@/hooks/useRoute'
  31. import useGlobalStore from '@/stores/use-global-store'
  32. const globalStore = useGlobalStore()
  33. interface MenuItem {
  34. key: string;
  35. label: string;
  36. icon?: string;
  37. children?: MenuItem[];
  38. }
  39. const props = defineProps({
  40. // 是否固定顶部导航栏
  41. isHeaderFixed: {
  42. type: Boolean,
  43. default: false
  44. },
  45. // 是否登录页,登录页不显示侧边栏和顶部导航,注册忘记密码等页面
  46. isLoginPage: {
  47. type: Boolean,
  48. default: false
  49. }
  50. })
  51. const isDark = computed(() => globalStore.theme === 'dark')
  52. const isTabBarPage = ref(false)
  53. const sidebarVisible = ref(true)
  54. function toggleSidebar() {
  55. sidebarVisible.value = !sidebarVisible.value;
  56. }
  57. onLoad(() => {
  58. updateRoute()
  59. })
  60. onShow(() => {
  61. updateRoute()
  62. })
  63. </script>
  64. <style lang="scss" scoped>
  65. @import "@/uni.scss";
  66. .page-wrapper {
  67. display: flex;
  68. flex-direction: row;
  69. height: 100vh;
  70. overflow: hidden;
  71. }
  72. .left-sidebar {
  73. display: flex;
  74. flex-direction: row;
  75. }
  76. .page-content {
  77. flex: 1;
  78. display: flex;
  79. flex-direction: column;
  80. }
  81. .content-wrapper {
  82. flex: 1;
  83. // padding: 0 px2rpx(24) px2rpx(0) px2rpx(24);
  84. box-sizing: border-box;
  85. overflow-y: auto;
  86. }
  87. </style>