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 } } ] },