review code.

This commit is contained in:
lijiahang
2023-12-01 17:29:42 +08:00
parent 351669a4f3
commit e8d99cb263
21 changed files with 235 additions and 132 deletions

View File

@@ -4,12 +4,10 @@
<div class="tab-bar-box">
<div class="tab-bar-scroll">
<div class="tags-wrap">
<TabItem
v-for="(tag, index) in tagList"
:key="tag.fullPath"
:index="index"
:item-data="tag"
/>
<TabItem v-for="(tag, index) in tagList"
:key="tag.fullPath"
:index="index"
:item-data="tag" />
</div>
</div>
<div class="tag-bar-operation"></div>
@@ -48,7 +46,7 @@
listenerRouteChange((route: RouteLocationNormalized) => {
if (
!route.meta.noAffix &&
!tagList.value.some((tag) => tag.fullPath === route.fullPath)
!tagList.value.some((tag) => tag.path === route.path)
) {
// 固定并且没有此 tab 则添加
tabBarStore.addTab(routerToTag(route), route.meta?.ignoreCache as unknown as boolean);

View File

@@ -1,18 +1,15 @@
<template>
<a-dropdown
trigger="contextMenu"
:popup-max-height="false"
@select="actionSelect">
<span
class="arco-tag arco-tag-size-medium arco-tag-checked"
:class="{ 'link-activated': itemData?.fullPath === $route.fullPath }"
@click="goto(itemData as TagProps)">
<a-dropdown trigger="contextMenu"
:popup-max-height="false"
@select="actionSelect">
<span class="arco-tag arco-tag-size-medium arco-tag-checked"
:class="{ 'link-activated': itemData?.path === $route.path }"
@click="goto(itemData as TagProps)">
<span class="tag-link">
{{ itemData.title }}
</span>
<span
class="arco-icon-hover arco-tag-icon-hover arco-icon-hover-size-medium arco-tag-close-btn"
@click.stop="tagClose(itemData as TagProps, index)">
<span class="arco-icon-hover arco-tag-icon-hover arco-icon-hover-size-medium arco-tag-close-btn"
@click.stop="tagClose(itemData as TagProps, index)">
<icon-close />
</span>
</span>
@@ -91,7 +88,7 @@
});
const disabledReload = computed(() => {
return props.itemData.fullPath !== route.fullPath;
return props.itemData.path !== route.path;
});
const disabledCurrent = computed(() => {
@@ -106,22 +103,22 @@
return props.index === tagList.value.length - 1;
});
/**
* 关闭 tag
*/
// 关闭 tag
const tagClose = (tag: TagProps, idx: number) => {
tabBarStore.deleteTab(idx, tag);
if (props.itemData.fullPath === route.fullPath) {
if (props.itemData.path === route.path) {
// 获取队列的前一个 tab
const latest = tagList.value[idx - 1];
router.push({ name: latest.name });
}
};
// 获取当前路由索引
const findCurrentRouteIndex = () => {
return tagList.value.findIndex((el) => el.fullPath === route.fullPath);
return tagList.value.findIndex((el) => el.path === route.path);
};
// 选择操作
const actionSelect = async (value: any) => {
const { itemData, index } = props;
const copyTagList = [...tagList.value];