扁平 mock 文件夹结构

Former-commit-id: edb8e0819f6baaf6d19d752916fd746f9062f6fa [formerly edb8e0819f6baaf6d19d752916fd746f9062f6fa [formerly edb8e0819f6baaf6d19d752916fd746f9062f6fa [formerly edb8e0819f6baaf6d19d752916fd746f9062f6fa [formerly 43d43484c561dfb366be8753aa5b461102e522f4 [formerly ce97e5f40c2e049145cace63cdc33c1032d444de]]]]]
Former-commit-id: 089a1e97d20d590cd810555ddb5093be36c4927e
Former-commit-id: 396e69f142ab127168c1ddc23351700d3f950b10
Former-commit-id: 9d77bdac87df7ec8c2e89a91218039cf4782f7fb [formerly 3c3cb317e3111c161c3e0f7edd33f881c23a56af]
Former-commit-id: 594a6423a0489a0c45c995390472f8ccf9aaaa4b
Former-commit-id: 2ce9acf12176cdeddbd0abfe54919e4cbdbd046c
Former-commit-id: 9fac2de7e4e93f2c107443b2e4cf7d9d15e2c3a7
Former-commit-id: f8fba332b2c45d1249fcf9aa4037262afa6028bb
Former-commit-id: 06b541ec993f9fb02646bbb8cc01099a45371c94
This commit is contained in:
liyang
2018-12-10 11:04:46 +08:00
parent d4197f4569
commit 0cf23cba57
6 changed files with 8 additions and 14 deletions

View File

@@ -1,9 +1,13 @@
import Mock from 'mockjs' import Mock from 'mockjs'
// 补丁 解决 mock.js 影响 Cookie 携带 // 解决 Mock 情况下,携带 withCredentials = true且未被拦截的跨域请求丢失 Cookies 的问题
import PatchCookie from './patch/cookie' Mock.XHR.prototype.proxy_send = Mock.XHR.prototype.send
Mock.XHR.prototype.send = function () {
PatchCookie(Mock) if (this.custom.xhr) {
this.custom.xhr.withCredentials = this.withCredentials || false
}
this.proxy_send(...arguments)
}
// 导入所有的接口 // 导入所有的接口
const req = context => context.keys().map(context) const req = context => context.keys().map(context)

View File

@@ -1,10 +0,0 @@
export default function (Mock) {
// 解决 Mock 情况下,携带 withCredentials = true且未被拦截的跨域请求丢失 Cookies 的问题
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)
}
}