2022-09-06 11:52:18 +00:00
< template >
2023-10-13 09:33:49 +00:00
< div class = "layout-wrapper" :class ="containerClass" :data-p-theme ="$appState.theme" >
2023-10-17 11:34:50 +00:00
< AppNews / >
2023-10-14 19:53:46 +00:00
< AppTopBar @menubutton-click ="onMenuButtonClick" @configbutton-click ="onConfigButtonClick" @darkswitch-click ="onDarkModeToggle" / >
2023-10-17 21:53:21 +00:00
< AppConfigurator :configActive ="appConfigActive" @updateConfigActive ="onUpdateConfigActive" @darkswitch-click ="onDarkModeToggle" / >
2022-09-14 14:26:41 +00:00
< div : class = "['layout-mask', { 'layout-mask-active': sidebarActive }]" @click ="onMaskClick" > < / div >
< div class = "layout-content" >
2023-10-07 15:46:59 +00:00
< app -menu :active ="sidebarActive" / >
< div class = "layout-content-slot" >
2022-09-14 14:26:41 +00:00
< slot > < / slot >
< / div >
< / div >
2023-10-10 08:38:49 +00:00
< AppFooter / >
2022-09-14 14:26:41 +00:00
< Toast / >
< Toast position = "top-left" group = "tl" / >
< Toast position = "bottom-left" group = "bl" / >
< Toast position = "bottom-right" group = "br" / >
< / div >
2022-09-06 11:52:18 +00:00
< / template >
< script >
2023-03-26 05:22:57 +00:00
import DomHandler from '@/components/lib/utils/DomHandler' ;
2023-10-14 19:53:46 +00:00
import EventBus from '@/layouts/AppEventBus' ;
import AppConfigurator from './AppConfigurator' ;
2022-12-09 09:02:20 +00:00
import AppFooter from './AppFooter.vue' ;
import AppMenu from './AppMenu.vue' ;
2022-09-06 11:52:18 +00:00
import AppNews from './AppNews.vue' ;
2022-12-09 09:02:20 +00:00
import AppTopBar from './AppTopBar.vue' ;
2022-09-06 11:52:18 +00:00
export default {
2022-09-14 14:26:41 +00:00
data ( ) {
return {
2023-02-28 08:29:30 +00:00
sidebarActive : false ,
2024-01-26 10:32:22 +00:00
appConfigActive : false ,
defaultRipple : false
2022-09-14 14:26:41 +00:00
} ;
} ,
2022-12-19 12:44:12 +00:00
watch : {
$route : {
immediate : true ,
2024-01-26 10:32:22 +00:00
handler ( to , from ) {
2022-12-19 12:44:12 +00:00
if ( ! process . client || typeof window === 'undefined' ) {
return ;
}
2022-09-06 11:52:18 +00:00
2024-01-26 10:32:22 +00:00
if ( ! this . defaultRipple ) {
if ( to . name === 'ripple' ) {
this . $appState . ripple = true ;
} else if ( from ? . name === 'ripple' ) {
this . $appState . ripple = this . defaultRipple ;
}
}
2022-12-19 12:44:12 +00:00
this . sidebarActive = false ;
2023-10-10 22:36:20 +00:00
DomHandler . unblockBodyScroll ( 'blocked-scroll' ) ;
2022-12-19 12:44:12 +00:00
this . $toast . removeAllGroups ( ) ;
}
}
} ,
2024-01-26 10:32:22 +00:00
beforeCreate ( ) {
this . defaultRipple = this . $appState . ripple ;
} ,
2022-12-20 12:32:32 +00:00
mounted ( ) {
if ( this . isOutdatedIE ( ) ) {
this . $toast . add ( {
severity : 'warn' ,
summary : 'Limited Functionality' ,
detail : 'Although PrimeVue supports IE11, ThemeSwitcher in this application cannot be not fully supported by your browser. Please use a modern browser for the best experience of the showcase.'
} ) ;
}
} ,
2022-09-14 14:26:41 +00:00
methods : {
onMenuButtonClick ( ) {
if ( this . sidebarActive ) {
this . sidebarActive = false ;
2023-10-10 22:36:20 +00:00
DomHandler . unblockBodyScroll ( 'blocked-scroll' ) ;
2022-09-14 14:26:41 +00:00
} else {
this . sidebarActive = true ;
2023-10-10 22:36:20 +00:00
DomHandler . blockBodyScroll ( 'blocked-scroll' ) ;
2022-09-14 14:26:41 +00:00
}
} ,
onMaskClick ( ) {
this . sidebarActive = false ;
2023-10-10 22:36:20 +00:00
DomHandler . unblockBodyScroll ( 'blocked-scroll' ) ;
2022-09-14 14:26:41 +00:00
} ,
isOutdatedIE ( ) {
let ua = window . navigator . userAgent ;
2022-12-20 12:32:32 +00:00
2022-09-14 14:26:41 +00:00
if ( ua . indexOf ( 'MSIE ' ) > 0 || ua . indexOf ( 'Trident/' ) > 0 ) {
return true ;
}
2022-09-06 11:52:18 +00:00
2022-09-14 14:26:41 +00:00
return false ;
} ,
2023-02-28 08:29:30 +00:00
onConfigButtonClick ( ) {
this . appConfigActive = true ;
2023-03-29 10:29:26 +00:00
} ,
onUpdateConfigActive ( ) {
this . appConfigActive = false ;
2023-10-14 19:53:46 +00:00
} ,
onDarkModeToggle ( ) {
let newTheme = null ;
let currentTheme = this . $appState . theme ;
if ( this . $appState . darkTheme ) {
newTheme = currentTheme . replace ( 'dark' , 'light' ) ;
} else {
2024-01-18 09:56:05 +00:00
if ( currentTheme . includes ( 'light' ) ) newTheme = currentTheme . replace ( 'light' , 'dark' ) ;
2024-01-18 03:51:37 +00:00
else newTheme = 'aura-dark-green' ; //fallback
2023-10-14 19:53:46 +00:00
}
EventBus . emit ( 'theme-change' , { theme : newTheme , dark : ! this . $appState . darkTheme } ) ;
2022-09-14 14:26:41 +00:00
}
} ,
computed : {
containerClass ( ) {
return [
{
'layout-news-active' : this . $appState . newsActive ,
2024-01-19 21:35:05 +00:00
'p-ripple-disabled' : this . $appState . ripple === false ,
2023-10-10 08:38:49 +00:00
'layout-dark' : this . $appState . darkTheme ,
'layout-light' : ! this . $appState . darkTheme
2022-09-14 14:26:41 +00:00
}
] ;
}
} ,
components : {
2023-10-10 08:38:49 +00:00
AppTopBar ,
AppMenu ,
AppFooter ,
AppConfigurator ,
AppNews
2022-09-14 14:26:41 +00:00
}
} ;
2022-09-06 11:52:18 +00:00
< / script >