Compare commits
1 Commits
master
...
perf/keep-
Author | SHA1 | Date |
---|---|---|
Pan | d431de0589 |
|
@ -6,14 +6,21 @@ const tagsView = {
|
|||
mutations: {
|
||||
ADD_VISITED_VIEWS: (state, view) => {
|
||||
if (state.visitedViews.some(v => v.path === view.path)) return
|
||||
|
||||
if (view.showInVisitedViews) {
|
||||
state.visitedViews.push({
|
||||
name: view.name,
|
||||
path: view.path,
|
||||
title: view.meta.title || 'no-name'
|
||||
})
|
||||
if (!view.meta.noCache) {
|
||||
state.cachedViews.push(view.name)
|
||||
}
|
||||
|
||||
if (!view.meta.noCache) {
|
||||
const cachedViews = [...state.cachedViews]
|
||||
cachedViews.push(view.name)
|
||||
state.cachedViews = Array.from(new Set([...cachedViews]))
|
||||
}
|
||||
console.log(state.cachedViews)
|
||||
},
|
||||
DEL_VISITED_VIEWS: (state, view) => {
|
||||
for (const [i, v] of state.visitedViews.entries()) {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
<script>
|
||||
export default {
|
||||
name: 'TableMain',
|
||||
name: 'Table',
|
||||
computed: {
|
||||
cachedViews() {
|
||||
return this.$store.state.tagsView.cachedViews
|
||||
|
|
|
@ -52,8 +52,11 @@ export default {
|
|||
methods: {
|
||||
generateTitle, // generateTitle by vue-i18n
|
||||
generateRoute() {
|
||||
if (this.$route.name) {
|
||||
return this.$route
|
||||
let matched = [...this.$route.matched]
|
||||
matched.splice(0, 1)
|
||||
matched = matched.filter(item => item.name)
|
||||
if (matched) {
|
||||
return matched
|
||||
}
|
||||
return false
|
||||
},
|
||||
|
@ -61,11 +64,17 @@ export default {
|
|||
return route.path === this.$route.path || route.name === this.$route.name
|
||||
},
|
||||
addViewTags() {
|
||||
const route = this.generateRoute()
|
||||
if (!route) {
|
||||
const routes = this.generateRoute()
|
||||
if (!routes) {
|
||||
return false
|
||||
}
|
||||
this.$store.dispatch('addVisitedViews', route)
|
||||
const length = routes.length
|
||||
routes.forEach((item, index) => {
|
||||
if (index === length - 1) {
|
||||
item.showInVisitedViews = true
|
||||
}
|
||||
this.$store.dispatch('addVisitedViews', item)
|
||||
})
|
||||
},
|
||||
moveToCurrentTag() {
|
||||
const tags = this.$refs.tag
|
||||
|
|
Loading…
Reference in New Issue