Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
DoraemonKit
提交
5c9afaf7
D
DoraemonKit
项目概览
DiDi
/
DoraemonKit
9 个月 前同步成功
通知
166
Star
19623
Fork
3062
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
DoraemonKit
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
5c9afaf7
编写于
8月 30, 2021
作者:
C
caoenze
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
bugfix: 修复因API MOCK请求拦截未考虑请求方法导致的跨域错误
上级
9a746eb6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
26 addition
and
26 deletion
+26
-26
Web/packages/web/src/plugins/api-mock/index.js
Web/packages/web/src/plugins/api-mock/index.js
+3
-1
Web/packages/web/src/plugins/api-mock/main.vue
Web/packages/web/src/plugins/api-mock/main.vue
+0
-2
Web/playground/index.html
Web/playground/index.html
+23
-23
未找到文件。
Web/packages/web/src/plugins/api-mock/index.js
浏览文件 @
5c9afaf7
...
...
@@ -3,7 +3,7 @@ import {getGlobalData, RouterPlugin} from '@dokit/web-core'
import
{
getPartUrlByParam
}
from
"
@dokit/web-utils
"
;
import
{
request
}
from
'
./../../assets/util
'
const
mockBaseUrl
=
"
https://
pre
.dokit.cn
"
;
const
mockBaseUrl
=
"
https://
www
.dokit.cn
"
;
const
getCheckedInterfaceList
=
function
(
interfaceList
)
{
return
interfaceList
.
filter
(
i
=>
i
.
checked
)
...
...
@@ -80,6 +80,7 @@ export default new RouterPlugin({
})
}
})
sceneId
&&
fetchArgs
[
1
]
&&
(
fetchArgs
[
1
].
method
=
'
get
'
)
sceneId
&&
(
fetchArgs
[
0
]
=
`
${
mockBaseUrl
}
/api/app/scene/
${
sceneId
}
`
)
return
fetchArgs
;
}
...
...
@@ -99,6 +100,7 @@ export default new RouterPlugin({
})
}
})
sceneId
&&
(
args
[
0
]
=
'
get
'
)
sceneId
&&
(
args
[
1
]
=
`
${
mockBaseUrl
}
/api/app/scene/
${
sceneId
}
`
)
return
args
;
},
...
...
Web/packages/web/src/plugins/api-mock/main.vue
浏览文件 @
5c9afaf7
...
...
@@ -13,8 +13,6 @@
<
script
>
import
interfaceItem
from
"
./interface-item
"
;
const
mockBaseUrl
=
"
https://pre.dokit.cn
"
;
export
default
{
components
:
{
interfaceItem
,
...
...
Web/playground/index.html
浏览文件 @
5c9afaf7
...
...
@@ -12,36 +12,36 @@
<h1>
DoKit For Web
</h1>
<h2>
Playground
</h2>
</body>
<script
src=
"https://
unpkg.com/vue@next
"
></script>
<script
src=
"https://
cdn.bootcdn.net/ajax/libs/vue/3.1.5/vue.global.js
"
></script>
<script
src=
"../packages/web/dist/dokit.js"
></script>
<script>
Dokit
.
setProductId
(
'
379cca45571436f86c31d687578541fc
'
)
</script>
<script>
setTimeout
(()
=>
{
// fetch('https://www.tianqiapi.com/free/day
?appid=68852321&appsecret=BgGLDVc7', {
//
body: JSON.stringify({
//
a:1
//
}),
// method: 'ge
t',
//
})
//
.then((response) => {
//
let weatherInfo = response.json();
//
return weatherInfo;
//
})
//
.then((info) => {
//
console.log('weatherInfo', info)
//
});
fetch
(
'
https://www.tianqiapi.com/free/week
?appid=68852321&appsecret=BgGLDVc7
'
,
{
//
body: JSON.stringify({
//
a:1
//
}),
method
:
'
pos
t
'
,
})
.
then
((
response
)
=>
{
let
weatherInfo
=
response
.
json
();
return
weatherInfo
;
})
.
then
((
info
)
=>
{
console
.
log
(
'
weatherInfo
'
,
info
)
});
function
reqListener
()
{
console
.
log
(
'
asasdasd
'
,
this
.
responseText
);
}
var
oReq
=
new
XMLHttpRequest
();
oReq
.
addEventListener
(
"
load
"
,
reqListener
);
oReq
.
open
(
"
post
"
,
"
https://www.tianqiapi.com/free/week?appid=68852321&appsecret=BgGLDVc7
"
);
oReq
.
send
(
JSON
.
stringify
({
a
:
1
}));
//
function reqListener () {
//
console.log('asasdasd', this.responseText);
//
}
//
var oReq = new XMLHttpRequest();
//
oReq.addEventListener("load", reqListener);
//
oReq.open("post", "https://www.tianqiapi.com/free/week?appid=68852321&appsecret=BgGLDVc7");
//
oReq.send(JSON.stringify({
//
a:1
//
}));
},
5000
);
</script>
</html>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录