From 53006a66a9e72f210969f6293627ab407bbfda0c Mon Sep 17 00:00:00 2001 From: lihuilin Date: Wed, 23 Jul 2025 11:47:52 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=80=E5=87=BA=E7=99=BB=E5=BD=95=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- activitylink/src/router/index.js | 11 ++- activitylink/src/views/zhongchou/index.vue | 134 +++++++++++++++-------------- 2 files changed, 80 insertions(+), 65 deletions(-) diff --git a/activitylink/src/router/index.js b/activitylink/src/router/index.js index e95e914..0912049 100644 --- a/activitylink/src/router/index.js +++ b/activitylink/src/router/index.js @@ -1,3 +1,4 @@ +import { ElMessage } from 'element-plus'; import { createRouter, createWebHistory } from 'vue-router' const routes = [ { @@ -75,5 +76,13 @@ const router = createRouter({ history: createWebHistory('/testBack/'), routes }) -// 导出 +router.beforeEach((to, from, next) => { + const token = localStorage.getItem("token"); + if (to.name != "homePage" && !token) { + next('/homePage'); + ElMessage.error('请先登录!'); + } + next(); +}) +// 暴露 export default router diff --git a/activitylink/src/views/zhongchou/index.vue b/activitylink/src/views/zhongchou/index.vue index c58431f..13223d2 100644 --- a/activitylink/src/views/zhongchou/index.vue +++ b/activitylink/src/views/zhongchou/index.vue @@ -1,4 +1,3 @@ -