You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
737 B
JavaScript

import Mock from 'mockjs'
import user from './user'
import home from './home'
import category from './category'
import product from './product'
5 years ago
import detail from './detail'
import cart from './cart'
const mocks = [...user, ...home, ...category, ...product, ...detail, ...cart]
5 years ago
const delayApi = [
'/prod-api/user/login',
'/prod-api/home/list',
'/prod-api/product/list',
'/prod-api/goods/detail',
'/prod-api/cart/list'
]
// https://github.com/nuysoft/Mock/wiki
export function mockXHR() {
for (const item of mocks) {
Mock.mock(item.url, item.type, item.response)
// 为了效果演示,定义一些接口延时
5 years ago
if (delayApi.includes(item.url)) {
Mock.setup({
timeout: 1000
})
}
}
}