<template>
  <div class="body">
    <div class="top">
      <div class="title">CocoClass后台管理</div>
      <div class="person">
        <div class="person_name">{{ userinfo ? userinfo.username : "" }}</div>
        <el-button type="text" @click="handleLogout" style="margin-left: 20px">退出</el-button>
      </div>
    </div>
    <div class="container">
      <div class="left">
        <ul>
          <router-link class="menu_left" to="/user-list">
            <i class="el-icon-s-custom"></i>账号列表
          </router-link>
          <router-link class="menu_left" to="/user-examine">
            <i class="el-icon-edit"></i>账号审核
          </router-link>
          <router-link class="menu_left" to="/organ-list">
            <i class="el-icon-office-building"></i>组织列表
          </router-link>
          <router-link class="menu_left" to="/school-list">
            <i class="el-icon-school"></i>学校列表
          </router-link>
          <!-- <router-link class="menu_left" to="/version-add">
            <i class="el-icon-office-building"></i>版本更新
          </router-link> -->
					<router-link class="menu_left" to="/desktopTool-list" v-show="userinfo.userid != '0abcb118-9110-11eb-80ad-005056b86db5'">
						<i class="el-icon-s-grid"></i>工具列表
					</router-link>
          <router-link class="menu_left" to="/suffix-list" v-show="userinfo.userid != '0abcb118-9110-11eb-80ad-005056b86db5'">
						<i class="el-icon-s-grid"></i>后缀管理
					</router-link>
           <router-link class="menu_left" to="/instupdata">
						<i class="el-icon-s-grid"></i>ai6说明文件
					</router-link>
        </ul>
      </div>
      <div class="table-container">
        <router-view></router-view>
      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters, mapActions } from 'vuex';
import { loginOut } from '@/api/user';

export default {
  name: "HomeView",
  computed: {
    ...mapGetters(['userinfo']),
  },
  methods: {
    ...mapActions({
      logout: 'user/logout'
    }),
    async handleLogout() {
      this.$confirm('确定退出吗', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async () => {
        loginOut()
          .then(async () => {
            this.$message({
              message: '退出成功',
              type: 'success'
            });
            await this.logout();
            this.$router.push('/login');
          })
          .catch(err => {
            console.error(err);
          });
      }).catch(() => {
        // 取消操作
      });
    }
  },
  mounted() {},
};
</script>

<style scoped>
.body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.top {
  width: 100%;
  height: 50px;
  background-color: #ffffff;
  display: flex;
  align-items: center;
  padding: 0 20px;
  box-sizing: border-box;
}
.top > .title {
  font-weight: bold;
  font-size: 20px;
  line-height: 40px;
}
.person {
  margin-left: auto;
  display: flex;
  align-items: center;
}
.person > .person_name {
  font-size: 15px;
  color: black;
  font-weight: 400;
}
.container {
  display: flex;
  width: 100%;
  height: calc(100% - 50px);
  overflow: hidden;
}
.table-container {
  width: calc(100% - 180px);
  overflow: hidden;
  height: 100%;
}
.left {
  width: 180px;
  height: 100%;
  background-color: #ffffff;
  display: flex;
  flex-direction: column;
  border: 5px;
  align-items: center;
}
.left ul {
  width: 100%;
  background-color: #ffffff;
}
.menu_left {
  width: 100%;
  height: 50px;
  text-decoration: none;
  color: rgb(154, 154, 154);
  background-color: #ffffff;
  line-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.menu_left > i {
  margin-right: 10px;
}
.router-link-active {
  background-color: #3d67bc;
  color: rgb(255, 255, 255);
}
.router-link-exact-active {
  background-color: #3d67bc;
  color: rgb(255, 255, 255);
}
</style>