<template>
  <el-container>
    <el-header>
      <el-row>
        <el-col :span="24">
          <h1>欢迎使用测盟汇管理系统</h1>
        </el-col>
      </el-row>
    </el-header>
    <el-main>
      <el-row :gutter="20">
        <el-col :span="8">
          <el-card shadow="hover">
            <h2>认证管理</h2>
            <el-menu :default-active="activeMenu" router>
              <el-menu-item index="/login">登录</el-menu-item>
              <el-menu-item index="/register">注册</el-menu-item>
              <el-menu-item index="/manageProfile">管理个人资料</el-menu-item>
              <el-menu-item index="/profile">个人资料</el-menu-item>
            </el-menu>
          </el-card>
        </el-col>
        <el-col :span="8">
          <el-card shadow="hover">
            <h2>新闻管理</h2>
            <el-menu :default-active="activeMenu" router>
              <el-menu-item index="/news">新闻列表</el-menu-item>
              <el-menu-item index="/news/edit">编辑新闻</el-menu-item>
            </el-menu>
          </el-card>
        </el-col>
        <el-col :span="8">
          <el-card shadow="hover">
            <h2>课程管理</h2>
            <el-menu :default-active="activeMenu" router>
              <el-menu-item index="/course">课程</el-menu-item>
              <el-menu-item index="/courseList">课程列表</el-menu-item>
            </el-menu>
          </el-card>
        </el-col>
      </el-row>
      <el-row :gutter="20" style="margin-top: 20px;">
        <el-col :span="8">
          <el-card shadow="hover">
            <h2>组织管理</h2>
            <el-menu :default-active="activeMenu" router>
              <el-menu-item index="/organizations">组织机构</el-menu-item>
            </el-menu>
          </el-card>
        </el-col>
        <el-col :span="8">
          <el-card shadow="hover">
            <h2>会议管理</h2>
            <el-menu :default-active="activeMenu" router>
              <el-menu-item index="/Meeting">会议管理</el-menu-item>
              <el-menu-item index="/Meeting/add">添加会议</el-menu-item>
            </el-menu>
          </el-card>
        </el-col>
        <el-col :span="8">
          <el-card shadow="hover">
            <h2>用户管理</h2>
            <el-menu :default-active="activeMenu" router>
              <el-menu-item index="/tenantManagement">租户管理</el-menu-item>
              <el-menu-item index="/addUser">添加用户</el-menu-item>
              <el-menu-item index="/addTenant">添加租户</el-menu-item>
              <el-menu-item index="/userManagement">用户管理</el-menu-item>
            </el-menu>
          </el-card>
        </el-col>
      </el-row>
    </el-main>
  </el-container>
</template>

<script setup>
import {ref} from 'vue'
import {useRouter} from 'vue-router'
import 'element-plus/dist/index.css'
import {useStore} from 'vuex'

const router = useRouter()
const store = useStore()
const activeMenu = ref(router.currentRoute.value.path)

if (store.getters['authentication/token'] == null) {
  router.push('/login')
}
</script>

<style scoped>
h1 {
  text-align: center;
  margin: 20px 0;
  color: #3a3a3a;
  font-weight: bold;
}

h2 {
  margin-bottom: 10px;
  color: #2c3e50;
}

.el-card {
  padding: 20px;
  border-radius: 8px;
  border: 1px solid #ebeef5;
}

.el-menu-item {
  font-size: 14px;
  color: #606266;
}

.el-menu-item:hover {
  color: #409eff;
}

.el-container {
  background-color: #f5f7fa;
  padding: 30px;
}
</style>