primevue-mirror/apps/showcase/layouts/default.vue

89 lines
2.4 KiB
Vue

<template>
<div :class="containerClass" :data-p-theme="$appState.theme">
<AppNews />
<AppTopBar @menubutton-click="onMenuButtonClick" />
<div :class="['layout-mask', { 'layout-mask-active': sidebarActive }]" @click="onMaskClick"></div>
<div class="layout-content">
<app-menu :active="sidebarActive" />
<div class="layout-content-slot">
<slot></slot>
</div>
</div>
<AppFooter />
<Toast />
<Toast position="top-left" group="tl" />
<Toast position="bottom-left" group="bl" />
<Toast position="bottom-right" group="br" />
</div>
</template>
<script>
import { blockBodyScroll, unblockBodyScroll } from '@primeuix/utils/dom';
import AppFooter from './AppFooter.vue';
import AppMenu from './AppMenu.vue';
import AppNews from './AppNews.vue';
import AppTopBar from './AppTopBar.vue';
export default {
data() {
return {
sidebarActive: false
};
},
watch: {
$route: {
immediate: true,
handler() {
if (!process.client || typeof window === 'undefined') {
return;
}
this.sidebarActive = false;
unblockBodyScroll('blocked-scroll');
this.$toast.removeAllGroups();
}
}
},
methods: {
onMenuButtonClick() {
if (this.sidebarActive) {
this.sidebarActive = false;
unblockBodyScroll('blocked-scroll');
} else {
this.sidebarActive = true;
blockBodyScroll('blocked-scroll');
}
},
onMaskClick() {
this.sidebarActive = false;
unblockBodyScroll('blocked-scroll');
},
isOutdatedIE() {
let ua = window.navigator.userAgent;
if (ua.indexOf('MSIE ') > 0 || ua.indexOf('Trident/') > 0) {
return true;
}
return false;
}
},
computed: {
containerClass() {
return [
'layout-wrapper',
{
'layout-news-active': this.$appState.newsActive
}
];
}
},
components: {
AppTopBar,
AppMenu,
AppFooter,
AppNews
}
};
</script>