<template>
  <el-container class="h-full">
    <el-aside :width="isCollapse ? '84px':'240px'" style="background-color: #fff">
      <div class="h-full flex flex-col hidden">
        <div>
          <div v-if="!isCollapse" class="flex p-10 flex-center gap-10">
            <div class="fw-600 color-main">AIGC电商平台</div>
            <el-select v-model="platform" placeholder="" size="small" style="width: 70px">
              <el-option label="用户端" :value="1" />
              <el-option label="管理端" :value="2" />
            </el-select>
          </div>
          <div v-else class="w-60 h-44"></div>
        </div>
        <div class="px-10 flex-1 over-y-auto">
          <el-menu style="border-right: none;" router :default-active="$route.path" :collapse="isCollapse">
            <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="item.icon" 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="item.icon" size="20" class="mr-10 iconscoal" />
                <span>{{ item.name }}</span>
              </el-menu-item>
            </template>
          </el-menu>
        </div>
        <div v-if="!isCollapse">
          <div class="p-10">
            <div class="border-eee round-6 flex-between px-10 py-8">
              <span>可用积分：</span>
              <span>90000</span>
            </div>
          </div>
          <div class="flex-between p-10" style="border-top: 1px solid #eee;">
            <div class="flex-between gap-10">
              <div class="w-40 h-40 bg-main round"></div>
              <div>
                <div>用户名称</div>
                <div class="fs-12 color-888">超级管理员</div>
              </div>
            </div>
            <el-button type="primary" size="small" link @click="isCollapse = !isCollapse">{{ isCollapse ? '展开' : '收起'
              }}</el-button>
          </div>
        </div>
        <div  v-else class="pb-20 pt-10 flex-center">
          <el-button type="primary" size="small" link @click="isCollapse = !isCollapse">{{ isCollapse ? '展开' : '收起'
              }}</el-button>
        </div>
      </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 { ref } from 'vue'
import { useRoute } from 'vue-router';

const platform = ref(1)
const route = useRoute();
const isCollapse = ref(false)
const menus = [
  {
    name: '首页',
    path: '/',
    icon: 'room',
  },
  {
    name: '快速创作',
    path: '/',
    icon: 'add',
  },
  {
    name: 'Agent创作',
    path: '/',
    icon: 'audio',
  },
  {
    name: '爆款复刻',
    path: '/',
    icon: 'caijian',
  },
  {
    name: 'AI视频',
    path: '/',
    icon: 'video',
  },
  {
    name: 'AI图片',
    path: '/',
    icon: 'image',
  },
  {
    name: '画布',
    path: '/',
    icon: 'redraw',
  },
  {
    name: '任务协作',
    path: '/task',
    icon: 'map',
  },
  {
    name: '资源库',
    path: '/resource',
    icon: 'fineness',
    children: [
      {
        name: '成片管理',
        path: '/clip',
      },
      {
        name: '素材管理',
        path: '/material',
      },
      {
        name: '脚本管理',
        path: '/script',
      },
      {
        name: '图片管理',
        path: '/image',
      },
      {
        name: '音频管理',
        path: '/audio',
      },
    ],
  },
  {
    name: '数据分析',
    path: '/analysis',
    icon: 'redraw',
    children: [
      {
        name: '视频数据分析',
        path: '/video',
      },
      {
        name: '广告账户分析',
        path: '/ad',
      },
      {
        name: '部门分析',
        path: '/department',
      }
    ],
  },
];
</script>

<style lang="scss" scoped>
.over-y-auto {
  scrollbar-width: none;
  /* Firefox */
  -ms-overflow-style: none;
  /* IE/Edge */
}

: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>
