diff --git a/web/src/store.ts b/web/src/store.ts index 3a96218..44bf972 100644 --- a/web/src/store.ts +++ b/web/src/store.ts @@ -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') + } + } });