<template>
  <div class="featureBox">
    <el-menu
      default-active="2"
      class="el-menu-vertical-demo dark-mode"
      :collapse="isCollapse"
    >
      <template v-for="item in menuList" :key="item.key">
        <el-sub-menu :index="item.path" v-if="item.children" class="menuBox">
          <template #title>
            <img :src="getUrl(item.icon)" alt="" />
            <span>{{ item.name }}</span>
          </template>
          <el-menu-item
            v-for="son in item.children"
            :index="son.path"
            @click="jumpModule(son.path)"
          >
            <template #title>
              <span class="muneName">{{ son.name }}</span>
            </template>
          </el-menu-item>
        </el-sub-menu>

        <el-menu-item :index="item.path" @click="jumpModule(item.path)" v-else>
          <img :src="getUrl(item.icon)" alt="" />
          <template #title>
            <span class="muneName">{{ item.name }}</span>
          </template>
        </el-menu-item>
      </template>
      <slot />
    </el-menu>
  </div>
</template>
<script setup>
import { reactive } from "vue";
import { useRouter } from "vue-router";
import "@/style/zwgk/menuModule.less";
const router = useRouter();

const menuList = reactive([
  {
    path: "zfxxgkzn",
    icon: "zwxxgk_bnt01",
    name: "政府信息公开指南",
  },
  {
    path: "zfxxgkzd",
    icon: "zwxxgk_bnt02",
    name: "政府信息公开制度",
  },
  {
    path: "zfxxgknb",
    icon: "zwxxgk_bnt02",
    name: "政府信息公开年报",
  },
  {
    path: "fdgknr",
    icon: "zwxxgk_bnt03",
    name: "法定公开内容",
    children: [
      {
        path: "fdgknr/lzyj",
        name: "履职依据",
      },
      {
        path: "fdgknr/jgzz",
        name: "机构职能",
      },
      {
        path: "fdgknr/ldzc",
        name: "领导之窗",
      },
      {
        path: "fdgknr/zdgkwj",
        name: "主动公开文件",
      },
      {
        path: "fdgknr/xzcf",
        name: "行政处罚",
      },
      {
        path: "fdgknr/xzxk",
        name: "行政许可",
      },
      {
        path: "fdgknr/ghjh",
        name: "规划计划",
      },
      {
        path: "fdgknr/czys",
        name: "财政预决算",
      },
    ],
  },
  {
    path: "zcwj",
    icon: "zwxxgk_bnt02",
    name: "政策文件",
  },
  {
    path: "zcjd",
    icon: "zwxxgk_bnt06",
    name: "政策解读",
  },
  {
    path: "xzgfxwj",
    icon: "zwxxgk_bnt06",
    name: "行政规范性文件",
  },
  {
    path: "ysqgk",
    icon: "zwxxgk_bnt06",
    name: "依申请公开",
  },
  {
    path: "zfwzgznb",
    icon: "zwxxgk_bnt06",
    name: "政府网站工作年报",
  },
]);
function jumpModule(path) {
  router.push("/zwgk/" + path);
}
function getUrl(name) {
  return new URL(`../../../assets/logo/${name}.png`, import.meta.url).href;
}
</script>
