import { reactive, toRefs } from "vue"; import { catchError } from "@/utils/common.js" import * as httpCatalogue from "@/api/catalogue.js" import cacheManager from "@/utils/cacheManager"; export function useCatalogue() { const auth = cacheManager.get('auth'); const { cardId = null, nianji = null } = auth const data = reactive({ xueke: null, nianji: null }) data.nianji = nianji; data.xueke = cardId; async function getCatalogue() { return await catchError(httpCatalogue.getCatalogue({ nianji: +data.nianji, cardId: +data.xueke })); } return { ...toRefs(data), // 获取章节数据 getCatalogue } }