Skip to content

Commit

Permalink
fix: 修复配置路由属性fixedTagfalse后当前标签页不可关闭的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoxian521 committed Jun 12, 2024
1 parent 933ced4 commit 47afa92
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/layout/components/lay-tag/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const {
buttonLeft,
showModel,
translateX,
isFixedTag,
pureSetting,
activeIndex,
getTabStyle,
Expand Down Expand Up @@ -578,7 +579,7 @@ onBeforeUnmount(() => {
'scroll-item is-closable',
linkIsActive(item),
showModel === 'chrome' && 'chrome-item',
!isAllEmpty(item?.meta?.fixedTag) && 'fixed-tag'
isFixedTag(item) && 'fixed-tag'
]"
@contextmenu.prevent="openMenu(item, $event)"
@mouseenter.prevent="onMouseenter(index)"
Expand All @@ -593,10 +594,10 @@ onBeforeUnmount(() => {
</span>
<span
v-if="
isAllEmpty(item?.meta?.fixedTag)
? iconIsActive(item, index) ||
isFixedTag(item)
? false
: iconIsActive(item, index) ||
(index === activeIndex && index !== 0)
: false
"
class="el-icon-close"
@click.stop="deleteMenu(item)"
Expand All @@ -617,7 +618,7 @@ onBeforeUnmount(() => {
{{ transformI18n(item.meta.title) }}
</span>
<span
v-if="isAllEmpty(item?.meta?.fixedTag) ? index !== 0 : false"
v-if="isFixedTag(item) ? false : index !== 0"
class="chrome-close-btn"
@click.stop="deleteMenu(item)"
>
Expand Down
7 changes: 7 additions & 0 deletions src/layout/hooks/useTag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ export function useTags() {
}
}

const isFixedTag = computed(() => {
return item => {
return isBoolean(item?.meta?.fixedTag) && item?.meta?.fixedTag === true;
};
});

const iconIsActive = computed(() => {
return (item, index) => {
if (index === 0) return;
Expand Down Expand Up @@ -221,6 +227,7 @@ export function useTags() {
buttonTop,
buttonLeft,
translateX,
isFixedTag,
pureSetting,
activeIndex,
getTabStyle,
Expand Down

0 comments on commit 47afa92

Please sign in to comment.