<template>
  <!-- <h1>{{ navStore.topNavList }}</h1> -->
  <subMenu :menuList="menuInfo.menuList" :collapse="menuInfo.collapse" :backgroundColor="menuInfo.backgroundColor"
    :textColor="menuInfo.textColor" :activeTextColor="menuInfo.activeTextColor" :defaultActive="navStore.defaultActive"
    :defaultOpeneds="menuInfo.defaultOpeneds" :uniqueOpened="menuInfo.uniqueOpened" :menuTrigger="menuInfo.menuTrigger"
    :router="menuInfo.router" :collapseTransition="menuInfo.collapseTransition" :popperEffect="menuInfo.popperEffect"
    :isCustomLink="menuInfo.isCustomLink" :customLinkCallBack="menuInfo.customLinkCallBack"></subMenu>
</template>
<script setup lang="ts">
import subMenu from './sideBar/subMenu.vue';
import { comNavStore } from "store/comNav"
import { permissionStore } from "store/permission"
import {list} from "router/routerData"
const navStore = comNavStore()
const permissionStoreInstance = permissionStore()
const routes = useRoute()
const router = useRouter()
const menuInfo: any = reactive({
  collapse: false,
  backgroundColor: '#fff',
  textColor: "",
  activeTextColor: '',
  defaultActive: "",
  defaultOpeneds: ['staticDefault_PathParent&&配置管理'],
  router: false,
  collapseTransition: true,
  menuList: list,
  isCustomLink: true,
  customLinkCallBack: (ev: any) => {
    console.log("customLinkCallBack", ev)
    if (ev.title.startsWith('staticDefault')) {
      return
    }
    router.push({
      name: ev.path
    })
    navStore.setDefaultActive(ev)
    navStore.addNavTarget(ev)
  }
})

onMounted(() => {
  console.log("routes", router.getRoutes())
  initRouteList()



})


const initRouteList = () => {
  // const routeList = router.getRoutes() 
  // menuInfo.menuList = routeList.find(ele=>ele.meta.routeListRoot)?.children
  // menuInfo.defaultOpeneds = menuInfo.menuList[0].path
  // console.log("menuInfo.menuList",menuInfo.menuList)
  menuInfo.defaultOpeneds.push()
  const routes: any = list
  console.log("routes", router)
  const currentNav = routes.find((ele:any)=>ele.meta.folder).children[0]
  // if (navStore.topNavList.length == 0) {
  //   let firstNav = {
  //     title: currentNav.meta.title,
  //     name: currentNav.name,
  //     path: currentNav.path
  //   }
  //   navStore.addNavTarget(firstNav)
  //   navStore.setCurrentNav(currentNav.path)
  // }
  console.log("currentNav", currentNav)
  menuInfo.defaultActive = currentNav.name + '&&' + currentNav.meta.title
  console.log("currentNav", menuInfo.defaultActive)
}
</script>
  
<style scoped></style>
  