make new localstorage function file

This commit is contained in:
Adrian Zürcher
2025-11-15 14:19:45 +01:00
parent 44f355a5ea
commit 7b17cd99fe
8 changed files with 128 additions and 56 deletions

View File

@@ -1,6 +1,7 @@
import { boot } from 'quasar/wrappers';
import { useUserStore } from 'src/vueLib/login/userStore';
import { appApi } from './axios';
import { getLocalLastRoute, setLocalLastRoute } from 'src/localstorage/localStorage';
export default boot(async ({ router }) => {
const userStore = useUserStore();
@@ -14,7 +15,7 @@ export default boot(async ({ router }) => {
// Restore logic after router is ready but before navigation
router.isReady().then(() => {
const lastRoute = localStorage.getItem('lastRoute');
const lastRoute = getLocalLastRoute();
const currentPath = router.currentRoute.value.fullPath;
// Restore only if:
@@ -34,7 +35,7 @@ export default boot(async ({ router }) => {
router.afterEach((to) => {
// Don't save login page as "last route"
if (to.path !== '/login' && to.path !== '/') {
localStorage.setItem('lastRoute', to.fullPath);
setLocalLastRoute(to.fullPath);
}
});
});