Merge remote-tracking branch 'origin/develop'

Former-commit-id: d0fa704b1dad757a9fb8bc908d710489e108c8ac
This commit is contained in:
liyang
2018-10-13 20:54:23 +08:00
3 changed files with 16 additions and 1 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "d2-admin", "name": "d2-admin",
"version": "1.5.2", "version": "1.5.3",
"scripts": { "scripts": {
"serve": "vue-cli-service serve --open", "serve": "vue-cli-service serve --open",
"start": "vue-cli-service serve --open", "start": "vue-cli-service serve --open",
+5
View File
@@ -1,5 +1,10 @@
import Mock from 'mockjs' import Mock from 'mockjs'
// 补丁 解决 mock.js 影响 Cookie 携带
import PatchCookie from './patch/cookie'
PatchCookie(Mock)
// 导入所有的接口 // 导入所有的接口
const req = context => context.keys().map(context) const req = context => context.keys().map(context)
req(require.context('./api/', true, /\.js$/)) req(require.context('./api/', true, /\.js$/))
+10
View File
@@ -0,0 +1,10 @@
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)
}
}