<template>
  <a-menu
      v-model:selectedKeys="selectedKeys"
      mode="inline"
      style="max-height: 200vh; min-height: 100vh;background-color: #ffe7ba"
      @click="handleClick"
  >
    <a-menu-item key="/index">
      <PieChartOutlined />
      <span>首页</span>
    </a-menu-item>
    <a-menu-item key="/userList">
      <UserOutlined />
      <span>用户列表</span>
    </a-menu-item>
    <a-sub-menu>
      <template #title>
            <span>
               <UserOutlined />
              <span>项目管理</span>
            </span>
      </template>
      <a-menu-item key="/project">接单管理</a-menu-item>
    </a-sub-menu>

    <a-sub-menu>
      <template #title>
            <span>
               <CommentOutlined />
              <span>结算管理</span>
            </span>
      </template>
      <a-menu-item key="/applicationRecord">推广码申请记录</a-menu-item>
      <a-menu-item key="/withdrawalApplicationRecord">提现申请记录</a-menu-item>
    </a-sub-menu>
    <a-sub-menu>
      <template #title>
            <span>
              <ReadOutlined />
              <span>课程管理</span>
            </span>
      </template>
      <a-menu-item key="/courseManagement">课程管理</a-menu-item>
      <a-menu-item key="/courseOrder">课程订单</a-menu-item>
    </a-sub-menu>
    <a-sub-menu>
      <template #title>
            <span>
              <FieldTimeOutlined />
              <span>勤工俭学</span>
            </span>
      </template>
      <a-menu-item key="/workList">工作列表</a-menu-item>
      <a-menu-item key="/workDetail">工作详情</a-menu-item>
    </a-sub-menu>

    <a-menu-item key="/community">
      <CommentOutlined />
      <span>社群</span>
    </a-menu-item>
  </a-menu>

</template>

<script setup lang="ts">
import {onMounted, ref} from "vue";
import {UserOutlined, FieldTimeOutlined,ReadOutlined,CommentOutlined,PieChartOutlined} from '@ant-design/icons-vue';
import {useRoute, useRouter} from "vue-router";

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

const selectedKeys = ref<string[]>(['/userList']);

onMounted(() => {
  setSelectedKey()
})


const setSelectedKey = () => {
  selectedKeys.value = [route.path];
}

const handleClick = (item: any) => {
  router.push(item.key)
}

</script>

<style scoped>

:deep(.ant-menu-item),
:deep(.ant-menu-submenu-title) {
  color: rgba(0, 0, 0, 0.85) !important; /* 未选中黑色字体 */
  font-weight: normal !important;
  transition: all 0.3s ease;
}


:deep(.ant-menu-item-selected) {
  background-color: #ffa940 !important;
  color: white !important;
  font-weight: 600 !important;
}


:deep(.ant-menu-item:hover),
:deep(.ant-menu-submenu-title:hover) {
  background-color: rgba(255, 169, 64, 0.1) !important;
}


:deep(.ant-menu-submenu-arrow::before),
:deep(.ant-menu-submenu-arrow::after) {
  background: rgba(0, 0, 0, 0.65) !important;
}


:deep(.ant-menu-submenu-selected  .ant-menu-submenu-title) {
  color: rgba(0, 0, 0, 0.95) !important;
}


:deep(.ant-menu-inline-collapsed .ant-menu-item-selected) {
  background-color: #ffa940 !important;
}
</style>