index.vue 7.4 KB
Newer Older
Mr.奇淼('s avatar
Mr.奇淼( 已提交
1
<template>
L
liuyang 已提交
2
  <el-container class="layout-cont">
J
导航  
jinlan.du 已提交
3
    <el-container :class="[isSider?'openside':'hideside',isMobile ? 'mobile': '']">
何秀钢 已提交
4
      <el-row :class="[isShadowBg?'shadowBg':'']" @click.native="changeShadow()" />
Mr.奇淼('s avatar
Mr.奇淼( 已提交
5
      <el-aside class="main-cont main-left">
6
        <div class="tilte" :style="{background: backgroundColor}">
7
          <img alt class="logoimg" :src="$GIN_VUE_ADMIN.appLogo">
8
          <h2 v-if="isSider" class="tit-text" :style="{color:textColor}">{{ $GIN_VUE_ADMIN.appName }}</h2>
9
        </div>
10
        <Aside class="aside" />
Mr.奇淼('s avatar
Mr.奇淼( 已提交
11
      </el-aside>
12
      <!-- 分块滑动功能 -->
Mr.奇淼('s avatar
Mr.奇淼( 已提交
13
      <el-main class="main-cont main-right">
Mr.奇淼('s avatar
Mr.奇淼( 已提交
14
        <transition :duration="{ enter: 800, leave: 100 }" mode="out-in" name="el-fade-in-linear">
Mr.奇淼('s avatar
Mr.奇淼( 已提交
15 16
          <div
            :style="{width: `calc(100% - ${isMobile?'0px':isCollapse?'54px':'220px'})`}"
17
            class="topfix"
Mr.奇淼('s avatar
Mr.奇淼( 已提交
18
          >
何秀钢 已提交
19 20 21 22 23 24 25
            <el-row>
              <!-- :xs="8" :sm="6" :md="4" :lg="3" :xl="1" -->
              <el-header class="header-cont">
                <el-col :xs="2" :lg="1" :md="1" :sm="1" :xl="1">
                  <div class="menu-total" @click="totalCollapse">
                    <i v-if="isCollapse" class="el-icon-s-unfold" />
                    <i v-else class="el-icon-s-fold" />
1
1319612909 已提交
26 27
                  </div>
                </el-col>
何秀钢 已提交
28 29 30 31 32 33 34 35 36 37 38 39 40
                <el-col :xs="10" :lg="14" :md="14" :sm="9" :xl="14">
                  <el-breadcrumb class="breadcrumb" separator-class="el-icon-arrow-right">
                    <el-breadcrumb-item
                      v-for="item in matched.slice(1,matched.length)"
                      :key="item.path"
                    >{{ item.meta.title }}</el-breadcrumb-item>
                  </el-breadcrumb>
                </el-col>
                <el-col :xs="12" :lg="9" :md="9" :sm="14" :xl="9">
                  <div class="fl-right right-box">
                    <Search />
                    <Screenfull class="screenfull" :style="{cursor:'pointer'}" />
                    <el-dropdown>
41
                      <span class="header-avatar" style="cursor: pointer">
何秀钢 已提交
42 43 44
                        <CustomPic />
                        <span style="margin-left: 5px">{{ userInfo.nickName }}</span>
                        <i class="el-icon-arrow-down" />
Mr.奇淼('s avatar
Mr.奇淼( 已提交
45
                      </span>
何秀钢 已提交
46 47 48 49 50 51 52 53 54 55 56 57 58
                      <el-dropdown-menu slot="dropdown" class="dropdown-group">
                        <el-dropdown-item>
                          <span>
                            更多信息
                            <el-badge is-dot />
                          </span>
                        </el-dropdown-item>
                        <el-dropdown-item icon="el-icon-s-custom" @click.native="toPerson">个人信息</el-dropdown-item>
                        <el-dropdown-item icon="el-icon-table-lamp" @click.native="LoginOut">登 出</el-dropdown-item>
                      </el-dropdown-menu>
                    </el-dropdown>
                  </div>
                </el-col>
1
1319612909 已提交
59

何秀钢 已提交
60 61
              </el-header>
            </el-row>
Mr.奇淼('s avatar
Mr.奇淼( 已提交
62 63 64 65
            <!-- 当前面包屑用路由自动生成可根据需求修改 -->
            <!--
            :to="{ path: item.path }" 暂时注释不用-->
            <HistoryComponent />
66 67 68 69
          </div>
        </transition>
        <transition mode="out-in" name="el-fade-in-linear">
          <keep-alive>
何秀钢 已提交
70
            <router-view v-if="$route.meta.keepAlive && reloadFlag" v-loading="loadingFlag" element-loading-text="正在加载中" class="admin-box" />
71 72 73
          </keep-alive>
        </transition>
        <transition mode="out-in" name="el-fade-in-linear">
何秀钢 已提交
74
          <router-view v-if="!$route.meta.keepAlive && reloadFlag" v-loading="loadingFlag" element-loading-text="正在加载中" class="admin-box" />
75
        </transition>
何秀钢 已提交
76
        <BottomInfo />
D
Devil 已提交
77
        <setting />
78 79
      </el-main>
    </el-container>
80

Mr.奇淼('s avatar
Mr.奇淼( 已提交
81
  </el-container>
Mr.奇淼('s avatar
Mr.奇淼( 已提交
82 83 84
</template>

<script>
85 86 87 88
import Aside from '@/view/layout/aside'
import HistoryComponent from '@/view/layout/aside/historyComponent/history'
import Screenfull from '@/view/layout/screenfull'
import Search from '@/view/layout/search/search'
K
klausY 已提交
89
import BottomInfo from '@/view/layout/bottomInfo/bottomInfo'
90
import { mapGetters, mapActions } from 'vuex'
91
import CustomPic from '@/components/customPic'
D
Devil 已提交
92
import Setting from './setting'
Mr.奇淼('s avatar
Mr.奇淼( 已提交
93
export default {
94
  name: 'Layout',
何秀钢 已提交
95 96 97 98 99 100
  components: {
    Aside,
    HistoryComponent,
    Screenfull,
    Search,
    BottomInfo,
D
Devil 已提交
101 102
    CustomPic,
    Setting
何秀钢 已提交
103
  },
104 105
  data() {
    return {
106
      show: false,
J
导航  
jinlan.du 已提交
107 108 109
      isCollapse: false,
      isSider: true,
      isMobile: false,
L
liuyang 已提交
110
      isShadowBg: false,
何秀钢 已提交
111 112
      loadingFlag: false,
      reloadFlag: true,
113 114
      value: ''
    }
Mr.奇淼('s avatar
Mr.奇淼( 已提交
115
  },
116
  computed: {
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
    ...mapGetters('user', ['userInfo', 'sideMode', 'baseColor']),
    textColor() {
      if (this.$store.getters['user/sideMode'] === 'dark') {
        return '#fff'
      } else if (this.$store.getters['user/sideMode'] === 'light') {
        return '#191a23'
      } else {
        return this.baseColor
      }
    },
    backgroundColor() {
      if (this.sideMode === 'dark') {
        return '#191a23'
      } else if (this.sideMode === 'light') {
        return '#fff'
      } else {
        return this.sideMode
      }
    },
136
    title() {
137
      return this.$route.meta.title || '当前页面'
138
    },
139
    matched() {
140
      return this.$route.matched
141
    }
J
导航  
jinlan.du 已提交
142 143
  },
  mounted() {
何秀钢 已提交
144
    const screenWidth = document.body.clientWidth
Mr.奇淼('s avatar
Mr.奇淼( 已提交
145
    if (screenWidth < 1000) {
146 147 148
      this.isMobile = true
      this.isSider = false
      this.isCollapse = true
Mr.奇淼('s avatar
Mr.奇淼( 已提交
149
    } else if (screenWidth >= 1000 && screenWidth < 1200) {
150 151 152
      this.isMobile = false
      this.isSider = false
      this.isCollapse = true
Mr.奇淼('s avatar
Mr.奇淼( 已提交
153
    } else {
154 155 156
      this.isMobile = false
      this.isSider = true
      this.isCollapse = false
Mr.奇淼('s avatar
Mr.奇淼( 已提交
157
    }
158 159
    this.$bus.emit('collapse', this.isCollapse)
    this.$bus.emit('mobile', this.isMobile)
何秀钢 已提交
160 161
    this.$bus.on('reload', this.reload)
    this.$bus.on('showLoading', () => {
Mr.奇淼('s avatar
Mr.奇淼( 已提交
162 163
      this.loadingFlag = true
    })
何秀钢 已提交
164
    this.$bus.on('closeLoading', () => {
Mr.奇淼('s avatar
Mr.奇淼( 已提交
165 166
      this.loadingFlag = false
    })
L
liuyang 已提交
167 168
    window.onresize = () => {
      return (() => {
何秀钢 已提交
169
        const screenWidth = document.body.clientWidth
Mr.奇淼('s avatar
Mr.奇淼( 已提交
170
        if (screenWidth < 1000) {
171 172 173
          this.isMobile = true
          this.isSider = false
          this.isCollapse = true
Mr.奇淼('s avatar
Mr.奇淼( 已提交
174
        } else if (screenWidth >= 1000 && screenWidth < 1200) {
175 176 177
          this.isMobile = false
          this.isSider = false
          this.isCollapse = true
L
liuyang 已提交
178
        } else {
179 180 181
          this.isMobile = false
          this.isSider = true
          this.isCollapse = false
L
liuyang 已提交
182
        }
183 184 185 186
        this.$bus.emit('collapse', this.isCollapse)
        this.$bus.emit('mobile', this.isMobile)
      })()
    }
何秀钢 已提交
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
  },
  methods: {
    ...mapActions('user', ['LoginOut']),
    reload() {
      this.reloadFlag = false
      this.$nextTick(() => {
        this.reloadFlag = true
      })
    },
    totalCollapse() {
      this.isCollapse = !this.isCollapse
      this.isSider = !this.isCollapse
      this.isShadowBg = !this.isCollapse
      this.$bus.emit('collapse', this.isCollapse)
    },
    toPerson() {
      this.$router.push({ name: 'person' })
    },
    changeShadow() {
      this.isShadowBg = !this.isShadowBg
      this.isSider = !!this.isCollapse
      this.totalCollapse()
    }
Mr.奇淼('s avatar
Mr.奇淼( 已提交
210
  }
211
}
Mr.奇淼('s avatar
Mr.奇淼( 已提交
212
</script>
何秀钢 已提交
213

Mr.奇淼('s avatar
Mr.奇淼( 已提交
214
<style lang="scss">
1
1319612909 已提交
215 216
@import '@/style/mobile.scss';

D
Devil 已提交
217 218 219 220 221 222 223 224
.dark{
  background-color: #191a23 !important;
  color: #fff !important;
}
.light{
  background-color: #fff !important;
  color: #000 !important;
}
K
klausY 已提交
225
</style>