<script setup lang="ts">
import { useWxStoreOutside } from '@/pinia/stores/wx';

const router = useRouter();
const wxStore = useWxStoreOutside();

// const tabbarItemList = computed(() => {
//   const routes = router.getRoutes()
//   return routes.filter(route => route.meta.layout?.tabbar?.showTabbar 
//                       && route.path!== '/approvalAsset/list'
//                       && route.path!== '/productList'
//                     )
//   .map(route => ({
//     title: route.meta.title,
//     icon: route.meta.layout?.tabbar?.icon,
//     path: route.path
//   }))
// });

const tabbarItemList = computed(() => {
  if (wxStore.isCabinetAdmin) {
    return [{
      title: '商品管理',
      icon: 'home-o',
      path: '/manage/goods'
    }, 
    {
      title: '柜机管理',
      icon: 'manager-o',
      path: '/cabinet'
    }, 
    /* {
      title: '审批中心',
      icon: 'records-o',
      path: '/approval/list'
    },  */
    {
      title: '商品动态',
      icon: 'exchange',
      path: '/order/borrow-return-dynamic'
    }, 
    {
      title: '我的',
      icon: 'user-o',
      path: '/'
    }]
  } else {
    return [{
      title: '我的',
      icon: 'user-o',
      path: '/'
    }]
  }
});
</script>

<template>
  <van-tabbar
    route
    fixed
    placeholder
    safe-area-inset-bottom
  >
    <van-tabbar-item
      v-for="item in tabbarItemList"
      :key="item.path"
      :icon="item.icon"
      :to="item.path"
      replace
    >
      {{ item.title }}
    </van-tabbar-item>
  </van-tabbar>
</template>
