Skip to content

Commit 5cd245a

Browse files
committed
split tabs-view to separate files
1 parent 0c3063f commit 5cd245a

File tree

3 files changed

+49
-23
lines changed

3 files changed

+49
-23
lines changed

src/views/layout/Levelbar.vue

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,14 @@
44
<router-link v-if='item.redirect==="noredirect"||index==levelList.length-1' to="" class="no-redirect">{{item.name}}</router-link>
55
<router-link v-else :to="item.path">{{item.name}}</router-link>
66
</el-breadcrumb-item>
7-
<router-link class="view-tabs" v-for="tag in Array.from(visitedViews)" :to="tag.path" :key="tag.path">
8-
<el-tag :closable="true" @close='closeViewTabs(tag,$event)'>
9-
{{tag.name}}
10-
</el-tag>
11-
</router-link>
127
</el-breadcrumb>
138
</template>
149

1510
<script>
16-
1711
export default {
1812
created() {
1913
this.getBreadcrumb()
2014
},
21-
computed: {
22-
visitedViews() {
23-
return this.$store.state.app.visitedViews.slice(-6)
24-
}
25-
},
2615
data() {
2716
return {
2817
levelList: null
@@ -36,18 +25,10 @@
3625
matched = [{ name: '首页', path: '/' }].concat(matched)
3726
}
3827
this.levelList = matched;
39-
},
40-
closeViewTabs(view, $event) {
41-
this.$store.dispatch('delVisitedViews', view)
42-
$event.preventDefault()
43-
},
44-
addViewTabs() {
45-
this.$store.dispatch('addVisitedViews', this.$route.matched[this.$route.matched.length - 1])
4628
}
4729
},
4830
watch: {
4931
$route() {
50-
this.addViewTabs();
5132
this.getBreadcrumb();
5233
}
5334
}
@@ -65,7 +46,4 @@
6546
cursor:text;
6647
}
6748
}
68-
.view-tabs{
69-
margin-left: 10px;
70-
}
7149
</style>

src/views/layout/Navbar.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
<el-menu class="navbar" mode="horizontal">
33
<hamburger class="hamburger-container" :toggleClick="toggleSideBar" :isActive="sidebar.opened"></hamburger>
44
<levelbar></levelbar>
5+
<tabs-view></tabs-view>
56
<error-log v-if="log.length>0" class="errLog-container" :logsList="log"></error-log>
67
<screenfull class='screenfull'></screenfull>
78
<el-dropdown class="avatar-container" trigger="click">
89
<div class="avatar-wrapper">
910
<img class="user-avatar" :src="avatar+'?imageView2/1/w/80/h/80'">
10-
<i class="el-icon-caret-bottom" />
11+
<i class="el-icon-caret-bottom"></i>
1112
</div>
1213
<el-dropdown-menu class="user-dropdown" slot="dropdown">
1314
<router-link class='inlineBlock' to="/">
@@ -29,6 +30,7 @@
2930
<script>
3031
import { mapGetters } from 'vuex';
3132
import Levelbar from './Levelbar';
33+
import TabsView from './TabsView';
3234
import Hamburger from 'components/Hamburger';
3335
import Screenfull from 'components/Screenfull';
3436
import ErrorLog from 'components/ErrLog';
@@ -37,6 +39,7 @@
3739
export default {
3840
components: {
3941
Levelbar,
42+
TabsView,
4043
Hamburger,
4144
ErrorLog,
4245
Screenfull

src/views/layout/TabsView.vue

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<template>
2+
<div class='tabs-view-container'>
3+
<router-link class="tabs-view" v-for="tag in Array.from(visitedViews)" :to="tag.path" :key="tag.path">
4+
<el-tag :closable="true" @close='closeViewTabs(tag,$event)'>
5+
{{tag.name}}
6+
</el-tag>
7+
</router-link>
8+
</div>
9+
</template>
10+
11+
<script>
12+
export default {
13+
computed: {
14+
visitedViews() {
15+
return this.$store.state.app.visitedViews.slice(-6)
16+
}
17+
},
18+
methods: {
19+
closeViewTabs(view, $event) {
20+
this.$store.dispatch('delVisitedViews', view)
21+
$event.preventDefault()
22+
},
23+
addViewTabs() {
24+
this.$store.dispatch('addVisitedViews', this.$route.matched[this.$route.matched.length - 1])
25+
}
26+
},
27+
watch: {
28+
$route() {
29+
this.addViewTabs()
30+
}
31+
}
32+
}
33+
</script>
34+
35+
<style rel="stylesheet/scss" lang="scss" scoped>
36+
.tabs-view-container{
37+
display: inline-block;
38+
vertical-align: top;
39+
margin-left: 10px;
40+
.tabs-view{
41+
margin-left: 10px;
42+
}
43+
}
44+
45+
</style>

0 commit comments

Comments
 (0)