From b627d3d0ba887962f73585d5f9d41745d017f2c8 Mon Sep 17 00:00:00 2001 From: derrick <1145390845@qq.com> Date: Tue, 9 Apr 2019 12:56:57 +0800 Subject: [PATCH] fix[TagsView]: fixed close last page bug(#1866) --- src/layout/components/TagsView/index.vue | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/layout/components/TagsView/index.vue b/src/layout/components/TagsView/index.vue index f06f5156..19d3083f 100644 --- a/src/layout/components/TagsView/index.vue +++ b/src/layout/components/TagsView/index.vue @@ -145,7 +145,7 @@ export default { closeSelectedTag(view) { this.$store.dispatch('tagsView/delView', view).then(({ visitedViews }) => { if (this.isActive(view)) { - this.toLastView(visitedViews) + this.toLastView(visitedViews, view) } }) }, @@ -160,16 +160,22 @@ export default { if (this.affixTags.some(tag => tag.path === view.path)) { return } - this.toLastView(visitedViews) + this.toLastView(visitedViews, view) }) }, - toLastView(visitedViews) { + toLastView(visitedViews, view) { const latestView = visitedViews.slice(-1)[0] if (latestView) { this.$router.push(latestView) } else { - // You can set another route - this.$router.push('/') + // now the default is to redirect to the home page if there is no tags-view, + // you can adjust it according to your needs. + if (view.name === 'Dashboard') { + // to reload home page + this.$router.replace({ path: '/redirect' + view.fullPath }) + } else { + this.$router.push('/') + } } }, openMenu(tag, e) {