Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b627d3d

Browse files
de1ckPanJiaChen
authored andcommitted
fix[TagsView]: fixed close last page bug(PanJiaChen#1866)
1 parent 8f45dbe commit b627d3d

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/layout/components/TagsView/index.vue

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export default {
145145
closeSelectedTag(view) {
146146
this.$store.dispatch('tagsView/delView', view).then(({ visitedViews }) => {
147147
if (this.isActive(view)) {
148-
this.toLastView(visitedViews)
148+
this.toLastView(visitedViews, view)
149149
}
150150
})
151151
},
@@ -160,16 +160,22 @@ export default {
160160
if (this.affixTags.some(tag => tag.path === view.path)) {
161161
return
162162
}
163-
this.toLastView(visitedViews)
163+
this.toLastView(visitedViews, view)
164164
})
165165
},
166-
toLastView(visitedViews) {
166+
toLastView(visitedViews, view) {
167167
const latestView = visitedViews.slice(-1)[0]
168168
if (latestView) {
169169
this.$router.push(latestView)
170170
} else {
171-
// You can set another route
172-
this.$router.push('/')
171+
// now the default is to redirect to the home page if there is no tags-view,
172+
// you can adjust it according to your needs.
173+
if (view.name === 'Dashboard') {
174+
// to reload home page
175+
this.$router.replace({ path: '/redirect' + view.fullPath })
176+
} else {
177+
this.$router.push('/')
178+
}
173179
}
174180
},
175181
openMenu(tag, e) {

0 commit comments

Comments
 (0)