From 0658c9e5fb7c0adc199d7513ff7fa24b38aa3cfc Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 6 Nov 2025 16:09:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20base=20=E8=B7=B3=E8=BD=AC=E5=89=8Dcheck?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/index.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index 07572a2..dc1c1ac 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,5 +1,6 @@ import { createRouter, createWebHistory} from 'vue-router'; import { authToken } from '@/store/index.js' +import http from "@/api/request.js"; const routes = [ { path: "/", redirect: "/login" }, { @@ -54,7 +55,7 @@ const router = createRouter({ routes, }); -router.beforeEach((to, from, next) => { +router.beforeEach(async (to, from, next) => { if (to.path === "/login") { if (authToken.access) { next("/home"); @@ -63,7 +64,14 @@ router.beforeEach((to, from, next) => { } } else { if (authToken.access) { - next(); + try{ + await http.get("/check_token/") + next(); + } catch(e){ + authToken.access = null; + authToken.refresh = null; + next("/login"); + } } else { next("/login"); }