diff --git a/src/store/modules/app.js b/src/store/modules/app.js index bed8098fdf3728f18834d91bdbd6514a1723c57a..749916d6de92c9a543b782fc2450fae76c14d51e 100644 --- a/src/store/modules/app.js +++ b/src/store/modules/app.js @@ -21,7 +21,8 @@ const app = { if (state.visitedViews.some(v => v.path === view.path)) return state.visitedViews.push({ name: view.name, - path: view.path + path: view.path, + title: view.meta.title || 'no-name' }) if (!view.meta.noCache) { state.cachedViews.push(view.name) diff --git a/src/views/form/components/ArticleDetail.vue b/src/views/form/components/ArticleDetail.vue index 83227df86fb9afc0be8442b8f73b35b79c5f4fa2..60379fa61b62d5d6f38c7e215801edfd02bb1379 100644 --- a/src/views/form/components/ArticleDetail.vue +++ b/src/views/form/components/ArticleDetail.vue @@ -5,7 +5,7 @@ <sticky :className="'sub-navbar '+postForm.status"> <template v-if="fetchSuccess"> - <router-link style="margin-right:15px;" v-show='isEdit' :to="{ path:'create'}"> + <router-link style="margin-right:15px;" v-show='isEdit' :to="{ path:'create-form'}"> <el-button type="info">创建form</el-button> </router-link> diff --git a/src/views/layout/components/Levelbar.vue b/src/views/layout/components/Levelbar.vue index 85c6995b81c7dfe18372acdd764808c0b83302b1..57157e70aef43360a97ed34a4fbd4c0022fddd19 100644 --- a/src/views/layout/components/Levelbar.vue +++ b/src/views/layout/components/Levelbar.vue @@ -20,6 +20,10 @@ export default { methods: { getBreadcrumb() { let matched = this.$route.matched.filter(item => item.name) + if (matched.length === 0) { + this.levelList = [{ path: '/', meta: { title: '首页' }}] + return + } const first = matched[0] if (first && (first.name !== '首页' || first.path !== '')) { matched = [{ path: '/', meta: { title: '首页' }}].concat(matched) diff --git a/src/views/layout/components/TabsView.vue b/src/views/layout/components/TabsView.vue index ab6dc4d7c202dee0d6da310a6b41fa209162f2ef..28c1bcf4223326c5c4aca4b75eca928da7e9ef09 100644 --- a/src/views/layout/components/TabsView.vue +++ b/src/views/layout/components/TabsView.vue @@ -1,8 +1,7 @@ <template> <scroll-pane class='tabs-view-container'> - <router-link class="tabs-view-item" :class="isActive(tag.path)?'active':''" v-for="tag in Array.from(visitedViews)" :to="tag.path" - :key="tag.path"> - {{tag.name}} + <router-link class="tabs-view-item" :class="isActive(tag)?'active':''" v-for="tag in Array.from(visitedViews)" :to="tag.path" :key="tag.path"> + {{tag.title}} <span class='el-icon-close' @click='closeViewTabs(tag,$event)'></span> </router-link> </scroll-pane> @@ -20,7 +19,7 @@ export default { } }, mounted() { - this.$store.dispatch('addVisitedViews', this.generateRoute()) + this.addViewTabs() }, methods: { closeViewTabs(view, $event) { @@ -37,17 +36,20 @@ export default { $event.preventDefault() }, generateRoute() { - if (this.$route.matched[this.$route.matched.length - 1].name) { - return this.$route.matched[this.$route.matched.length - 1] + if (this.$route.name) { + return this.$route } - this.$route.matched[0].path = '/' - return this.$route.matched[0] + return false }, addViewTabs() { - this.$store.dispatch('addVisitedViews', this.generateRoute()) + const route = this.generateRoute() + if (!route) { + return false + } + this.$store.dispatch('addVisitedViews', route) }, - isActive(path) { - return path === this.$route.path + isActive(route) { + return route.path === this.$route.path || route.name === this.$route.name } },