From ee4eec1e2e1e87f7f69b2d0730e77b7b1e304b50 Mon Sep 17 00:00:00 2001 From: fengerli <528575642@qq.com> Date: Fri, 10 Oct 2025 11:41:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=A4=A7=E5=B1=8F=E8=B7=B3?= =?UTF-8?q?=E8=BD=AC=E5=88=B0=E6=96=B0=E6=A0=87=E7=AD=BE=E9=A1=B5=EF=BC=8C?= =?UTF-8?q?=E5=B7=B2=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/components/Sidebar/SidebarItem.vue | 47 ++++++++++++------- src/router/index.ts | 4 +- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/layout/components/Sidebar/SidebarItem.vue b/src/layout/components/Sidebar/SidebarItem.vue index 5d12355..2f14209 100644 --- a/src/layout/components/Sidebar/SidebarItem.vue +++ b/src/layout/components/Sidebar/SidebarItem.vue @@ -1,13 +1,16 @@ @@ -77,9 +74,25 @@ const hasOneShowingChild = (parent: RouteRecordRaw, children?: RouteRecordRaw[]) return false; }; - +const router = useRouter(); +// 处理菜单点击,完全控制跳转行为 +const handleMenuClick = (route, event) => { + console.log(route, 'route'); + if (route.meta.openInNewTab) { + // 完全阻止默认行为和事件冒泡 + event.preventDefault(); + event.stopPropagation(); + console.log('Opening in new tab:', route); + const resolvedRoute = router.resolve({ + name: route.name || route.path + }); + const fullUrl = new URL(resolvedRoute.href, window.location.origin).href; + window.open(fullUrl, '_blank'); + } else { + } +}; const resolvePath = (routePath: string, routeQuery?: string): any => { - + if (isExternal(routePath)) { return routePath; } diff --git a/src/router/index.ts b/src/router/index.ts index b6ad076..a292631 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -43,7 +43,7 @@ export const constantRoutes: RouteRecordRaw[] = [ path: "/homeIndex", name: "HomeIndex", component: () => import("@/views/homeIndex/index.vue"), - meta: {title: '数据大屏', icon: 'home', preload: true, keepAlive: true }, + meta: { title: '数据大屏', icon: '首页1.1', preload: true, keepAlive: true, openInNewTab: true }, }, { path: '', @@ -54,7 +54,7 @@ export const constantRoutes: RouteRecordRaw[] = [ path: '/index', component: () => import('@/views/index.vue'), name: 'Index', - meta: { title: '首页', icon: 'home', affix: true, keepAlive: false } + meta: { title: '首页', icon: '首页1.1', affix: true, keepAlive: false } } ] },