<template>
  <el-container class="h-full">
    <el-aside width="240px" style="background-color: #fff">
      <div class="fs-50 p-10">LOGO</div>
      <div class="px-10">
        <el-menu style="border-right: none;" router :default-active="$route.path">
          <template v-for="(item, index) in menus" :key="index">
            <el-sub-menu v-if="item.children && item.children.length" :index="item.path">
              <template #title>
                <SvgIcon name="HD" size="20" class="mr-10 iconscoal" />
                <span>{{ item.name }}</span>
              </template>
              <el-menu-item v-for="(child, cindex) in item.children" :key="cindex" :index="item.path + child.path">
                <span class="ml-20">{{ child.name }}</span>
              </el-menu-item>
            </el-sub-menu>
            <el-menu-item v-else :index="item.path">
              <SvgIcon name="HD" size="20" class="mr-10 iconscoal" />
              <span>{{ item.name }}</span>
            </el-menu-item>
          </template>
        </el-menu>
      </div>
    </el-aside>
    <el-main class="p-0">
      <router-view v-slot="{ Component }">
        <transition name="fade" mode="out-in">
          <component :is="Component" :key="route.fullPath" />
        </transition>
      </router-view>
    </el-main>
  </el-container>
</template>

<script setup lang="ts">
import { useRoute } from 'vue-router';
const route = useRoute();

const menus = [
  {
    name: '首页',
    path: '/',
    icon: 'el-icon-s-home',
  },
  {
    name: '快速创作',
    path: '/',
    icon: 'el-icon-s-home',
  },
  {
    name: 'Agent创作',
    path: '/',
    icon: 'el-icon-s-home',
  },
  {
    name: '爆款复刻',
    path: '/',
    icon: 'el-icon-s-home',
  },
  {
    name: 'AI视频',
    path: '/',
    icon: 'el-icon-s-home',
  },
  {
    name: 'AI图片',
    path: '/',
    icon: 'el-icon-s-home',
  },
  {
    name: '画布',
    path: '/',
    icon: 'el-icon-s-home',
  },
  {
    name: '任务协作',
    path: '/',
    icon: 'el-icon-s-home',
  },
  {
    name: '资源库',
    path: '/resource',
    icon: 'el-icon-s-home',
    children: [
      {
        name: '成片管理',
        path: '/clip',
      },
      {
        name: '素材管理',
        path: '/material',
      },
      {
        name: '脚本管理',
        path: '/script',
      },
      {
        name: '图片管理',
        path: '/image',
      },
      {
        name: '音频管理',
        path: '/audio',
      }
    ],
  },
];
</script>

<style lang="scss" scoped>
:deep(.el-menu-item) {
  height: 44px;
  margin-top: 4px;

  &.is-active {
    background-color: #f1e3ff;
    border-radius: 10px;
  }

  &:hover {
    border-radius: 10px;

    .iconscoal {
      transition: all 0.3s ease-in-out;
      transform: scale(1.1);
    }
  }
}

:deep(.el-sub-menu__title) {
  height: 44px;
  margin-top: 4px;

  &:hover {
    border-radius: 10px;

    .iconscoal {
      transition: all 0.3s ease-in-out;
      transform: scale(1.1);
    }
  }
}
</style>
