import homeApi from '~/api/home'
import aboutApi from '~/api/about'
import userApi from '~/api/user'

/**
 * 将api注入到全局
 * 
 * 在页面或组件里使用
 *  async mounted() {
        const games = await this.$api.game.getGameList({ page: 1 })
    }

    async asyncData({ app }) {
        const games = await app.$api.game.getGameList({ page: 1 })
    },

 */
export default ({ $axios }, inject) => {
    const api = {
        home: homeApi($axios),
        about: aboutApi($axios),
        user: userApi($axios),
    }

    inject('api', api) // 将api注入到全局
}
