import { ref, watch } from 'vue'; /** * Eine Ansichtswahl (z. B. Liste/Kacheln), die sich der Browser merkt. * Ohne Speicher (privates Fenster) gilt einfach der Standard. */ export function useStoredChoice(key, fallback, allowed) { let initial = fallback; try { const stored = window.localStorage.getItem(key); if (allowed.includes(stored)) initial = stored; } catch { // kein Speicher verfügbar } const choice = ref(initial); watch(choice, (value) => { try { window.localStorage.setItem(key, value); } catch { // kein Speicher verfügbar } }); return choice; }