|
@@ -77,8 +77,26 @@ export default {
|
|
|
},
|
|
|
// 设置标签
|
|
|
setTags(route) {
|
|
|
- const isExist = this.tagsList.some((item) => {
|
|
|
- return item.path.indexOf(route.path) > -1;
|
|
|
+ let tagArr = {
|
|
|
+ title: route.title || route.meta.title,
|
|
|
+ path: route.fullPath
|
|
|
+ };
|
|
|
+ if (!!route.name) {
|
|
|
+ tagArr = {
|
|
|
+ title: route.title || route.meta.title,
|
|
|
+ path: route.fullPath,
|
|
|
+ name: route.name
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ const isExist = this.tagsList.some((item, index) => {
|
|
|
+ let thisBi = item.path.indexOf(route.path) > -1;
|
|
|
+ if (thisBi) {
|
|
|
+ this.tagsList.splice(index, 1, tagArr);
|
|
|
+
|
|
|
+ this.$store.dispatch('tags', this.tagsList);
|
|
|
+ }
|
|
|
+ return thisBi;
|
|
|
});
|
|
|
if (!isExist) {
|
|
|
if (route.path === '/') {
|
|
@@ -87,18 +105,6 @@ export default {
|
|
|
if (this.tagsList.length >= 8) {
|
|
|
this.tagsList.shift();
|
|
|
}
|
|
|
- let tagArr = {
|
|
|
- title: route.title || route.meta.title,
|
|
|
- path: route.fullPath
|
|
|
- };
|
|
|
- if (!!route.name) {
|
|
|
- tagArr = {
|
|
|
- title: route.title || route.meta.title,
|
|
|
- path: route.fullPath,
|
|
|
- name: route.name
|
|
|
- };
|
|
|
- }
|
|
|
-
|
|
|
this.tagsList.push(tagArr);
|
|
|
this.$store.dispatch('tags', this.tagsList);
|
|
|
}
|