import { useMessage } from "@/hooks/useMessage";

/**
 * 简化接口返回的数据
 */
const { createMessage } = useMessage()
export function formattedData(res: Recordable) {
    let data = [], total = 0

    if (res.code == 200) {
        data = res.data.records
        total = res.data.total
    } else {
        createMessage.error('返回的数据为空！')
    }

    return {
        data,
        total
    }
}