import { onMounted, ref } from 'vue'

import { type ContactItem, getFriendList } from '@/api/contact'

// 起飞
export function useHook() {
  const dataList = ref<ContactItem[]>([]);

  // 获取数据
  async function onSearch() {
    const { data } = await getFriendList();
    dataList.value = data;
    console.log(data);
  }

  // 挂载时执行
  onMounted(() => {
    onSearch();
  });

  return {
    dataList,
    onSearch
  }
}
