<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="/my" style="text-decoration-line: none">
              <img src="@/assets/img/icon/logo.png" class="el-avatar--circle el-avatar--medium" alt="img">
              my
            </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-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-submenu index="/my/account">
            <template slot="title">
              <i class="el-icon-user" />
              <span slot="title">帐号管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="/my/account/profile">
                <i class="el-icon-film" />
                <span slot="title">个人资料</span>
              </el-menu-item>
              <el-menu-item index="/my/account/vip">
                <i class="el-icon-film" />
                <span slot="title">小会员</span>
              </el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="/my/post">
            <template slot="title">
              <i class="el-icon-postcard" />
              <span slot="title">稿件管理</span>
            </template>
            <el-submenu index="/my/post/publish">
              <template slot="title">
                <i class="el-icon-plus" />
                <span slot="title">发布</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="/my/post/publish/video">
                  <i class="el-icon-film" />
                  <span slot="title">视频</span>
                </el-menu-item>
                <el-menu-item index="/my/post/publish/audio">
                  <i class="el-icon-headset" />
                  <span slot="title">音频</span>
                </el-menu-item>
                <el-menu-item index="/my/post/publish/image">
                  <i class="el-icon-picture" />
                  <span slot="title">相册</span>
                </el-menu-item>
                <el-menu-item index="/my/post/publish/article">
                  <i class="el-icon-document" />
                  <span slot="title">文章</span>
                </el-menu-item>
                <el-menu-item index="/my/post/publish/file">
                  <i class="el-icon-files" />
                  <span slot="title">文件</span>
                </el-menu-item>
              </el-menu-item-group>
            </el-submenu>
            <el-submenu index="/my/post/list">
              <template slot="title">
                <i class="el-icon-s-data" />
                <span slot="title">稿件</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="/my/post/list/video">
                  <i class="el-icon-film" />
                  <span slot="title">视频</span>
                </el-menu-item>
                <el-menu-item index="/my/post/list/audio">
                  <i class="el-icon-headset" />
                  <span slot="title">音频</span>
                </el-menu-item>
                <el-menu-item index="/my/post/list/image">
                  <i class="el-icon-picture" />
                  <span slot="title">相册</span>
                </el-menu-item>
                <el-menu-item index="/my/post/list/article">
                  <i class="el-icon-document" />
                  <span slot="title">文章</span>
                </el-menu-item>
              </el-menu-item-group>
            </el-submenu>
          </el-submenu>
          <el-submenu index="/my/favlist">
            <template slot="title">
              <i class="el-icon-collection" />
              <span slot="title">收藏夹</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="/my/favlist/video">
                <i class="el-icon-film" />
                <span slot="title">视频</span>
              </el-menu-item>
              <el-menu-item index="/my/favlist/image">
                <i class="el-icon-picture" />
                <span slot="title">相册</span>
              </el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-menu-item index="/my/visit">
            <i class="el-icon-document" />
            <span slot="title">历史记录</span>
          </el-menu-item>
          <el-submenu index="/my/message">
            <template slot="title">
              <i class="el-icon-message" />
              <span slot="title">我的消息</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="/my/message/send">
                <i class="el-icon-right" />
                <span slot="title">发出的消息</span>
              </el-menu-item>
              <el-menu-item index="/my/message/receive">
                <i class="el-icon-back" />
                <span slot="title">收到的消息</span>
              </el-menu-item>
              <el-menu-item index="/my/message/private">
                <i class="el-icon-bell" />
                <span slot="title">私信</span>
              </el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="/my/cam">
            <template slot="title">
              <i class="el-icon-camera" />
              <span slot="title">我的监控</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="/my/cam/list">
                <i class="el-icon-camera" />
                <span slot="title">摄像头列表</span>
              </el-menu-item>
            </el-menu-item-group>
          </el-submenu>
        </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>
