Skip to content

Commit ce20df6

Browse files
committed
解决参数注入批量测试报错
1 parent e22a052 commit ce20df6

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@
139139
<input class="url" id="vUrlComment" :disabled="isEditResponse" type="text" style="width: 100%; position: absolute; z-index: -100; color: darkseagreen;background: #0000;" />
140140
<input class="url" id="vUrl" :disabled="isEditResponse" type="text" @copy="doOnCopy" @paste="doOnPaste" @keyup="doOnKeyUp(event)" placeholder="请输入请求的接口地址" style="z-index: 0; background: #0000;" />
141141
</div>
142-
<button class="send" id="vSend" @click="onClickSend()">{{ isEditResponse ? '模拟返回' : '发送请求' }}</button>
142+
<button class="send" id="vSend" @click="onClickSend()">{{ isEditResponse ? '模拟返回' : '远程执行' }}</button>
143143
</div>
144144
<div v-show="isTestCaseShow" class="left-bar">
145145
<!--<svg class="icon" style="margin-left: 10px">-->

js/main.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5196,7 +5196,8 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
51965196
App.send(false, cb);
51975197
}
51985198
else {
5199-
App.request(false, type, url, constJson, header, cb);
5199+
// header 目前不是 JSONObject 不适合传参 App.request(false, type, url, constJson, header, cb);
5200+
App.request(false, type, App.server + '/execute', constJson, {}, cb);
52005201
}
52015202
}
52025203

@@ -5388,21 +5389,21 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
53885389
randomNameKeys[which] = valStr;
53895390
}
53905391

5391-
if (generateJSON) {
5392+
// if (generateJSON) {
53925393
//先按照单行简单实现
53935394
//替换 JSON 里的键值对 key: value
53945395
code += 'var ' + key + ' = "?";\n';
53955396
arg.push(val);
5396-
}
5397+
// }
53975398
}
53985399
catch (e) {
53995400
throw new Error('第 ' + (which + 1) + ' 行随机配置 key: value 后的 value 不合法! \nerr: ' + e.message)
54005401
}
54015402

54025403
respCount ++;
54035404
if (respCount >= reqCount) {
5404-
code += 'var sql = `' + sql.replaceAll('`', '\\`') + '`;\nsql;'
5405-
sql = eval(code)
5405+
code += 'return `' + sql.replaceAll('`', '\\`') + '`;'
5406+
sql = eval('(function() {\n' + code + '\n})()')
54065407
var json = {
54075408
sql: sql,
54085409
arg: arg // Object.values(header)

0 commit comments

Comments
 (0)