Default to Lara when navigation to home
parent
ff7b4e8eac
commit
0e1712ebbe
|
@ -105,6 +105,8 @@ import AppDemoActions from './AppDemoActions';
|
|||
import AppDocumentation from './AppDocumentation';
|
||||
import CodeHighlight from './AppCodeHighlight';
|
||||
|
||||
import EventBus from '@/AppEventBus';
|
||||
|
||||
import './assets/styles/primevue.css';
|
||||
import 'primeflex/primeflex.css';
|
||||
import 'primeicons/primeicons.css';
|
||||
|
@ -112,7 +114,10 @@ import 'prismjs/themes/prism-coy.css';
|
|||
import './assets/styles/flags.css';
|
||||
|
||||
router.beforeEach(function (to, from, next) {
|
||||
window.scrollTo(0, 0);
|
||||
if (to.name === 'home' && from.name) {
|
||||
const newTheme = app.config.globalProperties.$appState.darkTheme ? 'lara-dark-indigo' : 'lara-light-indigo';
|
||||
EventBus.emit('theme-change', { theme: newTheme, dark: app.config.globalProperties.$appState.darkTheme });
|
||||
}
|
||||
next();
|
||||
});
|
||||
|
||||
|
|
|
@ -840,8 +840,11 @@ const routes = [
|
|||
const router = createRouter({
|
||||
history: createWebHashHistory(),
|
||||
routes,
|
||||
scrollBehavior () {
|
||||
return { left: 0, top: 0 };
|
||||
scrollBehavior (to, from, savedPosition) {
|
||||
if (savedPosition)
|
||||
return savedPosition
|
||||
else
|
||||
return { left: 0, top: 0 };
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue