|
@@ -6,7 +6,7 @@ import $i from '../i18n.js'
|
|
|
import modal from '../../components/common/dialog/magic-modal.js'
|
|
|
import { definition2TreeList, getSizeUnit } from '../utils.js'
|
|
|
import { parseJson } from '../parsing/parser.js'
|
|
|
-import { nextTick } from '@vue/runtime-core'
|
|
|
+import { nextTick } from 'vue'
|
|
|
function sendApiTestRequest(opened, requestConfig) {
|
|
|
bus.$emit(Message.SWITCH_TOOLBAR, 'log')
|
|
|
requestConfig.headers[constants.HEADER_REQUEST_CLIENT_ID] = constants.CLIENT_ID
|
|
@@ -35,12 +35,12 @@ function sendApiTestRequest(opened, requestConfig) {
|
|
|
})
|
|
|
}]
|
|
|
const fullName = opened.path()
|
|
|
- bus.status(`开始测试「${fullName}」`)
|
|
|
+ bus.status('api.test.begin', true, fullName)
|
|
|
const start = new Date().getTime()
|
|
|
request.execute(requestConfig).then(res => res.data.then(data => {
|
|
|
- bus.status(`「${fullName}」测试完毕,状态:<em>${res.status}</em> 大小:<em>${getSizeUnit(dataLen)}</em> 耗时:<em>${new Date().getTime() - start} ms</em>`)
|
|
|
+ bus.status('api.test.success', true, fullName, res.status, getSizeUnit(dataLen), new Date().getTime() - start)
|
|
|
opened.running = false
|
|
|
- if(opened.responseBlob = data instanceof Blob){
|
|
|
+ if((opened.responseBlob = data instanceof Blob)){
|
|
|
opened.responseBlobValue = data
|
|
|
opened.item.responseBody = null
|
|
|
opened.item.responseBodyDefinition = null
|
|
@@ -54,7 +54,7 @@ function sendApiTestRequest(opened, requestConfig) {
|
|
|
opened.responseHeaders = res.headers
|
|
|
nextTick(() => bus.$emit(Message.SWITCH_TOOLBAR, 'response'))
|
|
|
})).catch(error => {
|
|
|
- bus.status(`请求出错:「${fullName}」`, false)
|
|
|
+ bus.status('api.test.requestError', false, fullName)
|
|
|
opened.running = false
|
|
|
request.processError(error)
|
|
|
})
|
|
@@ -72,11 +72,11 @@ function doApiTest(opened) {
|
|
|
responseType: 'json',
|
|
|
withCredentials: true
|
|
|
}
|
|
|
- const setPaths = paths => paths.filter(it => it.value && it.value.trim()).forEach(it => requestConfig.url = requestConfig.url.replace(new RegExp(`\{${it.name}\}`, "g"), it.value.trim()))
|
|
|
+ const setPaths = paths => paths.filter(it => it.value && it.value.trim()).forEach(it => requestConfig.url = requestConfig.url.replace(new RegExp(`\\{${it.name}\}`, "g"), it.value.trim()))
|
|
|
opened.getGroups().filter(it => it.paths && it.paths.length > 0).map(it => it.paths).forEach(paths => setPaths(paths))
|
|
|
setPaths(info.paths || [])
|
|
|
if (requestConfig.url.indexOf('{') > -1) {
|
|
|
- modal.alert('请填写路径变量后在测试!')
|
|
|
+ modal.alert($i('api.test.missPath'))
|
|
|
opened.running = false
|
|
|
return;
|
|
|
}
|
|
@@ -118,7 +118,7 @@ function doApiTest(opened) {
|
|
|
}
|
|
|
} catch (e) {
|
|
|
opened.running = false
|
|
|
- modal.alert('RequestBody 参数有误,请检查!')
|
|
|
+ modal.alert($i('api.test.requestBodyError'))
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -162,4 +162,4 @@ export default {
|
|
|
options: item.options.filter(it => it.name)
|
|
|
}
|
|
|
}
|
|
|
-}
|
|
|
+}
|