File tree 3 files changed +28
-12
lines changed 3 files changed +28
-12
lines changed Original file line number Diff line number Diff line change @@ -6,14 +6,21 @@ const tagsView = {
6
6
mutations : {
7
7
ADD_VISITED_VIEWS : ( state , view ) => {
8
8
if ( state . visitedViews . some ( v => v . path === view . path ) ) return
9
- state . visitedViews . push ( {
10
- name : view . name ,
11
- path : view . path ,
12
- title : view . meta . title || 'no-name'
13
- } )
9
+
10
+ if ( view . showInVisitedViews ) {
11
+ state . visitedViews . push ( {
12
+ name : view . name ,
13
+ path : view . path ,
14
+ title : view . meta . title || 'no-name'
15
+ } )
16
+ }
17
+
14
18
if ( ! view . meta . noCache ) {
15
- state . cachedViews . push ( view . name )
19
+ const cachedViews = [ ...state . cachedViews ]
20
+ cachedViews . push ( view . name )
21
+ state . cachedViews = Array . from ( new Set ( [ ...cachedViews ] ) )
16
22
}
23
+ console . log ( state . cachedViews )
17
24
} ,
18
25
DEL_VISITED_VIEWS : ( state , view ) => {
19
26
for ( const [ i , v ] of state . visitedViews . entries ( ) ) {
Original file line number Diff line number Diff line change 8
8
9
9
<script >
10
10
export default {
11
- name: ' TableMain ' ,
11
+ name: ' Table ' ,
12
12
computed: {
13
13
cachedViews () {
14
14
return this .$store .state .tagsView .cachedViews
Original file line number Diff line number Diff line change @@ -52,20 +52,29 @@ export default {
52
52
methods: {
53
53
generateTitle, // generateTitle by vue-i18n
54
54
generateRoute () {
55
- if (this .$route .name ) {
56
- return this .$route
55
+ let matched = [... this .$route .matched ]
56
+ matched .splice (0 , 1 )
57
+ matched = matched .filter (item => item .name )
58
+ if (matched) {
59
+ return matched
57
60
}
58
61
return false
59
62
},
60
63
isActive (route ) {
61
64
return route .path === this .$route .path || route .name === this .$route .name
62
65
},
63
66
addViewTags () {
64
- const route = this .generateRoute ()
65
- if (! route ) {
67
+ const routes = this .generateRoute ()
68
+ if (! routes ) {
66
69
return false
67
70
}
68
- this .$store .dispatch (' addVisitedViews' , route)
71
+ const length = routes .length
72
+ routes .forEach ((item , index ) => {
73
+ if (index === length - 1 ) {
74
+ item .showInVisitedViews = true
75
+ }
76
+ this .$store .dispatch (' addVisitedViews' , item)
77
+ })
69
78
},
70
79
moveToCurrentTag () {
71
80
const tags = this .$refs .tag
You can’t perform that action at this time.
0 commit comments