|
@@ -237,11 +237,19 @@ const closeRightTags = () => {
|
|
|
|
|
|
// 新增tag
|
|
|
const addTags = () => {
|
|
|
- const { name } = unref(currentRoute)
|
|
|
+ const { name, path } = unref(currentRoute)
|
|
|
if (name) {
|
|
|
- selectedTag.value = unref(currentRoute)
|
|
|
- tagsViewStore.addView(unref(currentRoute))
|
|
|
- tagsViewStore.addCachedView()
|
|
|
+ // 检查当前路由路径是否已经存在
|
|
|
+ const existingTagIndex = unref(visitedViews).findIndex((view) => view.path === path)
|
|
|
+ if (existingTagIndex !== -1) {
|
|
|
+ // 如果存在相同路径的标签,更新该标签
|
|
|
+ tagsViewStore.visitedViews[existingTagIndex] = unref(currentRoute)
|
|
|
+ } else {
|
|
|
+ // 如果不存在相同路径的标签,添加新标签
|
|
|
+ selectedTag.value = unref(currentRoute)
|
|
|
+ tagsViewStore.addView(unref(currentRoute))
|
|
|
+ tagsViewStore.addCachedView()
|
|
|
+ }
|
|
|
}
|
|
|
nextTick(() => {
|
|
|
// 当前选择路由滚入视野
|
|
@@ -253,6 +261,7 @@ const addTags = () => {
|
|
|
})
|
|
|
return false
|
|
|
}
|
|
|
+
|
|
|
//订阅流程中关闭message事件
|
|
|
subscribe.on('closeCurrentView', () => {
|
|
|
const view = vueRouter.currentRoute.value as RouteLocationNormalizedLoaded
|