From c45a19f1e534fb519f1cbc1c50800b61fdda9ba1 Mon Sep 17 00:00:00 2001 From: ssongliu Date: Mon, 6 Mar 2023 09:26:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=99=BB=E5=BD=95=E9=A1=B5=E3=80=81?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E8=B7=AF=E7=94=B1=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/api/helper/check-status.ts | 2 +- frontend/src/api/index.ts | 4 ++-- frontend/src/config/config.ts | 2 +- frontend/src/routers/index.ts | 2 +- frontend/src/routers/modules/app-store.ts | 4 ++++ frontend/src/routers/modules/container.ts | 9 +++++++++ frontend/src/routers/modules/cronjob.ts | 4 +++- frontend/src/routers/modules/database.ts | 2 ++ frontend/src/routers/modules/host.ts | 3 +++ frontend/src/routers/modules/log.ts | 3 +++ frontend/src/routers/modules/website.ts | 3 +++ frontend/src/routers/router.ts | 11 +++++++---- frontend/src/store/modules/menu.ts | 2 +- frontend/src/views/home/index.vue | 2 +- frontend/src/views/host/terminal/host/index.vue | 11 +++++------ 15 files changed, 46 insertions(+), 18 deletions(-) diff --git a/frontend/src/api/helper/check-status.ts b/frontend/src/api/helper/check-status.ts index 4c66922ae..514ba4126 100644 --- a/frontend/src/api/helper/check-status.ts +++ b/frontend/src/api/helper/check-status.ts @@ -11,7 +11,7 @@ export const checkStatus = (status: number, msg: string): void => { MsgError(msg ? msg : i18n.global.t('commons.res.notFound')); break; case 403: - router.replace({ path: '/' }); + router.replace({ path: '/login' }); MsgError(msg ? msg : i18n.global.t('commons.res.forbidden')); break; case 500: diff --git a/frontend/src/api/index.ts b/frontend/src/api/index.ts index bc47ae3a8..493b83813 100644 --- a/frontend/src/api/index.ts +++ b/frontend/src/api/index.ts @@ -44,13 +44,13 @@ class RequestHttp { } if (data.code == ResultEnum.OVERDUE || data.code == ResultEnum.FORBIDDEN) { router.replace({ - path: '/', + path: '/login', }); return Promise.reject(data); } if (data.code == ResultEnum.UNSAFETY) { router.replace({ - path: '/', + path: '/login', }); return data; } diff --git a/frontend/src/config/config.ts b/frontend/src/config/config.ts index 2702b36bc..0c8e5c320 100644 --- a/frontend/src/config/config.ts +++ b/frontend/src/config/config.ts @@ -1,4 +1,4 @@ // ? 全局不动配置项 只做导出不做修改 // * 首页地址(默认) -export const HOME_URL: string = '/home'; +export const HOME_URL: string = '/'; diff --git a/frontend/src/routers/index.ts b/frontend/src/routers/index.ts index 973cd294f..24ea87862 100644 --- a/frontend/src/routers/index.ts +++ b/frontend/src/routers/index.ts @@ -17,7 +17,7 @@ router.beforeEach((to, from, next) => { const globalStore = GlobalStore(); if (!globalStore.isLogin) { next({ - path: '/', + path: '/login', }); NProgress.done(); return; diff --git a/frontend/src/routers/modules/app-store.ts b/frontend/src/routers/modules/app-store.ts index 9a99e1d43..0e78e50a8 100644 --- a/frontend/src/routers/modules/app-store.ts +++ b/frontend/src/routers/modules/app-store.ts @@ -25,6 +25,7 @@ const appStoreRouter = { hidden: true, meta: { activeMenu: '/apps', + requiresAuth: false, }, }, { @@ -35,6 +36,7 @@ const appStoreRouter = { hidden: true, meta: { activeMenu: '/apps', + requiresAuth: false, }, }, { @@ -45,6 +47,7 @@ const appStoreRouter = { hidden: true, meta: { activeMenu: '/apps', + requiresAuth: false, }, }, { @@ -55,6 +58,7 @@ const appStoreRouter = { hidden: true, meta: { activeMenu: '/apps', + requiresAuth: false, }, }, ], diff --git a/frontend/src/routers/modules/container.ts b/frontend/src/routers/modules/container.ts index 054267975..ff111e82f 100644 --- a/frontend/src/routers/modules/container.ts +++ b/frontend/src/routers/modules/container.ts @@ -25,6 +25,7 @@ const containerRouter = { hidden: true, meta: { activeMenu: '/containers', + requiresAuth: false, }, }, { @@ -35,6 +36,7 @@ const containerRouter = { hidden: true, meta: { activeMenu: '/containers', + requiresAuth: false, }, }, { @@ -44,6 +46,7 @@ const containerRouter = { hidden: true, meta: { activeMenu: '/containers', + requiresAuth: false, }, }, { @@ -53,6 +56,7 @@ const containerRouter = { hidden: true, meta: { activeMenu: '/containers', + requiresAuth: false, }, }, { @@ -62,6 +66,7 @@ const containerRouter = { hidden: true, meta: { activeMenu: '/containers', + requiresAuth: false, }, }, { @@ -71,6 +76,7 @@ const containerRouter = { hidden: true, meta: { activeMenu: '/containers', + requiresAuth: false, }, }, { @@ -80,6 +86,7 @@ const containerRouter = { hidden: true, meta: { activeMenu: '/containers', + requiresAuth: false, }, }, { @@ -89,6 +96,7 @@ const containerRouter = { hidden: true, meta: { activeMenu: '/containers', + requiresAuth: false, }, }, { @@ -98,6 +106,7 @@ const containerRouter = { hidden: true, meta: { activeMenu: '/containers', + requiresAuth: false, }, }, ], diff --git a/frontend/src/routers/modules/cronjob.ts b/frontend/src/routers/modules/cronjob.ts index 7d7e49e05..1a3912856 100644 --- a/frontend/src/routers/modules/cronjob.ts +++ b/frontend/src/routers/modules/cronjob.ts @@ -14,7 +14,9 @@ const cronRouter = { path: '/cronjobs', name: 'Cronjob', component: () => import('@/views/cronjob/index.vue'), - meta: {}, + meta: { + requiresAuth: false, + }, }, ], }; diff --git a/frontend/src/routers/modules/database.ts b/frontend/src/routers/modules/database.ts index 0de2d158d..d46f46c24 100644 --- a/frontend/src/routers/modules/database.ts +++ b/frontend/src/routers/modules/database.ts @@ -24,6 +24,7 @@ const databaseRouter = { hidden: true, meta: { activeMenu: '/databases', + requiresAuth: false, }, }, { @@ -33,6 +34,7 @@ const databaseRouter = { hidden: true, meta: { activeMenu: '/databases', + requiresAuth: false, }, }, ], diff --git a/frontend/src/routers/modules/host.ts b/frontend/src/routers/modules/host.ts index fabc5030d..8ca957b7d 100644 --- a/frontend/src/routers/modules/host.ts +++ b/frontend/src/routers/modules/host.ts @@ -17,6 +17,7 @@ const hostRouter = { component: () => import('@/views/host/file-management/index.vue'), meta: { title: 'menu.files', + requiresAuth: false, }, }, { @@ -25,6 +26,7 @@ const hostRouter = { component: () => import('@/views/host/monitor/index.vue'), meta: { title: 'menu.monitor', + requiresAuth: false, }, }, { @@ -34,6 +36,7 @@ const hostRouter = { meta: { title: 'menu.terminal', keepAlive: true, + requiresAuth: false, }, }, ], diff --git a/frontend/src/routers/modules/log.ts b/frontend/src/routers/modules/log.ts index e60b74478..1552d89f4 100644 --- a/frontend/src/routers/modules/log.ts +++ b/frontend/src/routers/modules/log.ts @@ -24,6 +24,7 @@ const logsRouter = { hidden: true, meta: { activeMenu: '/logs', + requiresAuth: false, }, }, { @@ -33,6 +34,7 @@ const logsRouter = { hidden: true, meta: { activeMenu: '/logs', + requiresAuth: false, }, }, { @@ -42,6 +44,7 @@ const logsRouter = { hidden: true, meta: { activeMenu: '/logs', + requiresAuth: false, }, }, ], diff --git a/frontend/src/routers/modules/website.ts b/frontend/src/routers/modules/website.ts index 3fbd22875..967aa2386 100644 --- a/frontend/src/routers/modules/website.ts +++ b/frontend/src/routers/modules/website.ts @@ -16,6 +16,7 @@ const webSiteRouter = { component: () => import('@/views/website/website/index.vue'), meta: { title: 'menu.website', + requiresAuth: false, }, }, { @@ -26,6 +27,7 @@ const webSiteRouter = { props: true, meta: { activeMenu: '/websites', + requiresAuth: false, }, }, { @@ -34,6 +36,7 @@ const webSiteRouter = { component: () => import('@/views/website/ssl/index.vue'), meta: { title: 'menu.ssl', + requiresAuth: false, }, }, ], diff --git a/frontend/src/routers/router.ts b/frontend/src/routers/router.ts index 8946da5df..a48425caf 100644 --- a/frontend/src/routers/router.ts +++ b/frontend/src/routers/router.ts @@ -4,9 +4,9 @@ import { Layout } from '@/routers/constant'; const modules = import.meta.globEager('./modules/*.ts'); const homeRouter: RouteRecordRaw = { - path: '/home', + path: '/', component: Layout, - redirect: '/home', + redirect: '/', meta: { keepAlive: true, title: 'menu.home', @@ -14,9 +14,12 @@ const homeRouter: RouteRecordRaw = { }, children: [ { - path: '/home', + path: '/', name: 'home', component: () => import('@/views/home/index.vue'), + meta: { + requiresAuth: true, + }, }, ], }; @@ -55,7 +58,7 @@ menuList.unshift(homeRouter); export const routes: RouteRecordRaw[] = [ homeRouter, { - path: '/', + path: '/login', name: 'login', props: true, component: () => import('@/views/login/index.vue'), diff --git a/frontend/src/store/modules/menu.ts b/frontend/src/store/modules/menu.ts index be618ced4..258af1cd0 100644 --- a/frontend/src/store/modules/menu.ts +++ b/frontend/src/store/modules/menu.ts @@ -2,7 +2,7 @@ import { defineStore } from 'pinia'; import { MenuState } from '../interface'; import piniaPersistConfig from '@/config/pinia-persist'; import { RouteRecordRaw } from 'vue-router'; -const whiteList = ['/', '/error']; +const whiteList = ['/login', '/error']; export const MenuStore = defineStore({ id: 'MenuState', diff --git a/frontend/src/views/home/index.vue b/frontend/src/views/home/index.vue index 256109c10..70e3f7590 100644 --- a/frontend/src/views/home/index.vue +++ b/frontend/src/views/home/index.vue @@ -4,7 +4,7 @@ :buttons="[ { label: i18n.global.t('menu.home'), - path: '/home', + path: '/', }, ]" /> diff --git a/frontend/src/views/host/terminal/host/index.vue b/frontend/src/views/host/terminal/host/index.vue index 9b599451f..8f3489470 100644 --- a/frontend/src/views/host/terminal/host/index.vue +++ b/frontend/src/views/host/terminal/host/index.vue @@ -43,17 +43,16 @@ @search="search" > - + + + + + - - - - -