From 852a715722fe6156acd9109d2edb87ea99033fa5 Mon Sep 17 00:00:00 2001 From: xiaowang <2161656029@qq.com> Date: Fri, 4 Sep 2026 16:21:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BD=91=E9=A1=B5=E7=AB=AF?= =?UTF-8?q?=E6=9C=AA=E7=9F=A5=E8=B7=AF=E5=BE=84=E8=B7=B3=E8=BD=AC=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- JC-Salon-Frontend/src/router/index.ts | 3 ++- JC-Salon-Frontend/src/views/NotFoundView.vue | 20 ++++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/JC-Salon-Frontend/src/router/index.ts b/JC-Salon-Frontend/src/router/index.ts index 7726cda6..4670683b 100644 --- a/JC-Salon-Frontend/src/router/index.ts +++ b/JC-Salon-Frontend/src/router/index.ts @@ -14,6 +14,7 @@ const pageNames = [ ] as const const routes = [ + { path: '/', redirect: '/admin' }, { path: '/admin/login', name: 'admin-login', component: () => import('../views/admin/AdminLoginView.vue'), meta: { requiresAuth: false, isAdmin: true, hideNav: true } }, { path: '/admin', component: () => import('../views/admin/AdminLayout.vue'), meta: { requiresAuth: true, isAdmin: true, hideNav: true }, @@ -21,7 +22,7 @@ const routes = [ path, name, component: () => import(`../views/admin/${view}.vue`), meta: { requiresAuth: true, isAdmin: true, hideNav: true, permissionCode } })) }, - { path: '/:pathMatch(.*)*', name: 'not-found', component: () => import('../views/NotFoundView.vue'), meta: { requiresAuth: false, isAdmin: true, hideNav: true } } + { path: '/:pathMatch(.*)*', name: 'not-found', component: () => import('../views/NotFoundView.vue'), meta: { requiresAuth: false, isAdmin: false, hideNav: true } } ] const router = createRouter({ history: createWebHistory(import.meta.env.BASE_URL), routes }) diff --git a/JC-Salon-Frontend/src/views/NotFoundView.vue b/JC-Salon-Frontend/src/views/NotFoundView.vue index 49a083ed..da138b88 100644 --- a/JC-Salon-Frontend/src/views/NotFoundView.vue +++ b/JC-Salon-Frontend/src/views/NotFoundView.vue @@ -12,11 +12,11 @@ {{ BRAND_CONFIG.appName }}
404

这页去做护理了

-

您访问的页面不存在或已被删除,我们带您回到首页继续浏览作品。

+

您访问的页面不存在或已被删除,我们将在 5 秒后返回上一页。

- 将在 {{ countdown }} 秒后自动跳转到首页... + 将在 {{ countdown }} 秒后返回上一页...

- 立即前往首页 + 返回上一页 @@ -53,16 +53,20 @@ const handleBackClick = () => { router.back() return } - router.push('/home') + router.replace('/admin/login') } -/** redirectToHome is a local helper used by this page script. */ -const redirectToHome = () => { +/** redirectToLogin 将无历史来源的访问导回管理端登录页。 */ +const redirectToLogin = () => { clearRedirectTimer() - router.push('/home') + router.replace('/admin/login') } onMounted(() => { + if (window.history.length <= 1) { + redirectToLogin() + return + } timer = window.setInterval(() => { if (countdown.value > 0) { countdown.value-- @@ -70,7 +74,7 @@ onMounted(() => { if (timer) { clearInterval(timer) } - redirectToHome() + handleBackClick() } }, 1000) })