提交 7cd247bf 编写于 作者: M mxd

优化状态条显示

上级 31debf08
...@@ -117,6 +117,7 @@ ...@@ -117,6 +117,7 @@
--text-key-color: #660e7a; --text-key-color: #660e7a;
--suggest-hover-background: #D6EBFF; --suggest-hover-background: #D6EBFF;
--suggest-hover-color: #000; --suggest-hover-color: #000;
--statusbar-em-color: #007f31;
scrollbar-color: var(--scollbar-color) var(--scollbar-color); scrollbar-color: var(--scollbar-color) var(--scollbar-color);
scrollbar-width: thin; scrollbar-width: thin;
outline: 0; outline: 0;
...@@ -317,6 +318,11 @@ ...@@ -317,6 +318,11 @@
.ma-container .monaco-list-row.focused .monaco-highlighted-label .highlight{ .ma-container .monaco-list-row.focused .monaco-highlighted-label .highlight{
color: #0097fb !important color: #0097fb !important
} }
.ma-container .ma-status-container em,.ma-event .ma-content em{
color: var(--statusbar-em-color);
font-style: normal;
font-weight: bold;
}
/** 旋转特效 **/ /** 旋转特效 **/
@keyframes rotate { @keyframes rotate {
......
...@@ -480,7 +480,8 @@ export default { ...@@ -480,7 +480,8 @@ export default {
} else { } else {
bus.$emit('report','script_add') bus.$emit('report','script_add')
} }
bus.$emit('status',`接口「${thisInfo.groupName}/${thisInfo.name}(${thisInfo.groupPath}/${thisInfo.path})」已保存`.replace(/\/+/g, '/')) let fullName = utils.replaceURL(`${thisInfo.groupName}/${thisInfo.name}(${thisInfo.groupPath}/${thisInfo.path})`)
bus.$emit('status',`接口「${fullName}」已保存`)
thisInfo.id = id thisInfo.id = id
this.info.ext.tmpScript = saveObj.script this.info.ext.tmpScript = saveObj.script
}) })
...@@ -502,7 +503,8 @@ export default { ...@@ -502,7 +503,8 @@ export default {
} else { } else {
bus.$emit('report','function_add') bus.$emit('report','function_add')
} }
bus.$emit('status',`函数「${thisInfo.groupName}/${thisInfo.name}(${thisInfo.groupPath}/${thisInfo.path})」已保存`.replace(/\/+/g, '/')) let fullName = utils.replaceURL(`${thisInfo.groupName}/${thisInfo.name}(${thisInfo.groupPath}/${thisInfo.path})`)
bus.$emit('status',`函数「${fullName}」已保存`)
thisInfo.id = id thisInfo.id = id
this.info.ext.tmpScript = saveObj.script this.info.ext.tmpScript = saveObj.script
}) })
...@@ -698,7 +700,10 @@ export default { ...@@ -698,7 +700,10 @@ export default {
.join(',') .join(',')
requestConfig.responseType = 'blob' requestConfig.responseType = 'blob'
requestConfig.validateStatus = () => true requestConfig.validateStatus = () => true
let dataLen = 0
let fullName = utils.replaceURL(`${target.groupName}/${target.name}(${target.groupPath}/${target.path})`)
requestConfig.transformResponse = [function(data, headers){ requestConfig.transformResponse = [function(data, headers){
dataLen = data.size;
if(headers['content-disposition']){ if(headers['content-disposition']){
return new Promise(function(resolve){resolve(data)}); return new Promise(function(resolve){resolve(data)});
} }
...@@ -714,13 +719,20 @@ export default { ...@@ -714,13 +719,20 @@ export default {
} }
}) })
}] }]
bus.$emit('status', '开始测试...') bus.$emit('status', `开始测试「${fullName}」`)
let start = new Date().getTime() let start = new Date().getTime()
request request
.execute(requestConfig) .execute(requestConfig)
.then(res => { .then(res => {
res.data.then(data =>{ res.data.then(data =>{
bus.$emit('status', `测试完毕,本次请求耗时:${new Date().getTime() - start}ms`) let unit = ['B','KB','MB'];
let index = 0;
while(index < unit.length && dataLen >= 1024){
dataLen = dataLen / 1024
index++;
}
dataLen = dataLen.toFixed(2);
bus.$emit('status', `「${fullName}」测试完毕,状态:<em>${res.status}</em> 大小:<em>${dataLen}${unit[index]}</em> 耗时:<em>${new Date().getTime() - start}ms</em>`)
const contentType = res.headers['content-type'] const contentType = res.headers['content-type']
target.ext.debugDecorations && this.editor.deltaDecorations(target.ext.debugDecorations, []) target.ext.debugDecorations && this.editor.deltaDecorations(target.ext.debugDecorations, [])
target.ext.debugDecorations = target.ext.debugDecoration = null target.ext.debugDecorations = target.ext.debugDecoration = null
...@@ -731,7 +743,6 @@ export default { ...@@ -731,7 +743,6 @@ export default {
bus.$emit('update-response-body-definition', target.responseBodyDefinition); bus.$emit('update-response-body-definition', target.responseBodyDefinition);
bus.$emit('update-response-body', target.responseBody) bus.$emit('update-response-body', target.responseBody)
} else { } else {
bus.$emit('status', '脚本执行完毕')
// 执行完毕 // 执行完毕
target.running = false target.running = false
bus.$emit('switch-tab', 'result') bus.$emit('switch-tab', 'result')
...@@ -740,7 +751,7 @@ export default { ...@@ -740,7 +751,7 @@ export default {
}) })
}) })
.catch(error => { .catch(error => {
bus.$emit('status', '请求出错...') bus.$emit('status', `请求出错:「${fullName}」`)
target.ext.debuging = target.running = false target.ext.debuging = target.running = false
request.processError(error) request.processError(error)
}) })
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<div class="ma-content"> <div class="ma-content">
<div v-for="(item, key) in eventList" :key="'event_' + key" class="ma-table-row content-bg"> <div v-for="(item, key) in eventList" :key="'event_' + key" class="ma-table-row content-bg">
<div>{{ item.timestamp }}</div> <div>{{ item.timestamp }}</div>
<div>{{ item.content }}</div> <div v-html="item.content"></div>
</div> </div>
</div> </div>
</div> </div>
......
<template> <template>
<div class="ma-status-container"> <div class="ma-status-container">
<div>{{ message }}</div> <div v-html="message"></div>
<div class="ma-icons"> <div class="ma-icons">
<span v-if="config.header.repo !== false" title="Gitee" <span v-if="config.header.repo !== false" title="Gitee"
@click="open('https://gitee.com/ssssssss-team/magic-api')"> @click="open('https://gitee.com/ssssssss-team/magic-api')">
......
...@@ -99,6 +99,7 @@ export default { ...@@ -99,6 +99,7 @@ export default {
'text-property-color': '#9876aa', 'text-property-color': '#9876aa',
'text-key-color': '#9876aa', 'text-key-color': '#9876aa',
'suggest-hover-background': '#113A5C', 'suggest-hover-background': '#113A5C',
'suggest-hover-color': '#fff' 'suggest-hover-color': '#fff',
'statusbar-em-color': '#68dd9a'
} }
}; };
\ No newline at end of file
import * as monaco from 'monaco-editor'
let computeIndentLevel = function (line, tabSize) { let computeIndentLevel = function (line, tabSize) {
var indent = 0; var indent = 0;
var i = 0; var i = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册