import { api, type HelpDoc } from "@/api/help";
import { onMounted, ref } from "vue";

export function useHelp() {
  const menuItems = ref<Array<HelpDoc>>([]);

  const getMenuItems = async () => {
    const res = await api.listHelpTree({});
    // console.log(res);
    menuItems.value = res.data;
  };

  const getDoc = async (id: any) => {
    const res = await api.getDoc(id);
    // console.log(res);
    return res.data;
  };

  onMounted(async () => {
    await getMenuItems();
  });

  return {
    menuItems,
    getDoc
  };
}
