Merge branch 'hotfix/mock_cookie' into develop
Former-commit-id: 3c1851b296580793b43a13fae61a4f0e54c8ae9c [formerly 3c1851b296580793b43a13fae61a4f0e54c8ae9c [formerly 3c1851b296580793b43a13fae61a4f0e54c8ae9c [formerly 3c1851b296580793b43a13fae61a4f0e54c8ae9c [formerly f6868eeb1774258c2e08b0519447c6ba504d6812 [formerly 1074f84e5dd01b2731a590d7d840eef2cd56c7e9]]]]] Former-commit-id: d424af7886642a2483b1b8e4ec5db8b2de01f0d8 Former-commit-id: 73caaab600a67a83cdc7cca1df0c96d59dcc7aff Former-commit-id: 29edec4793650b50bba982c3ac4d778530a154c2 [formerly 7fe2a1c7926816fe038150a0faf867070e79da1c] Former-commit-id: 417f6eb6d9853b529e04223e509cb006425d764e Former-commit-id: 9c11f49368da627ccebc0c0f36e3d32415a441dd Former-commit-id: fcfc6f7fcfef9cfa7712149979b84e45e4eec849 Former-commit-id: e90b02db21d1e488b9b90adb47e1c407c4c8e73c Former-commit-id: 61f645c5bed2a5b4680ac57da846bd1655b6d9bf
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "d2-admin",
|
||||
"version": "1.5.2",
|
||||
"version": "1.5.3",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"serve": "vue-cli-service serve --open",
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
import Mock from 'mockjs'
|
||||
|
||||
// 补丁 解决 mock.js 影响 Cookie 携带
|
||||
import PatchCookie from './patch/cookie'
|
||||
|
||||
PatchCookie(Mock)
|
||||
|
||||
// 导入所有的接口
|
||||
const req = context => context.keys().map(context)
|
||||
req(require.context('./api/', true, /\.js$/))
|
||||
|
||||
10
src/mock/patch/cookie/index.js
Normal file
10
src/mock/patch/cookie/index.js
Normal 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user