Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MeterSphere
metersphere
提交
ac6466ff
M
metersphere
项目概览
MeterSphere
/
metersphere
上一次同步 3 年多
通知
25
Star
1
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
metersphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ac6466ff
编写于
7月 28, 2020
作者:
C
chenjianxing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 接口测试结果格式化
上级
d7df95c7
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
150 addition
and
3 deletion
+150
-3
frontend/package.json
frontend/package.json
+2
-1
frontend/src/business/components/api/report/components/ResponseText.vue
...usiness/components/api/report/components/ResponseText.vue
+19
-2
frontend/src/business/components/common/components/MsCodeEdit.vue
.../src/business/components/common/components/MsCodeEdit.vue
+74
-0
frontend/src/business/components/common/components/MsDropdown.vue
.../src/business/components/common/components/MsDropdown.vue
+55
-0
未找到文件。
frontend/package.json
浏览文件 @
ac6466ff
...
...
@@ -34,7 +34,8 @@
"babel-eslint"
:
"^10.0.3"
,
"eslint"
:
"^5.16.0"
,
"eslint-plugin-vue"
:
"^5.0.0"
,
"vue-template-compiler"
:
"^2.6.10"
"vue-template-compiler"
:
"^2.6.10"
,
"vue2-ace-editor"
:
"0.0.15"
},
"eslintConfig"
:
{
"root"
:
true
,
...
...
frontend/src/business/components/api/report/components/ResponseText.vue
浏览文件 @
ac6466ff
...
...
@@ -7,7 +7,7 @@
<el-collapse-transition>
<el-tabs
v-model=
"activeName"
v-show=
"isActive"
>
<el-tab-pane
label=
"Body"
name=
"body"
class=
"pane"
>
<
div>
{{
response
.
body
}}
</div
>
<
ms-code-edit
:read-only=
"true"
:data=
"response.body"
:modes=
"modes"
ref=
"codeEdit"
/
>
</el-tab-pane>
<el-tab-pane
label=
"Headers"
name=
"headers"
class=
"pane"
>
<pre>
{{
response
.
headers
}}
</pre>
...
...
@@ -15,6 +15,13 @@
<el-tab-pane
:label=
"$t('api_report.assertions')"
name=
"assertions"
class=
"pane assertions"
>
<ms-assertion-results
:assertions=
"response.assertions"
/>
</el-tab-pane>
<el-tab-pane
v-if=
"activeName == 'body'"
:disabled=
"true"
name=
"mode"
class=
"pane assertions"
>
<template
v-slot:label
>
<ms-dropdown
:commands=
"modes"
@
command=
"modeChange"
/>
</
template
>
</el-tab-pane>
</el-tabs>
</el-collapse-transition>
</div>
...
...
@@ -22,11 +29,17 @@
<
script
>
import
MsAssertionResults
from
"
./AssertionResults
"
;
import
MsCodeEdit
from
"
../../../common/components/MsCodeEdit
"
;
import
MsDropdown
from
"
../../../common/components/MsDropdown
"
;
export
default
{
name
:
"
MsResponseText
"
,
components
:
{
MsAssertionResults
},
components
:
{
MsDropdown
,
MsCodeEdit
,
MsAssertionResults
,
},
props
:
{
response
:
Object
...
...
@@ -36,12 +49,16 @@
return
{
isActive
:
false
,
activeName
:
"
body
"
,
modes
:
[
'
text
'
,
'
json
'
,
'
xml
'
,
'
html
'
],
}
},
methods
:
{
active
()
{
this
.
isActive
=
!
this
.
isActive
;
},
modeChange
(
mode
)
{
this
.
$refs
.
codeEdit
.
setMode
(
mode
);
}
},
}
...
...
frontend/src/business/components/common/components/MsCodeEdit.vue
0 → 100644
浏览文件 @
ac6466ff
<
template
>
<editor
v-model=
"formatData"
:lang=
"mode"
@
init=
"editorInit"
theme=
"chrome"
/>
</
template
>
<
script
>
export
default
{
name
:
"
MsCodeEdit
"
,
components
:
{
editor
:
require
(
'
vue2-ace-editor
'
)},
data
()
{
return
{
mode
:
'
text
'
,
formatData
:
''
}
},
props
:
{
data
:
{
type
:
String
},
init
:
{
type
:
Function
},
readOnly
:
{
type
:
Boolean
,
default
()
{
return
false
;
}
},
modes
:
{
type
:
Array
,
default
()
{
return
[
'
text
'
,
'
json
'
,
'
xml
'
,
'
html
'
];
}
}
},
mounted
()
{
this
.
format
();
},
methods
:
{
editorInit
:
function
(
editor
)
{
require
(
'
brace/ext/language_tools
'
)
//language extension prerequsite...
this
.
modes
.
forEach
(
mode
=>
{
require
(
'
brace/mode/
'
+
mode
);
//language
});
require
(
'
brace/theme/chrome
'
)
require
(
'
brace/snippets/javascript
'
)
//snippet
if
(
this
.
readOnly
)
{
editor
.
setReadOnly
(
true
);
}
if
(
this
.
init
)
{
this
.
init
(
editor
);
}
},
format
()
{
if
(
this
.
mode
===
'
json
'
)
{
try
{
this
.
formatData
=
JSON
.
stringify
(
JSON
.
parse
(
this
.
data
),
null
,
'
\t
'
);
}
catch
(
e
)
{
this
.
formatData
=
this
.
data
;
}
}
else
{
this
.
formatData
=
this
.
data
;
}
},
setMode
(
mode
)
{
this
.
mode
=
mode
;
this
.
format
();
}
}
}
</
script
>
<
style
scoped
>
</
style
>
frontend/src/business/components/common/components/MsDropdown.vue
0 → 100644
浏览文件 @
ac6466ff
<
template
>
<el-dropdown
@
command=
"handleCommand"
>
<slot>
<span
class=
"el-dropdown-link"
>
{{
currentCommand
}}
<i
class=
"el-icon-arrow-down el-icon--right"
></i>
</span>
</slot>
<el-dropdown-menu
slot=
"dropdown"
chang
>
<el-dropdown-item
v-for=
"(command, index) in commands"
:key=
"index"
:command=
"command"
>
{{
command
}}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</
template
>
<
script
>
export
default
{
name
:
"
MsDropdown
"
,
data
()
{
return
{
currentCommand
:
''
}
},
props
:
{
commands
:
{
type
:
Array
}
},
created
()
{
if
(
this
.
commands
&&
this
.
commands
.
length
>
0
)
{
this
.
currentCommand
=
this
.
commands
[
0
];
}
},
methods
:
{
handleCommand
(
command
)
{
this
.
currentCommand
=
command
;
this
.
$emit
(
'
command
'
,
command
);
}
}
}
</
script
>
<
style
scoped
>
.el-dropdown-link
{
cursor
:
pointer
;
color
:
#409EFF
;
}
.el-icon-arrow-down
{
font-size
:
12px
;
}
</
style
>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录