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 @@