From d2a9027869f6b3156038c5eaa9a1a2d8b088b1d8 Mon Sep 17 00:00:00 2001 From: ko1234 Date: Wed, 16 Oct 2024 15:28:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=93=E6=9F=B1=E9=AB=94chart=20|=20?= =?UTF-8?q?=E7=B3=BB=E7=B5=B1=E7=9B=A3=E6=8E=A7=E7=9A=84menu=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=A4=A7=E9=A1=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/navbar/Navbar.vue | 9 +- src/components/navbar/NavbarItem.vue | 104 +++++--- src/router/index.js | 17 +- .../components/DashboardElecChart.vue | 251 +++++++++++------- 4 files changed, 237 insertions(+), 144 deletions(-) diff --git a/src/components/navbar/Navbar.vue b/src/components/navbar/Navbar.vue index 40b01d8..5eb539b 100644 --- a/src/components/navbar/Navbar.vue +++ b/src/components/navbar/Navbar.vue @@ -92,10 +92,11 @@ const src = import.meta.env.MODE === "production" ? "./logo.svg" : Logo; class="dropdown-content translate-y-2 z-[100] menu py-3 shadow rounded w-32 bg-[#4c625e] border text-center" >
  • - {{ $t("sign_out") }}{{ $t("sign_out") }}
  • @@ -108,7 +109,7 @@ const src = import.meta.env.MODE === "production" ? "./logo.svg" : Logo; diff --git a/src/router/index.js b/src/router/index.js index a272662..cdd85f8 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -94,6 +94,16 @@ const router = createRouter({ name: "mytestfile", component: Test, }, + { + path: "/logout", + name: "logout", + beforeEnter: (to, from, next) => { + const auth = useUserInfoStore(); + document.cookie = "JWT-Authorization="; + auth.user.token = ""; + next({ path: "/login", replace: true }); + }, + }, ], }); @@ -105,13 +115,6 @@ router.beforeEach(async (to, from, next) => { const auth = useUserInfoStore(); const token = useGetCookie("JWT-Authorization"); - if (location.pathname.includes("logoutConfirm")) { - document.cookie = "JWT-Authorization="; - auth.user.token = ""; - // 清除 cookie token - next({ path: "/login" }); - } - if ((authRequired && !token) || to.path === "/") { auth.user.token = ""; next({ path: "/login" }); diff --git a/src/views/dashboard/components/DashboardElecChart.vue b/src/views/dashboard/components/DashboardElecChart.vue index 11ab187..201fd97 100644 --- a/src/views/dashboard/components/DashboardElecChart.vue +++ b/src/views/dashboard/components/DashboardElecChart.vue @@ -1,112 +1,171 @@