<template>
  <el-container style="height: 650px; border: 1px solid #eee">
    <el-header style="text-align: right; font-size: 12px">
      <el-col :md="2">
        <ul class="el-menu--horizontal el-menu">
          <li class="el-menu-item">
            <a href="/admin" style="text-decoration-line: none">
              <img src="@/assets/img/icon/logo.png" class="el-avatar--circle el-avatar--medium" alt="img">
              admin
            </a>
          </li>
        </ul>
      </el-col>
      <el-dropdown>
        <img
          :src="user.avatarUrl"
          class="el-avatar--circle el-avatar--medium"
          style="margin-right: 10px; margin-top: 15px"
          alt=""
        >
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item
            icon="el-icon-error"
            class="size"
            @click.native="goToLogout"
          >退出</el-dropdown-item>
          <el-dropdown-item>查看</el-dropdown-item>
          <el-dropdown-item>新增</el-dropdown-item>
          <el-dropdown-item>删除</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </el-header>
    <el-container>
      <el-aside width="200px" style="background-color: rgb(238, 241, 246)">
        <el-menu
          :default-active="this.$route.path"
          router
          class="el-menu-vertical-demo"
          :collapse="isCollapse"
          @open="handleOpen"
          @close="handleClose"
        >
          <el-menu-item index="/admin/site">
            <i class="el-icon-apple" />
            <span slot="title">站点配置</span>
          </el-menu-item>
          <el-menu-item index="/admin/user">
            <i class="el-icon-user" />
            <span slot="title">用户列表</span>
          </el-menu-item>
          <el-menu-item index="/admin/post">
            <i class="el-icon-postcard" />
            <span slot="title">稿件列表</span>
          </el-menu-item>
          <el-menu-item index="/admin/datasource">
            <i class="el-icon-date" />
            <span slot="title">数据源</span>
          </el-menu-item>
        </el-menu>
      </el-aside>
      <el-main>
        <router-view />
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
import { getAuthedUser } from '@/utils/auth'

export default {
  data() {
    return {
      user: null
    }
  },
  created() {
    document.title = '后台管理'
    const userInfo = getAuthedUser()
    if (userInfo !== null) {
      this.user = userInfo
    }
  }
}
</script>

<style>
.el-header {
  background-color: #B3C0D1;
  color: #333;
  line-height: 60px;
}

.el-aside {
  color: #333;
}
</style>
