whychw
2021-01-08 826ecd914e7fa71f2ecbb6915d0dee2e94f62acb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<template>
  <div class="pageLayout">
    <div class="pageSlideMenu">
      <page-menu></page-menu>
    </div>
    <div class="pageConten">
      <page-header></page-header>
      <div class="viewCon">
        <div class="inner">
          <transition :name="transitionName">
            <!--这里的router-view用来渲染子页面-->
            <router-view></router-view>
          </transition>
        </div>
      </div>
    </div>
  </div>
</template>
 
<script>
  import PageMenu from '@/components/PageMenu'
  import PageHeader from '@/components/PageHeader'
  const trsList = ['slide-left', 'slide-right', 'clip-circle-in', 'clip-triangle-in', 'clip-rect-in', 'clip-diamond-in', 'clip-rect-sp-in', 'clip-sector-in', 'seed', 'seed-hor', 'clip-rotate-in'];
  const trsLen = trsList.length;
  export default {
    components: {
      PageMenu,
      PageHeader
    },
    data() {
      return {
        // transitionName: 'slide-left'
        transitionName: 'clip-rotate-in'
        ,idx: 0
      }
    },
    methods: {
      random () {
        let res = Math.floor(Math.random() * trsLen);
        if (this.idx == res) {
          return this.random();
        }
        return res;
      }
    },
    mounted () {
      this.$event.$on('routerChange', () => {
        this.idx = this.random();
        this.transitionName = trsList[this.idx];
      });
    },
    beforeCreate() { //设置子路由路径
      let activeMenu = localStorage.getItem('activeMenu');
      // 当activeMenu 为 null时 输入的跳由应该不处理
      // 当activeMenu 和路径相同时也不处理
      // debugger;
      if (!activeMenu || this.$route.path.indexOf(activeMenu) > -1) {
        return false;
      }
      if (this.$route.path.indexOf('/index') > -1) {
        if (activeMenu) {
 
          this.$router.push({
            path: `/index/${activeMenu}`,
          }).catch(err => {
 
          });
        } else {
          this.$router.push({
            path: '/index/topoGraph',
          }).catch(err => {
 
          });
        }
      }
    }
  }
</script>
 
<style scoped>
  .pageLayout {
    width: 100%;
    height: 100%;
    display: flex;
  }
 
  .pageSlideMenu {
    padding-left: 5px;
    padding-bottom: 8px;
    width: 220px;
    overflow-y: auto;
    overflow-x: hidden;
  }
 
  .pageConten {
    flex: 1;
    display: -webkit-flex;
    display: flex;
    flex-direction: column;
  }
 
  .viewCon {
    flex: 1;
    /*padding: 8px 8px 0 18px;*/
    /*width: 100%;*/
    /*display: -webkit-flex;
    display: flex;*/
    position: relative;
    /*height: calc(100% - 108px);*/
  }
  .inner {
    position: absolute;
    left: 18px;
    top: 8px;
    right: 8px;
    bottom: 0;
    overflow: hidden;
  }
</style>