index.js 733 B

1234567891011121314151617181920212223242526
  1. import Mock from 'mockjs'
  2. import userAPI from './user'
  3. import tableAPI from './table'
  4. // Fix an issue with setting withCredentials = true, cross-domain request lost cookies
  5. // https://github.com/nuysoft/Mock/issues/300
  6. Mock.XHR.prototype.proxy_send = Mock.XHR.prototype.send
  7. Mock.XHR.prototype.send = function() {
  8. if (this.custom.xhr) {
  9. this.custom.xhr.withCredentials = this.withCredentials || false
  10. }
  11. this.proxy_send(...arguments)
  12. }
  13. // Mock.setup({
  14. // timeout: '350-600'
  15. // })
  16. // User
  17. Mock.mock(/\/user\/login/, 'post', userAPI.login)
  18. Mock.mock(/\/user\/info/, 'get', userAPI.getInfo)
  19. Mock.mock(/\/user\/logout/, 'post', userAPI.logout)
  20. // Table
  21. Mock.mock(/\/table\/list/, 'get', tableAPI.list)
  22. export default Mock