From 05a20ff94e653750f0a10cac4dbfbf40371654fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=98=99=E2=97=A6=20The=20Tablet=20=E2=9D=80=20GamerGirla?= =?UTF-8?q?ndCo=20=E2=97=A6=E2=9D=A7?= Date: Sat, 20 Apr 2024 20:56:47 -0400 Subject: [PATCH] fix(pages, components): fix inconsistent theme when logging in/out manually set body's `data-theme` attribute to the appropriate value --- pages/auth/login.vue | 15 +++++++-------- pages/auth/logout.vue | 3 +++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/pages/auth/login.vue b/pages/auth/login.vue index 2d9a612..326079f 100644 --- a/pages/auth/login.vue +++ b/pages/auth/login.vue @@ -17,17 +17,16 @@ username: "", password: "", }); - + const darkRef = inject>("dark"); const onFinish = async (values: any) => { - const { signIn, data } = useAuth(); + const { signIn } = useAuth(); - let reso: any; try { - reso = await signIn(values); - - await navigateTo({ - path: "/", - }); + await signIn(values, { redirect: true, callbackUrl: "/" }); + const { data } = useAuth(); + darkRef.value = data.value.user.profile.nightMode; + if (darkRef.value) document.body.dataset.theme = "dark"; + await navigateTo(); } catch (e: any) { if (e.data) { notification["error"]({ diff --git a/pages/auth/logout.vue b/pages/auth/logout.vue index 703d9b4..01a1949 100644 --- a/pages/auth/logout.vue +++ b/pages/auth/logout.vue @@ -6,6 +6,9 @@ signOut({ callbackUrl: "/", }); + const d = inject>("dark"); + d.value = false; + document.body.dataset.theme = undefined;