From 9d718e1af657fcc42642b544a7e6cc1a6e712817 Mon Sep 17 00:00:00 2001 From: zhaozhenfang Date: Fri, 21 Jun 2024 16:18:22 +0800 Subject: [PATCH] frontend: fix blank issue when refresh plugin page --- frontend/src/router/index.ts | 35 +++++++++++++++++++---------------- frontend/src/styles/main.scss | 4 +++- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts index bf47cfd2..d5da661e 100644 --- a/frontend/src/router/index.ts +++ b/frontend/src/router/index.ts @@ -206,12 +206,8 @@ export default router; import { routerStore, type Menu } from '@/stores/router'; import { iframeComponents } from "@/views/Plugin/plugin"; -import PluginFrame from "@/views/Plugin/PluginFrame.vue"; -import { app } from "@/main"; -import { useRouter } from "vue-router"; import { hasPermisson } from '@/module/permission'; -import { userStore } from '@/stores/user'; import { getToken } from "@/module/cookie"; export function updateSidebarItems() { @@ -356,20 +352,27 @@ router.beforeEach((to, from, next) => { if (getToken()) { // 已登录 if (to.path.includes('plugin-')) { - // 解决在插件页面一刷新页面空白问题 - if (!router.hasRoute(to.fullPath)) { - new Promise(async (resolve, rejection) => { - await routerStore().routers.forEach((route: any) => { - addPluginRoute(route); - }) - resolve('addRoute success'); - }).then(res => { - console.log(router.getRoutes()) - next({ ...to, replace: true }) + // 解决在插件页面一刷新页面空白问题 + let paths = [] as any; + router.getRoutes().forEach(routeItem => { + paths.push(routeItem.path); }) + if (paths.includes(to.path)) { + next(); + } else { + new Promise(async (resolve, rejection) => { + await routerStore().routers.forEach((route: any) => { + addPluginRoute(route); + }) + resolve('addRoute success'); + }).then(res => { + next({ ...to, replace: true }) + }) } - } - next() + } else { + next() + } + } else { // 未登录 if (whiteList.indexOf(to.path) !== -1) { diff --git a/frontend/src/styles/main.scss b/frontend/src/styles/main.scss index bdc067ff..65ad645e 100644 --- a/frontend/src/styles/main.scss +++ b/frontend/src/styles/main.scss @@ -3,9 +3,11 @@ html { height: 100%; width: 100%; - box-sizing: border-box; min-width: 1440px; } +* { + box-sizing: border-box; +} body { height: 100%; -- Gitee