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) })