Merge pull request #98 from lin-xin/dev

修复bug
pull/195/head
林鑫 2018-06-01 14:54:15 +08:00 committed by GitHub
commit c6e9ee77e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 29 additions and 7 deletions

View File

@ -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>

View File

@ -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();

View File

@ -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
}, },

View File

@ -64,6 +64,7 @@
<script> <script>
export default { export default {
name: 'baseform',
data: function(){ data: function(){
return { return {
options:[ options:[

View File

@ -69,6 +69,7 @@
<script> <script>
export default { export default {
name: 'basetable',
data() { data() {
return { return {
url: './static/vuetable.json', url: './static/vuetable.json',

View File

@ -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'),

View File

@ -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:{

View File

@ -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:'',

View File

@ -72,6 +72,7 @@
<script> <script>
export default { export default {
name: 'tabs',
data() { data() {
return { return {
message: 'first', message: 'first',

View File

@ -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',

View File

@ -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: '',