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 AppDocumentation from './AppDocumentation';
import CodeHighlight from './AppCodeHighlight'; import CodeHighlight from './AppCodeHighlight';
import EventBus from '@/AppEventBus';
import './assets/styles/primevue.css'; import './assets/styles/primevue.css';
import 'primeflex/primeflex.css'; import 'primeflex/primeflex.css';
import 'primeicons/primeicons.css'; import 'primeicons/primeicons.css';
@ -112,7 +114,10 @@ import 'prismjs/themes/prism-coy.css';
import './assets/styles/flags.css'; import './assets/styles/flags.css';
router.beforeEach(function (to, from, next) { 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(); next();
}); });

View File

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