import { TabesItem } from '@/service/app'
import { sysDictType } from '@/service/index/api'
import { useUserStore } from '@/store'

const tabbarList = ref<TabesItem[]>([])
const userStore = useUserStore()

sysDictType({ id: 619330547859525 }).then((res) => {
  const { code, result } = res
  const _tabbarList = [
    {
      id: 0,
      path: '/pages/home/index/index',
      icon: '/static/tabBar/home.png',
      selectIcon: '/static/tabBar/home-active.png',
      text: '首页',
      centerItem: false,
    },
    {
      id: 3,
      path: '/pages/evaluation/index/index',
      icon: '/static/tabBar/news.png',
      selectIcon: '/static/tabBar/news-active.png',
      text: '测评',
      centerItem: false,
    },
    {
      id: 2,
      path: '/aiService-sub/index/index',
      icon: '/static/tabBar/ai.png',
      selectIcon: '/static/tabBar/ai-active.png',
      text: '',
      centerItem: true,
      navigatorItem: true,
    },
    {
      id: 1,
      path: '/pages/expert/index/index',
      icon: '/static/tabBar/place.png',
      selectIcon: '/static/tabBar/place-active.png',
      text: '专家',
      centerItem: false,
    },
    {
      id: 4,
      path: '/pages/ucenter/index/index',
      icon: '/static/tabBar/center.png',
      selectIcon: '/static/tabBar/center-active.png',
      text: '我的',
      centerItem: false,
    },
  ]
  const { status } = result as { status: number }
  if (code === 200) {
    if (status === 1) {
      tabbarList.value = _tabbarList.filter((item) => item.id !== 2)
      userStore.setIsShowAi(false)
    } else {
      tabbarList.value = _tabbarList
      userStore.setIsShowAi(true)
    }
  }
})

export { tabbarList }
