web: implement localstorage

This commit is contained in:
Mika 2024-07-09 11:36:53 +02:00
parent e6151e09b1
commit 1f6caa8178

View file

@ -1,8 +1,15 @@
import { reactive } from 'vue';
export const store = reactive<{token: string | null, setToken: (token: string | null) => void}>({
token: null,
setToken: (token: string | null) => store.token = token
token: localStorage.getItem('token') || null,
setToken: (token: string | null) => {
store.token = token
if (token) {
localStorage.setItem('token', token)
} else{
localStorage.removeItem('token')
}
}
});