// 高校排名类型
import { getUnSortType, getUniversityRank } from '@/service/index/api'

type UnSortType = { type: number; name: string }[]

export const useUnSortType = () => {
  let unSortTypeList = ref<any[]>([])
  getUnSortType().then((res) => {
    unSortTypeList.value = res.result as UnSortType
  })

  return { unSortTypeList }
}

export const useUniversityRank = ({
  Year,
  Type,
  PageSize,
  PageIndex,
}: {
  Year: number
  Type: number
  PageSize: number
  PageIndex: number
}) => {
  let universityRankList = ref<any[]>([])
  getUniversityRank({ Year, Type, PageSize, PageIndex }).then((res) => {
    if (res.code === 200) {
      const _res = res.result as { rows: any[] }
      universityRankList.value = _res.rows
    }
  })

  return { universityRankList }
}
