Newer
Older
CallCenterFront / mock / index.js
StephanieGitHub on 1 Apr 2020 852 bytes create
import Mock from 'mockjs'

import user from './system/user'
import resource from './system/resource'
import dict from './system/dict'
import dept from './system/dept'
import area from './system/area'
import role from './system/role'
import log from './system/log'
import config from './system/config'
import search from './remote-search'

const mocks = [
  ...user,
  ...resource,
  ...dict,
  ...area,
  ...dept,
  ...role,
  ...log,
  ...config,
  ...search
]

Mock.XHR.prototype.proxy_send = Mock.XHR.prototype.send
Mock.XHR.prototype.send = function() {
  if (this.custom.xhr) {
    this.custom.xhr.withCredentials = this.withCredentials || false
  }
  this.proxy_send(...arguments)
}
Mock.setup({
  timeout: '350-600'
})

for (const i of mocks) {
  console.log(i)
  Mock.mock(new RegExp(i.url), i.type || 'get', i.response)
}

export default Mock