fix: 无参数打开页签is-active样式问题

This commit is contained in:
hb0730 2024-03-27 11:06:45 +08:00
parent fbacf8e85e
commit 4190e8411a
5 changed files with 51 additions and 4 deletions

View File

@ -277,6 +277,16 @@ const tabsRouter = {
roles: ["admin", "common"] roles: ["admin", "common"]
} }
}, },
{
path: "/tabs/no-parameter-detail",
name: "TabNoParameterDetail",
meta: {
// 不在menu菜单中显示
showLink: false,
activePath: "/tabs/index",
roles: ["admin", "common"]
}
},
// query 传参模式 // query 传参模式
{ {
path: "/tabs/query-detail", path: "/tabs/query-detail",

View File

@ -117,8 +117,10 @@ export function useTags() {
if (isBoolean(route?.meta?.showLink) && route?.meta?.showLink === false) { if (isBoolean(route?.meta?.showLink) && route?.meta?.showLink === false) {
if (Object.keys(route.query).length > 0) { if (Object.keys(route.query).length > 0) {
return isEqual(route.query, item.query) ? previous : next; return isEqual(route.query, item.query) ? previous : next;
} else { } else if (Object.keys(route.params).length > 0) {
return isEqual(route.params, item.params) ? previous : next; return isEqual(route.params, item.params) ? previous : next;
} else {
return route.path === item.path ? previous : next;
} }
} else { } else {
return route.path === item.path ? previous : next; return route.path === item.path ? previous : next;

View File

@ -59,11 +59,30 @@ export function useDetail() {
router.push({ name: "TabParamsDetail", params: parameter }); router.push({ name: "TabParamsDetail", params: parameter });
} }
} }
function toDetailNoParameter() {
// 保存信息到标签页
useMultiTagsStoreHook().handleTags("push", {
path: `/tabs/no-parameter-detail`,
name: "TabNoParameterDetail",
meta: {
title: {
zh: `无参数 - 详情信息`,
en: `no parameter - DetailInfo`
},
// 如果使用的是非国际化精简版title可以像下面这么写
// title: `No.${index} - 详情信息`,
// 最大打开标签数
dynamicLevel: 3
}
});
// 路由跳转
router.push({ name: "TabNoParameterDetail" });
}
// 用于页面刷新,重新获取浏览器地址栏参数并保存到标签页 // 用于页面刷新,重新获取浏览器地址栏参数并保存到标签页
const initToDetail = (model: "query" | "params") => { const initToDetail = (model: "query" | "params") => {
if (getParameter) toDetail(getParameter, model); if (getParameter) toDetail(getParameter, model);
}; };
return { toDetail, initToDetail, getParameter, router }; return { toDetail, toDetailNoParameter, initToDetail, getParameter, router };
} }

View File

@ -15,7 +15,7 @@ defineOptions({
name: "Tabs" name: "Tabs"
}); });
const { toDetail, router } = useDetail(); const { toDetail, toDetailNoParameter, router } = useDetail();
const menusTree = clone(usePermissionStoreHook().wholeMenus, true); const menusTree = clone(usePermissionStoreHook().wholeMenus, true);
const treeData = computed(() => { const treeData = computed(() => {
@ -58,6 +58,12 @@ function onCloseTags() {
</el-link> </el-link>
</template> </template>
<div class="flex flex-wrap items-center"> <div class="flex flex-wrap items-center">
<p>无参数</p>
<el-button class="m-2" @click="toDetailNoParameter()">
无参模式
</el-button>
<el-divider />
<p>query传参模式</p> <p>query传参模式</p>
<el-button <el-button
v-for="index in 6" v-for="index in 6"
@ -155,7 +161,6 @@ function onCloseTags() {
> >
点击查看更多跳转方式 点击查看更多跳转方式
</el-link> </el-link>
<el-divider /> <el-divider />
<el-button @click="router.push({ name: 'Empty' })"> <el-button @click="router.push({ name: 'Empty' })">
跳转无Layout的空白页面 跳转无Layout的空白页面

View File

@ -0,0 +1,11 @@
<script setup lang="ts">
defineOptions({
name: "TabNoParameterDetail"
});
</script>
<template>
<div>
<p>无参数页面</p>
</div>
</template>