From 1f6caa817849defcbf96e19d870c18177936bd89 Mon Sep 17 00:00:00 2001 From: Mika Date: Tue, 9 Jul 2024 11:36:53 +0200 Subject: [PATCH] web: implement localstorage --- web/src/store.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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') + } + } });