<template>
  <el-main class="flex">
    <el-container>
      <el-aside class="bg-white manage-page-aside">
        <el-menu router :default-active="$route.fullPath">
          <el-menu-item index="/manage">
            <el-icon><icon-ep-home-filled /></el-icon>
            系统首页
          </el-menu-item>
          <el-sub-menu index="1" v-if="userStore.hasUserPermission(UserPermissionId.MANAGE_USER)">
            <template #title>
              <el-icon><icon-ep-user-filled /></el-icon>
              <span>用户管理</span>
            </template>
            <el-menu-item v-if="userStore.isRouteAccessible('/manage/user')" index="/manage/user">
              <el-icon><icon-ep-user-filled /></el-icon>
              用户管理
            </el-menu-item>
          </el-sub-menu>
          <el-sub-menu index="2">
            <template #title>
              <el-icon><icon-cs-club-black /></el-icon>
              <span>社团管理</span>
            </template>
            <el-menu-item v-if="userStore.isRouteAccessible('/manage/club')" index="/manage/club">
              <el-icon><icon-cs-club-black /></el-icon>
              社团管理
            </el-menu-item>
          </el-sub-menu>
        </el-menu>
      </el-aside>
      <el-container>
        <router-view v-slot="{ Component }">
          <transition name="manage-sub-page" mode="out-in" appear>
            <component :is="Component" class="manage-sub-page" />
          </transition>
        </router-view>
      </el-container>
    </el-container>
  </el-main>
</template>
<style lang="scss" scoped>
.manage-page-aside {
  --el-aside-width: 200px;
  .el-menu--vertical {
    --el-menu-item-height: 50px;
    border-right: none;
  }
}
.manage-sub-page {
  --el-main-padding: 10px;
  &-enter-active,
  &-leave-active {
    transition: opacity 0.25s;
  }
  &-enter-from,
  &-leave-to {
    opacity: 0;
  }
  :deep(.el-card) {
    --el-card-padding: 15px;
  }
}
</style>
<script setup lang="ts">
import { UserPermissionId } from '@/router/permissions';
import { useMediaStore } from '@/stores/media';
import { useUserStore } from '@/stores/user';
import { ElMessage } from 'element-plus';
import { storeToRefs } from 'pinia';
import { onMounted } from 'vue';
const { mdLess } = storeToRefs(useMediaStore());
const userStore = useUserStore();
onMounted(() => {
  if (mdLess.value) {
    ElMessage.warning('暂不支持移动端');
  }
});
</script>
