11<template >
22 <div class =" router-history" >
33 <el-tabs
4- :closable =" !(historys.length==1&&this.$route.name=='dashboard' )"
4+ :closable =" !(historys.length==1&&this.$route.name==defaultRouter )"
55 @contextmenu.prevent.native =" openContextMenu($event)"
66 @tab-click =" changeTab"
77 @tab-remove =" removeTab"
2727 </div >
2828</template >
2929<script >
30+ import {mapGetters } from " vuex"
31+
3032export default {
3133 name: ' HistoryComponent' ,
3234 data () {
3335 return {
3436 historys: [],
35- activeValue: ' dashboard ' ,
37+ activeValue: ' ' ,
3638 contextMenuVisible: false ,
3739 left: 0 ,
3840 top: 0 ,
@@ -41,7 +43,15 @@ export default {
4143 rightActive: ' '
4244 }
4345 },
46+
47+ computed: {
48+ ... mapGetters (" user" ,[" userInfo" ]),
49+ defaultRouter (){
50+ return this .userInfo .authority .defaultRouter
51+ }
52+ },
4453 created () {
54+ this .activeValue = this .defaultRouter
4555 this .$bus .on (' mobile' , isMobile => {
4656 this .isMobile = isMobile
4757 })
@@ -50,9 +60,9 @@ export default {
5060 })
5161 const initHistorys = [
5262 {
53- name: ' dashboard ' ,
63+ name: this . defaultRouter ,
5464 meta: {
55- title: ' 仪表盘 '
65+ title: ' 首页 '
5666 }
5767 }
5868 ]
@@ -67,7 +77,7 @@ export default {
6777 },
6878 methods: {
6979 openContextMenu (e ) {
70- if (this .historys .length == 1 && this .$route .name == ' dashboard ' ) {
80+ if (this .historys .length == 1 && this .$route .name == this . defaultRouter ) {
7181 return false
7282 }
7383 if (e .srcElement .id ) {
@@ -89,13 +99,13 @@ export default {
8999 closeAll () {
90100 this .historys = [
91101 {
92- name: ' dashboard ' ,
102+ name: this . defaultRouter ,
93103 meta: {
94- title: ' 仪表盘 '
104+ title: ' 首页 '
95105 }
96106 }
97107 ]
98- this .$router .push ({ name: ' dashboard ' })
108+ this .$router .push ({ name: this . defaultRouter })
99109 this .contextMenuVisible = false
100110 sessionStorage .setItem (' historys' , JSON .stringify (this .historys ))
101111 },
@@ -169,7 +179,7 @@ export default {
169179 const index = this .historys .findIndex (item => item .name == tab)
170180 if (this .$route .name == tab) {
171181 if (this .historys .length == 1 ) {
172- this .$router .push ({ name: ' dashboard ' })
182+ this .$router .push ({ name: this . defaultRouter })
173183 } else {
174184 if (index < this .historys .length - 1 ) {
175185 this .$router .push ({ name: this .historys [index + 1 ].name ,query: this .historys [index + 1 ].query ,params: this .historys [index + 1 ].params })
0 commit comments