baizonghao
2023-08-04 8fee5b265eaa379b7a1cc51cd060a368c046de46
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
120
121
122
123
<template>
  <el-container>
    <el-header height="61" class="student-header">
      <div class="head-user">
        <el-dropdown trigger="click" placement="bottom">
          <el-badge :is-dot="messageCount!==0">
            <el-avatar class="el-dropdown-avatar" size="medium"
                       :src="imagePath===null|| imagePath === '' ? require('@/assets/avatar.png') : imagePath"></el-avatar>
          </el-badge>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item @click.native="$router.push({path:'/user/index'})">个人中心</el-dropdown-item>
            <el-dropdown-item @click.native="$router.push({path:'/user/message'})">
              <el-badge :value="messageCount" v-if="messageCount!==0">
                <span>消息中心</span>
              </el-badge>
              <span v-if="messageCount===0">消息中心</span>
            </el-dropdown-item>
            <el-dropdown-item @click.native="logout" divided>退出</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </div>
      <el-menu class="el-menu-title" mode="horizontal" :default-active="defaultUrl" :router="true">
        <el-menu-item index="/index">首页</el-menu-item>
<!--        <el-menu-item index="/video/index">视频课堂</el-menu-item>-->
        <el-menu-item index="/smart/index">智能训练</el-menu-item>
        <el-menu-item index="/paper/index">试卷中心</el-menu-item>
        <el-menu-item index="/record/index">考试记录</el-menu-item>
        <el-menu-item index="/question/index">错题本</el-menu-item>
        <el-menu-item index="/mymeetlist/index">我的会议</el-menu-item>
      </el-menu>
      <div>
        <a href="/">
          <img src="@/assets/logo.png" style="margin-left: 15px;height: 50px;margin-top: 6px;"/>
        </a>
      </div>
    </el-header>
    <el-main class="student-main">
      <router-view/>
    </el-main>
<!--    <el-footer height="340" class="student-footer">-->
<!--      <div class="foot-container">-->
<!--        <div class="footer-main">-->
<!--          <h4>产品介绍</h4>-->
<!--          <a href="https://www.mindskip.net/sdd.html" target="_blank" class="footer-main-link">思多多智能考试系统</a>-->
<!--          <a href="https://www.mindskip.net/wdd.html" target="_blank" class="footer-main-link">维多多培训考试系统</a>-->
<!--          <a href="https://www.mindskip.net/xzs.html" target="_blank" class="footer-main-link">学之思开源考试系统</a>-->
<!--        </div>-->
<!--        <div class="footer-main">-->
<!--          <h4>微信小程序</h4>-->
<!--          <img src="@/assets/code/3.jpg" style="width: 100px;height: 100px;margin-right: 30px"/>-->
<!--          <img src="@/assets/code/7.jpg" style="width: 100px;height: 100px;margin-right: 30px"/>-->
<!--          <img src="@/assets/code/1.jpg" style="width: 100px;height: 100px;"/>-->
<!--        </div>-->
<!--        <div class="footer-main">-->
<!--          <h4>关于我们</h4>-->
<!--          <img src="@/assets/4.jpg" style="width: 100px;height: 100px;"/>-->
<!--        </div>-->
<!--        <div class="footer-main">-->
<!--          <h4>文档中心</h4>-->
<!--          <a href="https://gitee.com/mindskip" target="_blank" class="footer-main-link">学之思仓库地址</a>-->
<!--          <a href="https://www.mindskip.net:999" target="_blank" class="footer-main-link">学之思开发文档</a>-->
<!--          <a href="https://ke.qq.com/course/3614230" target="_blank" class="footer-main-link">学之思视频教程</a>-->
<!--        </div>-->
<!--      </div>-->
<!--    </el-footer>-->
    <div class="foot-copyright">
      <span>Copyright ©2020-2023 成都优创力软件技术有限公司 版权所有</span>
    </div>
  </el-container>
</template>
 
<script>
import { mapActions, mapMutations, mapState } from 'vuex'
import loginApi from '@/api/login'
 
export default {
  name: 'Layout',
  data () {
    return {
      defaultUrl: '/index'
    }
  },
  created () {
    this.defaultUrl = this.routeSelect(this.$route.path)
    this.getUserMessageInfo()
  },
  watch: {
    $route (to, from) {
      this.defaultUrl = this.routeSelect(to.path)
    }
  },
  methods: {
    routeSelect (path) {
      let topPath = ['/', '/index', '/video/index', '/smart/index', '/paper/index', '/record/index', '/question/index']
      if (topPath.indexOf(path)) {
        return path
      }
      return null
    },
    logout () {
      let _this = this
      loginApi.logout().then(function (result) {
        if (result && result.code === 1) {
          _this.clearLogin()
          _this.$router.push({ path: '/login' })
        }
      })
    },
    ...mapActions('user', ['getUserMessageInfo']),
    ...mapMutations('user', ['clearLogin'])
  },
  computed: {
    ...mapState('user', {
      messageCount: state => state.messageCount,
      imagePath: state => state.imagePath
    })
  }
}
</script>
 
<style lang="scss" scoped>
 
</style>