'关闭标签后销毁组件'
parent
367252196c
commit
c6a5a64419
|
@ -6,7 +6,7 @@
|
||||||
<v-tags></v-tags>
|
<v-tags></v-tags>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<transition name="move" mode="out-in">
|
<transition name="move" mode="out-in">
|
||||||
<keep-alive>
|
<keep-alive :include="tagsList">
|
||||||
<router-view></router-view>
|
<router-view></router-view>
|
||||||
</keep-alive>
|
</keep-alive>
|
||||||
</transition>
|
</transition>
|
||||||
|
@ -19,10 +19,11 @@
|
||||||
import vHead from './Header.vue';
|
import vHead from './Header.vue';
|
||||||
import vSidebar from './Sidebar.vue';
|
import vSidebar from './Sidebar.vue';
|
||||||
import vTags from './Tags.vue';
|
import vTags from './Tags.vue';
|
||||||
import bus from '../common/bus';
|
import bus from './bus';
|
||||||
export default {
|
export default {
|
||||||
data(){
|
data(){
|
||||||
return {
|
return {
|
||||||
|
tagsList: [],
|
||||||
collapse: false
|
collapse: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -33,6 +34,15 @@
|
||||||
bus.$on('collapse', msg => {
|
bus.$on('collapse', msg => {
|
||||||
this.collapse = msg;
|
this.collapse = msg;
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 只有在标签页列表里的页面才使用keep-alive,即关闭标签之后就不保存到内存中了。
|
||||||
|
bus.$on('tags', msg => {
|
||||||
|
let arr = [];
|
||||||
|
for(let i = 0, len = msg.length; i < len; i ++){
|
||||||
|
msg[i].name && arr.push(msg[i].name);
|
||||||
|
}
|
||||||
|
this.tagsList = arr;
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import bus from './bus';
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -31,14 +32,14 @@
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
isActive(path) {
|
isActive(path) {
|
||||||
return path === this.$route.path;
|
return path === this.$route.fullPath;
|
||||||
},
|
},
|
||||||
// 关闭单个标签
|
// 关闭单个标签
|
||||||
closeTags(index) {
|
closeTags(index) {
|
||||||
const delItem = this.tagsList.splice(index, 1)[0];
|
const delItem = this.tagsList.splice(index, 1)[0];
|
||||||
const item = this.tagsList[index] ? this.tagsList[index] : this.tagsList[index - 1];
|
const item = this.tagsList[index] ? this.tagsList[index] : this.tagsList[index - 1];
|
||||||
if (item) {
|
if (item) {
|
||||||
delItem.path === this.$route.path && this.$router.push(item.path);
|
delItem.path === this.$route.fullPath && this.$router.push(item.path);
|
||||||
}else{
|
}else{
|
||||||
this.$router.push('/');
|
this.$router.push('/');
|
||||||
}
|
}
|
||||||
|
@ -51,19 +52,21 @@
|
||||||
// 关闭其他标签
|
// 关闭其他标签
|
||||||
closeOther(){
|
closeOther(){
|
||||||
const curItem = this.tagsList.filter(item => {
|
const curItem = this.tagsList.filter(item => {
|
||||||
return item.path === this.$route.path;
|
return item.path === this.$route.fullPath;
|
||||||
})
|
})
|
||||||
this.tagsList = curItem;
|
this.tagsList = curItem;
|
||||||
},
|
},
|
||||||
// 设置标签
|
// 设置标签
|
||||||
setTags(route){
|
setTags(route){
|
||||||
const isExist = this.tagsList.some(item => {
|
const isExist = this.tagsList.some(item => {
|
||||||
return item.path === route.path;
|
return item.path === route.fullPath;
|
||||||
})
|
})
|
||||||
!isExist && this.tagsList.push({
|
!isExist && this.tagsList.push({
|
||||||
title: route.meta.title,
|
title: route.meta.title,
|
||||||
path: route.path
|
path: route.fullPath,
|
||||||
|
name: route.matched[1].components.default.name
|
||||||
})
|
})
|
||||||
|
bus.$emit('tags', this.tagsList);
|
||||||
},
|
},
|
||||||
handleTags(command){
|
handleTags(command){
|
||||||
command === 'other' ? this.closeOther() : this.closeAll();
|
command === 'other' ? this.closeOther() : this.closeAll();
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
<script>
|
<script>
|
||||||
import Schart from 'vue-schart';
|
import Schart from 'vue-schart';
|
||||||
export default {
|
export default {
|
||||||
|
name: 'basecharts',
|
||||||
components: {
|
components: {
|
||||||
Schart
|
Schart
|
||||||
},
|
},
|
||||||
|
|
|
@ -64,6 +64,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
|
name: 'baseform',
|
||||||
data: function(){
|
data: function(){
|
||||||
return {
|
return {
|
||||||
options:[
|
options:[
|
||||||
|
|
|
@ -69,6 +69,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
|
name: 'basetable',
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
url: './static/vuetable.json',
|
url: './static/vuetable.json',
|
||||||
|
|
|
@ -99,6 +99,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
|
name: 'dashboard',
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
name: localStorage.getItem('ms_username'),
|
name: localStorage.getItem('ms_username'),
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
<script>
|
<script>
|
||||||
import draggable from 'vuedraggable'
|
import draggable from 'vuedraggable'
|
||||||
export default {
|
export default {
|
||||||
|
name: 'draglist',
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
dragOptions:{
|
dragOptions:{
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
import { mavonEditor } from 'mavon-editor'
|
import { mavonEditor } from 'mavon-editor'
|
||||||
import 'mavon-editor/dist/css/index.css'
|
import 'mavon-editor/dist/css/index.css'
|
||||||
export default {
|
export default {
|
||||||
|
name: 'markdown',
|
||||||
data: function(){
|
data: function(){
|
||||||
return {
|
return {
|
||||||
content:'',
|
content:'',
|
||||||
|
|
|
@ -72,6 +72,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
|
name: 'tabs',
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
message: 'first',
|
message: 'first',
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
<script>
|
<script>
|
||||||
import VueCropper from 'vue-cropperjs';
|
import VueCropper from 'vue-cropperjs';
|
||||||
export default {
|
export default {
|
||||||
|
name: 'upload',
|
||||||
data: function(){
|
data: function(){
|
||||||
return {
|
return {
|
||||||
defaultSrc: './static/img/img.jpg',
|
defaultSrc: './static/img/img.jpg',
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
import 'quill/dist/quill.bubble.css';
|
import 'quill/dist/quill.bubble.css';
|
||||||
import { quillEditor } from 'vue-quill-editor';
|
import { quillEditor } from 'vue-quill-editor';
|
||||||
export default {
|
export default {
|
||||||
|
name: 'editor',
|
||||||
data: function(){
|
data: function(){
|
||||||
return {
|
return {
|
||||||
content: '',
|
content: '',
|
||||||
|
|
Loading…
Reference in New Issue