Skip to content

Commit 3890230

Browse files
committed
APIAuto: 新增支持 App.wait 延迟请求和 App.timeout 请求超时配置
1 parent 421f5e1 commit 3890230

File tree

2 files changed

+12
-5
lines changed
  • APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static

2 files changed

+12
-5
lines changed

APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@
289289
<input id="vTestCasePage" v-model="testCasePage" style="width: 30px;text-align: center" type="number" @keyup="doOnKeyUp(event, 'testCase', true)" placeholder="页码" />
290290
<button @click="pageUp('testCase')">></button>
291291
<input id="vTestCaseCount" v-model="testCaseCount" style="width: 30px;text-align: center" type="number" @keyup="doOnKeyUp(event, 'testCase', true)" placeholder="条数" />
292-
<input id="vTestCaseSearch" v-model="testCaseSearch" style="min-width: 60px; display: inline-flex; flex-grow: 1; text-align: center" @keyup="doOnKeyUp(event, 'testCase', true)" placeholder="搜索" />
292+
<input id="vTestCaseSearch" v-model="testCaseSearch" style="width: 168px; display: inline-flex; flex-grow: 1; text-align: center" @keyup="doOnKeyUp(event, 'testCase', true)" placeholder="搜索" />
293293
</div>
294294
</div>
295295
</div>

APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/js/main.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,8 @@ https://github.com/Tencent/APIJSON/issues
10811081
scriptType: 'case',
10821082
scriptBelongId: 0,
10831083
scripts: newDefaultScript(),
1084+
wait: 0, // 每个请求前的等待延迟
1085+
timeout: null, // 每个请求的超时时间
10841086
loadingCount: 0,
10851087
isPreScript: true,
10861088
isRandomTest: false,
@@ -6378,7 +6380,7 @@ https://github.com/Tencent/APIJSON/issues
63786380
var projectHosts = this.projectHosts || []
63796381
var projectHost = this.projectHost || {}
63806382
var find = false
6381-
for (var j = 0; j < projects.length; j ++) {
6383+
for (var j = 0; j < projectHosts.length; j ++) {
63826384
var pjt = projectHosts[j]
63836385
if (pjt == null || StringUtil.isEmpty(pjt.host, true)) {
63846386
continue
@@ -6393,7 +6395,7 @@ https://github.com/Tencent/APIJSON/issues
63936395
if (find != true) {
63946396
projectHosts.push({host: bu, project: projectHost.project})
63956397
this.projectHosts = projectHosts
6396-
this.saveCache('', 'projectHosts', projects)
6398+
this.saveCache('', 'projectHosts', projectHosts)
63976399
}
63986400

63996401
}
@@ -6425,7 +6427,7 @@ https://github.com/Tencent/APIJSON/issues
64256427
},
64266428

64276429
//请求
6428-
request: function (isAdminOperation, method, type, url, req, header, callback, caseScript_, accountScript_, globalScript_, ignorePreScript) {
6430+
request: function (isAdminOperation, method, type, url, req, header, callback, caseScript_, accountScript_, globalScript_, ignorePreScript, timeout_, wait_) {
64296431
this.loadingCount ++
64306432

64316433
const isEnvCompare = this.isEnvCompareEnabled
@@ -6434,6 +6436,8 @@ https://github.com/Tencent/APIJSON/issues
64346436
const globalScript = (isAdminOperation ? null : (globalScript_ != null ? globalScript_ : (scripts.global || {})[0])) || {}
64356437
const accountScript = (isAdminOperation ? null : (accountScript_ != null ? accountScript_ : (scripts.account || {})[this.getCurrentAccountId() || 0])) || {}
64366438
const caseScript = (isAdminOperation ? null : caseScript_) || {}
6439+
const timeout = timeout_ != null ? timeout_ : this.timeout
6440+
const wait = wait_ != null ? wait_ : (this.wait || 0)
64376441

64386442
var evalPostScript = function () {}
64396443

@@ -6486,6 +6490,7 @@ https://github.com/Tencent/APIJSON/issues
64866490
headers: header, //Accept-Encoding(HTTP Header 大小写不敏感,SpringBoot 接收后自动转小写)可能导致 Response 乱码
64876491
withCredentials: true, //Cookie 必须要 type == REQUEST_TYPE_JSON
64886492
// crossDomain: true
6493+
timeout: timeout
64896494
})
64906495
.then(function (res) {
64916496
App.currentHttpResponse = res
@@ -6775,7 +6780,9 @@ https://github.com/Tencent/APIJSON/issues
67756780
return
67766781
}
67776782

6778-
sendRequest(isAdminOperation, method, type, url, req, header, callback)
6783+
setTimeout(function () {
6784+
sendRequest(isAdminOperation, method, type, url, req, header, callback)
6785+
}, wait < 0 ? 0 : wait)
67796786
},
67806787

67816788

0 commit comments

Comments
 (0)