修复一下tab页签
This commit is contained in:
		| @@ -21,7 +21,7 @@ export default { | ||||
|     ...mapState(['apps']), | ||||
|     currentTab() { | ||||
|       let {name, query, hash} = this.$route | ||||
|       return [name, query?.id, hash].join("") | ||||
|       return [name?.replace(query?.id, ''), query?.id, hash].join("") | ||||
|     } | ||||
|   }, | ||||
|   data() { | ||||
| @@ -32,21 +32,19 @@ export default { | ||||
|   watch: { | ||||
|     $route: { | ||||
|       immediate: true, | ||||
|       handler(v) { | ||||
|         this.getTabs(v) | ||||
|       handler() { | ||||
|         this.getTabs("route") | ||||
|       } | ||||
|     }, | ||||
|   }, | ||||
|   methods: { | ||||
|     handleTabClick(tab) { | ||||
|       let to = {}, selectedTab = this.tabs.find(e => e.name == tab.name) | ||||
|       if (selectedTab) { | ||||
|         to = {...selectedTab, params: {tabclick: 1}} | ||||
|       } else { | ||||
|         let {name, query, hash} = tab | ||||
|         to = {name, query, hash, params: {tabclick: 1}} | ||||
|       } | ||||
|       this.$router.push({...to}) | ||||
|     handleTabClick({name}) { | ||||
|       let {name: route, query, hash} = this.tabs.find(e => e.name == name), | ||||
|           exps = [] | ||||
|       query.id && exps.push(query.id) | ||||
|       hash && exps.push(hash) | ||||
|       let reg = new RegExp(`(${exps.join("|")})`, 'g') | ||||
|       this.$router.push({name: route.replace(reg, ''), query, hash}) | ||||
|     }, | ||||
|     handleTabRemove(id = this.currentTab) { | ||||
|       let tabs = JSON.parse(JSON.stringify(this.tabs)), | ||||
| @@ -57,11 +55,13 @@ export default { | ||||
|       } | ||||
|       this.tabs.splice(index, 1) | ||||
|     }, | ||||
|     getTabs() { | ||||
|     getTabs(from) { | ||||
|       let {name, query, hash} = this.$route | ||||
|       console.log(`getTabs>>>>>>>>>%s>>>>>>>%s`, from, name) | ||||
|       let tab = this.tabs.find(e => e.name == this.currentTab), | ||||
|           tabName = [name, query?.id, hash].join("") | ||||
|       if (tab) { | ||||
|       } else if (!name) { | ||||
|       } else if (tabName) { | ||||
|         let menu = this.apps.find(e => e.name == name) | ||||
|         this.tabs.push({name: tabName, query, hash, label: menu?.label}) | ||||
| @@ -69,7 +69,7 @@ export default { | ||||
|     }, | ||||
|   }, | ||||
|   created() { | ||||
|     this.getTabs() | ||||
|     this.getTabs("created") | ||||
|   } | ||||
| } | ||||
| </script> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user