Skip to content

Commit 005a008

Browse files
committed
从 APIAuto 同步 Headless 模式 Node 环境无 UI 测试、回归测试完继续深度测试等功能
1 parent bf1831c commit 005a008

File tree

8 files changed

+1111
-414
lines changed

8 files changed

+1111
-414
lines changed

apijson/CodeUtil.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@
1212
See the License for the specific language governing permissions and
1313
limitations under the License.*/
1414

15+
if (typeof window == 'undefined') {
16+
try {
17+
eval(`
18+
var StringUtil = require("./StringUtil");
19+
var JSONObject = require("./JSONObject");
20+
`)
21+
} catch (e) {
22+
console.log(e)
23+
}
24+
}
1525

1626
/**util for generate code
1727
* @author Lemon
@@ -6716,4 +6726,8 @@ var CodeUtil = {
67166726
return (targetType == 'number' && realType == 'integer') || (targetType == 'string' && ['date', 'time', 'datetime'].indexOf(realType) >= 0);
67176727
}
67186728

6729+
};
6730+
6731+
if (typeof module == 'object') {
6732+
module.exports = CodeUtil;
67196733
}

apijson/JSONObject.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,20 @@
1919
var JSONObject = {
2020
TAG: 'JSONObject',
2121

22+
log: function (tag, msg) {
23+
24+
},
25+
26+
isEmpty: function (obj) {
27+
return obj == null || Object.keys(obj).length <= 0;
28+
},
29+
2230
/**判断key是否为表名
2331
* @param key
2432
* @return
2533
*/
2634
isTableKey: function(key, value, isRestful) {
27-
log(this.TAG, 'isTableKey typeof key = ' + (typeof key));
35+
JSONObject.log(this.TAG, 'isTableKey typeof key = ' + (typeof key));
2836
if (key == null) {
2937
return false;
3038
}
@@ -44,7 +52,7 @@ var JSONObject = {
4452
* @return
4553
*/
4654
isArrayKey: function(key, value, isRestful) {
47-
log(this.TAG, 'isArrayKey typeof key = ' + (typeof key));
55+
JSONObject.log(this.TAG, 'isArrayKey typeof key = ' + (typeof key));
4856

4957
if (key == null) {
5058
return false;
@@ -110,13 +118,17 @@ var JSONObject = {
110118
}
111119

112120
return {
113-
method,
114-
isRestful,
115-
tag,
121+
method: method,
122+
isRestful: isRestful,
123+
tag: tag,
116124
table: startName
117125
}
118126
}
119127

128+
};
129+
130+
if (typeof module == 'object') {
131+
module.exports = JSONObject;
120132
}
121133

122134
//TODO 取消注释 Object.freeze(JSONObject) //不可修改

apijson/JSONRequest.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,5 +467,8 @@ function newArrayString(table, json, count, page) {
467467
+ table + "\":" + JSON.stringify(json) + "}}";
468468
}
469469

470+
if (typeof module == 'object') {
471+
module.exports = this;
472+
}
470473

471474
//常用请求>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

apijson/JSONResponse.js

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@
1717
* @author Lemon
1818
*/
1919

20+
if (typeof window == 'undefined') {
21+
try {
22+
eval(`
23+
var StringUtil = require("./StringUtil");
24+
var JSONObject = require("./JSONObject");
25+
var CodeUtil = require("./CodeUtil");
26+
`)
27+
} catch (e) {
28+
console.log(e)
29+
}
30+
}
2031

2132
//状态信息,非GET请求获得的信息<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
2233

@@ -59,8 +70,19 @@ var JSONResponse = {
5970
* @param code
6071
* @return
6172
*/
62-
isSuccess: function(code) {
63-
return code == CODE_SUCCESS;
73+
isSuccess: function(obj) {
74+
if (obj == null) {
75+
return false
76+
}
77+
78+
if (typeof obj == 'number') {
79+
return obj == CODE_SUCCESS;
80+
}
81+
if (obj instanceof Object && obj instanceof Array == false) {
82+
return obj.code == CODE_SUCCESS;
83+
}
84+
85+
return false
6486
},
6587

6688
/**校验服务端是否存在table
@@ -370,10 +392,10 @@ var JSONResponse = {
370392
};
371393
}
372394

373-
if (real == null || real.data == null) {
395+
if (real == null || real.list == null) {
374396
return {
375397
code: JSONResponse.COMPARE_KEY_LESS, //未上传对比标准
376-
msg: '没有校验标准,且缺少非 null 值的 data 字段',
398+
msg: '没有校验标准,且缺少非 null 值的 list 字段',
377399
path: folder == null ? '' : folder
378400
};
379401
}
@@ -1544,4 +1566,8 @@ var JSONResponse = {
15441566
return value;
15451567
}
15461568

1569+
};
1570+
1571+
if (typeof module == 'object') {
1572+
module.exports = JSONResponse;
15471573
}

apijson/StringUtil.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ var StringUtil = {
173173
return arr == null ? '' : arr.join(separator)
174174
}
175175

176+
};
177+
178+
if (typeof module == 'object') {
179+
module.exports = StringUtil;
176180
}
177181

178182
//校正(自动补全等)字符串>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

index.html

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@
111111
<a style="border-bottom: #DDD 1px solid;width: 100%" href="javascript:void(0)" @click="showConfig(! isPreviewEnabled, 10)">预览左侧输入框: {{ isPreviewEnabled ? '已开启,点击关闭' : '已关闭,点击开启' }}</a>
112112
<a v-show="User.id != null && User.id > 0" style="border-bottom: #DDD 1px solid;width: 100%" href="javascript:void(0)" @click="showConfig(! isEditResponse, 11)">当前编辑模式: {{ isEditResponse ? 'Response 后端响应结果' : 'Request 前端请求参数' }}</a>
113113
<a style="border-bottom: #DDD 1px solid;width: 100%" href="javascript:void(0)" @click="showConfig(StringUtil.isEmpty(host, true), 3)">{{ StringUtil.isEmpty(host, true) ? '隐藏(固定)URL Host: 可用空格隔开' : '显示(编辑)URL Host: \n' + host }}</a>
114+
<a style="border-bottom: #DDD 1px solid;width: 100%;display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; overflow: hidden;" href="javascript:void(0)" @click="showConfig(! isHeaderShow, 4)">{{ (isHeaderShow ? '隐藏(固定)' : '显示(编辑)') + (isEditResponse ? '参数值 Argument Value' : '参数值 Argument Value' ) }}</a>
114115
<a style="border-bottom: #DDD 1px solid;width: 100%;display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; overflow: hidden;" href="javascript:void(0)" @click="showConfig(! isRandomShow, 5)">{{ isRandomShow ? '隐藏(固定)参数注入 Random Test' : '显示(编辑)参数注入 Random Test' }}</a>
115-
<a style="border-bottom: #DDD 1px solid;width: 100%;display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; overflow: hidden;" href="javascript:void(0)" @click="showConfig(! isHeaderShow, 4)">{{ (isHeaderShow ? '隐藏(固定)' : '显示(编辑)') + (isEditResponse ? '响应头 Response Header' : '请求头 Request Header' ) }}</a>
116-
<a style="border-bottom: #DDD 1px solid;width: 100%" href="javascript:void(0)" @click="showConfig(true, 2)">生成代码(封装,解析) : {{ language || '例如 Java' }}</a>
116+
<a style="border-bottom: #DDD 1px solid;width: 100%" href="javascript:void(0)" @click="showConfig(true, 2)">生成代码(封装,解析) : {{ language || '例如 Java' }}</a>
117117
<a style="border-bottom: #DDD 1px solid;width: 100%" href="javascript:void(0)" @click="showConfig(true, 0)">数据库类型 Database: {{ database || '例如 MYSQL' }}</a>
118118
<a style="border-bottom: #DDD 1px solid;width: 100%" href="javascript:void(0)" @click="showConfig(true, 1)">数据库名/模式 Schema: {{ schema || '例如 sys' }}</a>
119119
<a v-show="User.id == null || User.id <= 0" style="border-bottom: #DDD 1px solid;width: 100%" href="javascript:void(0)" @click="showConfig(true, 7)">使用的请求类型: {{ types == null || types.length <= 0 ? '点击设置' : (types instanceof Array ? types.join() : types) }}</a>
@@ -171,7 +171,7 @@
171171
</div>
172172
<div class="left-panel">
173173
<ul v-show="isTestCaseShow" class="historys" style="width: 100%;height: 100%;overflow: hidden;overflow-y: scroll;padding-bottom: 50px">
174-
<li v-for="(item, index) in testCases" >
174+
<li v-for="(item, index) in testCases" :id="'docItem' + index" >
175175
<div style="display: inline-table">
176176
<button v-show="false && types != null && types.length > 1" style="width: 48px;margin-right: 6px;padding: 0px;position: relative" id="vDocType" @click="restoreRemoteAndTest(index, item)">{{ getTypeName(item.Document.type) }}</button>
177177
<a class="hint--rounded hint--no-animate" ref="testCaseTexts" @mouseover="setRequestHint(index, item)" href="javascript:void(0)" @click="restoreRemote(index, item)" :style="{ color: index == currentDocIndex ? 'black' : 'gray' }"> {{(item.Document.version > 0 ? 'V' + item.Document.version : 'V*') + ' ' + item.Document.name + ' ' + item.Document.url}}</a>
@@ -256,7 +256,7 @@
256256

257257
<!-- 临时生成的配置子项 -->
258258
<ul v-show="isRandomSubListShow" class="historys" style="width: 100%;height: 100%;overflow: hidden;overflow-y: scroll; padding-bottom: 100px">
259-
<li style="width: 100%" v-for="(item, index) in randomSubs" >
259+
<li style="width: 100%" v-for="(item, index) in randomSubs" :id="'randomSubItem' + index" >
260260
<a v-show="! isRandomEditable" class="hint--rounded hint--no-animate" ref="randomSubTexts" @mouseover="setRequestHint(index, item, true)" href="javascript:void(0)" @click="restoreRandom(index, item)" :style="{ color: index == currentRandomSubIndex ? 'black' : 'gray' }">{{ (item.Random || {}).name }}</a>
261261
<input v-show="isRandomEditable" style="width: 96%" v-model="(item.Random || {}).name" @keyup="doOnKeyUp(event, 'randomSub', false, item)" />
262262

@@ -286,7 +286,7 @@
286286

287287
<!-- 持久化存储的配置项 -->
288288
<ul v-show="isRandomListShow" class="historys" style="width: 100%;height: 100%;overflow: hidden;overflow-y: scroll;padding-bottom: 100px">
289-
<li style="width: 100%; display: inline-table" v-for="(item, index) in randoms" >
289+
<li style="width: 100%; display: inline-table" v-for="(item, index) in randoms" :id="'randomItem' + index" >
290290
<input v-model="(item.Random || {}).count" style="min-width: 12px; max-width: 30px; width: auto; text-align: center" type="number" @keyup="doOnKeyUp(event, 'random', false, item)" />
291291
<a style="margin-left: 4px; "></a>
292292
<a v-show="! isRandomEditable" style="top: 13px; left: 68px; position: absolute" class="hint--rounded hint--no-animate" ref="randomTexts" @mouseover="setRequestHint(index, item, true)" href="javascript:void(0)" @click="restoreRandom(index, item)" :style="{ color: index == currentRandomIndex ? 'black' : 'gray' }">{{ (item.Random || {}).name }}</a>
@@ -345,7 +345,7 @@
345345
userId: RANDOM_IN(82001, 82002, 82003) // 随机选项取值
346346
limit: ORDER_IN(1, 3, 5, 10) // 顺序选项取值
347347
offset: RANDOM_INT(0, 5) // 随机范围取值
348-
// 从数据库随机取值 userId: RANDOM_DB('Comment', 'userId')
348+
// 从数据库随机取值 userId: RANDOM_DB(0, 100000, 'Comment', 'userId')
349349

350350
// 注释可省略,但如果未省略则前面两个空格必须;清空文本内容可查看规则。
351351

@@ -496,7 +496,7 @@
496496
</div>
497497

498498
<!--<div class="statement">-->
499-
<!--Copyright ©2016-2021 APIJSON.cn All right reserved.-->
499+
<!--Copyright ©2022 APIJSON.cn All right reserved.-->
500500
<!--<a href="https://beian.miit.gov.cn/" target="_blank">-->
501501
<!--<span >粤ICP备18005508号-1.</span>-->
502502
<!--</a>-->
@@ -513,19 +513,18 @@
513513
<button @click="save()" >保存</button>
514514
</div>
515515

516-
<!--弹出下载文本框-->
517-
<div class="save-box" v-show="isExportShow">
518-
<div id="divSaveBoxCheck" v-show="isExportCheckShow && ! isEditResponse" style="position: absolute; width: 120px; height: 30px; padding: 0px; margin: 0px; left: -45px; top: 6px; display: inline-block">
519-
<input type="checkbox" style="position: relative; width: 18px; top: 1px; " id="cbSaveBoxCheck" value="first_checkbox"><label id="lblSaveBox" for="cbSaveBoxCheck" style="top: 0px; right: -36px">{{ exTxt.label || '发布简单接口'}}</label>
520-
</div>
521-
522-
<svg class="icon close-icon" @click="showExport(false, isExportRemote)">
523-
<use xlink:href="svg/icon.svg#close"></use>
524-
</svg>
525-
526-
<input type="text" placeholder="请输入名称" v-model="exTxt.name" />
527-
<div style="display: inline-block; margin-top: 6px; padding-bottom: 0px"><button @click="exportTxt(0)">{{isExportRemote ? '上传' : '下载'}}</button><button v-show="isExportRemote && (isExportRandom != true || isEditResponse != true)" style="margin-left: 6px" @click="exportTxt(1)">{{isExportRandom ? '发布简单接口' : '分享'}}</button></div>
528-
</div>
516+
<!--弹出下载文本框-->
517+
<div class="save-box" v-show="isExportShow">
518+
<!-- <div id="divSaveBoxCheck" v-show="isExportCheckShow && ! isEditResponse" style="position: absolute; width: 120px; height: 30px; padding: 0px; margin: 0px; left: -45px; top: 6px; display: inline-block">-->
519+
<!-- <input type="checkbox" style="position: relative; width: 18px; top: 1px; " id="cbSaveBoxCheck" value="first_checkbox"><label id="lblSaveBox" for="cbSaveBoxCheck" style="top: 0px; right: -36px">{{ exTxt.label || '发布简单接口'}}</label>-->
520+
<!-- </div>-->
521+
<svg class="icon close-icon" @click="showExport(false, isExportRemote)">
522+
<use xlink:href="svg/icon.svg#close"></use>
523+
</svg>
524+
525+
<input type="text" placeholder="请输入名称" v-model="exTxt.name" />
526+
<div style="display: inline-block; margin-top: 6px; padding-bottom: 0px"><button @click="exportTxt(0)">{{isExportRemote ? '上传' : '下载'}}</button><button v-show="isExportRemote && (isExportRandom != true && isEditResponse != true)" style="margin-left: 6px" @click="exportTxt(1)">{{isExportRandom ? '发布简单接口' : '分享'}}</button></div>
527+
</div>
529528

530529
<!--弹出设置文本框-->
531530
<div class="save-box" v-show="isConfigShow">

0 commit comments

Comments
 (0)