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

@@ -54,6 +54,7 @@ import { useUserStore } from './userStore';
import { useRoute } from 'vue-router';
import { Dark } from 'quasar';
import { useLogin } from './useLogin';
import { setLocalDarkMode, setLocalLanguage } from 'src/localstorage/localStorage';
const userLogin = useLogin();
const route = useRoute();
@@ -81,7 +82,7 @@ const loginText = computed(() => {
//switch between dark and light mode and save it in localStorage
function toggleDarkMode() {
Dark.toggle();
localStorage.setItem('mode', String(Dark.mode));
setLocalDarkMode();
}
// opens login page if no user is logged in otherwise it serves as logout
@@ -99,6 +100,7 @@ const langSelection = ref(lang);
// Watch for changes and update i18n locale
watch(langSelected, (newLang) => {
i18n.global.locale = newLang;
localStorage.setItem('lang', newLang);
setLocalLanguage(newLang);
});
</script>