Default to Lara when navigation to home

pull/2206/head
Cagatay Civici 2022-02-23 23:08:45 +03:00
parent ff7b4e8eac
commit 0e1712ebbe
2 changed files with 11 additions and 3 deletions

View File

@ -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();
});

View File

@ -840,7 +840,10 @@ const routes = [
const router = createRouter({
history: createWebHashHistory(),
routes,
scrollBehavior () {
scrollBehavior (to, from, savedPosition) {
if (savedPosition)
return savedPosition
else
return { left: 0, top: 0 };
}
});