forked from dyf/dyf-vue-ui
数据大屏跳转到新标签页,已修改
This commit is contained in:
@ -1,13 +1,16 @@
|
||||
<template>
|
||||
<div v-if="!item.hidden">
|
||||
<template v-if="hasOneShowingChild(item, item.children) && (!onlyOneChild.children || onlyOneChild.noShowingChildren) && !item.alwaysShow">
|
||||
<template
|
||||
v-if="hasOneShowingChild(item, item.children) && (!onlyOneChild.children || onlyOneChild.noShowingChildren) && !item.alwaysShow">
|
||||
<app-link v-if="onlyOneChild.meta" :to="resolvePath(onlyOneChild.path, onlyOneChild.query)">
|
||||
<span @click="handleMenuClick(onlyOneChild, $event)">
|
||||
<el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{ 'submenu-title-noDropdown': !isNest }">
|
||||
<svg-icon :icon-class="onlyOneChild.meta.icon || (item.meta && item.meta.icon)" />
|
||||
<template #title>
|
||||
<span class="menu-title" :title="hasTitle(onlyOneChild.meta.title)">{{ onlyOneChild.meta.title }}</span>
|
||||
</template>
|
||||
</el-menu-item>
|
||||
</span>
|
||||
</app-link>
|
||||
</template>
|
||||
|
||||
@ -17,14 +20,8 @@
|
||||
<span class="menu-title" :title="hasTitle(item.meta?.title)">{{ item.meta?.title }}</span>
|
||||
</template>
|
||||
|
||||
<sidebar-item
|
||||
v-for="(child, index) in item.children"
|
||||
:key="child.path + index"
|
||||
:is-nest="true"
|
||||
:item="child"
|
||||
:base-path="resolvePath(child.path)"
|
||||
class="nest-menu"
|
||||
/>
|
||||
<sidebar-item v-for="(child, index) in item.children" :key="child.path + index" :is-nest="true" :item="child"
|
||||
:base-path="resolvePath(child.path)" class="nest-menu" />
|
||||
</el-sub-menu>
|
||||
</div>
|
||||
</template>
|
||||
@ -77,7 +74,23 @@ 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)) {
|
||||
|
||||
@ -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 }
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user