<template>
  <div class="brand-layout">
    <el-container class="brand-layout-container">
      <el-aside class="brand-aside-menu">
        <!-- 菜单部分 -->
        <el-menu :default-active="activeMenu" class="aside-menu" @select="handleSelect">
          <el-menu-item index="apply">
            <img :src="getAssetsFile('images/brand/Apply.png')" class="menu-icon" alt="申请图标" />
            <span>使用申请</span>
          </el-menu-item>

          <el-menu-item index="auth">
            <img :src="getAssetsFile('images/brand/autho.png')" class="menu-icon" alt="" />
            <span>授权管理</span>
          </el-menu-item>

          <el-menu-item index="monitor">
            <img :src="getAssetsFile('images/brand/supervision.png')" class="menu-icon" alt="" />
            <span>使用监管</span>
          </el-menu-item>
        </el-menu>
      </el-aside>

      <el-main class="brand-main">
        <router-view />
      </el-main>
    </el-container>
  </div>
</template>

<script setup>
import { computed } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { getAssetsFile } from '@/utils/index.js';

const router = useRouter();
const route = useRoute();

// 激活菜单项
const activeMenu = computed(() => {
  const path = route.path;
  if (path.includes('/apply')) return 'apply';
  if (path.includes('/auth')) return 'auth';
  if (path.includes('/monitor')) return 'monitor';
  return '';
});
// 菜单切换处理
function handleSelect(index) {
  router.push(`/sub-operation-service/brand/${index}`);
}
</script>

<style lang="scss" scoped>
.brand-layout {
  width: 100%;
  height: calc(100vh - 230px);

  .brand-layout-container {
    height: 100%;
    width: $width-main;
    margin: auto;
    .brand-aside-menu {
      width: 240px;
      background-color: $color-fff;
      border-radius: 8px;
      .aside-menu {
        border-right: none;
        .el-menu-item {
          height: 48px;
          line-height: 48px;
          margin: 4px 8px;
          border-radius: 4px;
          font-size: 20px;
          font-weight: 400;
          text-align: left;
          &:hover {
            background-color: #f5f7fa;
          }
          .el-icon {
            color: #666;
            margin-right: 12px;
            font-size: 18px;
            vertical-align: middle;
          }
          .menu-icon {
            width: 1.5em;
            height: 1.5em;
            margin-right: 8px;
            vertical-align: -0.15em;
          }
          span {
            vertical-align: middle;
          }
        }
      }
    }
    .brand-main {
      width: calc(100% - 240px - 16px);
      margin-left: 16px;
      // background-color: #f0f0f0;
      padding: 0;
    }
    .brand-main::-webkit-scrollbar {
      display: none;
    }
  }
}
</style>
