| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <template>
- <view :class="['page-wrapper', { dark: isDark }]">
- <cwg-match-media :min-width="991" v-if="!isLoginPage">
- <view class="left-sidebar">
- <cwg-sidebar />
- <cwg-submenu v-if="sidebarVisible" @submenu-click="onSubmenuClick" />
- </view>
- </cwg-match-media>
- <cwg-progress />
- <view class="page-content">
- <cwg-match-media :min-width="991" v-if="!isLoginPage">
- <cwg-pc-header @toggle-sidebar="toggleSidebar" />
- </cwg-match-media>
- <cwg-match-media :max-width="991">
- <cwg-header v-if="!isHeaderFixed" />
- </cwg-match-media>
- <view class="content-wrapper" :class="{ 'content-wrapper-padding': isContentPadding}">
- <slot />
- </view>
- <view :style="{ height: isTabBarPage ? '60px' : '0px' }" />
- </view>
- <cwg-match-media :max-width="991">
- <cwg-tab-bar v-model:isTabBarPage="isTabBarPage" />
- </cwg-match-media>
- </view>
- </template>
- <script setup lang="ts">
- import { ref, watch, computed } from "vue";
- import { onLoad, onShow } from '@dcloudio/uni-app'
- import { updateRoute } from '@/hooks/useRoute'
- import useGlobalStore from '@/stores/use-global-store'
- const globalStore = useGlobalStore()
- interface MenuItem {
- key: string;
- label: string;
- icon?: string;
- children?: MenuItem[];
- }
- const props = defineProps({
- // 是否固定顶部导航栏
- isHeaderFixed: {
- type: Boolean,
- default: false
- },
- // 是否登录页,登录页不显示侧边栏和顶部导航,注册忘记密码等页面
- isLoginPage: {
- type: Boolean,
- default: false
- },
- // 是否含有padding 默认有
- isContentPadding: {
- type: Boolean,
- default: true
- }
- })
- const isDark = computed(() => globalStore.theme === 'dark')
- const isTabBarPage = ref(false)
- const sidebarVisible = ref(true)
- function toggleSidebar() {
- sidebarVisible.value = !sidebarVisible.value;
- }
- onLoad(() => {
- updateRoute()
- })
- onShow(() => {
- updateRoute()
- })
- </script>
- <style lang="scss" scoped>
- @import "@/uni.scss";
- .page-wrapper {
- display: flex;
- flex-direction: row;
- height: 100vh;
- overflow: hidden;
- }
- .left-sidebar {
- display: flex;
- flex-direction: row;
- }
- .page-content {
- flex: 1;
- display: flex;
- flex-direction: column;
- }
- .content-wrapper {
- flex: 1;
- // padding: 0 px2rpx(24) px2rpx(0) px2rpx(24);
- box-sizing: border-box;
- overflow-y: auto;
- }
- .content-wrapper-padding{
- padding: px2rpx(30);
- }
- </style>
|