Skip to content

Commit 34e1780

Browse files
committed
Java:MultiDataSource 同步 APIAuto:新增 HTTP Method, Content-Type 的下拉选项
1 parent da32a6e commit 34e1780

3 files changed

Lines changed: 116 additions & 27 deletions

File tree

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

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,15 @@ a:active svg, a:hover svg{
176176
top: 0px;
177177
display: flex;
178178
align-items: center;
179-
z-index: 100;
179+
z-index: 101;
180180
background-color: #FFF;
181181
box-shadow: 1px 1px 1px rgba(244, 243, 243, 0.64)
182182
}
183183

184+
.side-left > .left-bar {
185+
z-index: 101;
186+
}
187+
184188
.left-panel {
185189
height: 100%;
186190
width: 100%;
@@ -272,7 +276,7 @@ textarea {
272276
padding-right: 10px;
273277
display: flex;
274278
align-items: center;
275-
z-index: 100;
279+
z-index: 101;
276280
background-color: #FFF;
277281
box-shadow: 1px 1px 1px rgba(244, 243, 243, 0.64)
278282
}
@@ -336,7 +340,7 @@ textarea {
336340
display: inline-block;
337341
position: relative
338342
}
339-
.pop-btn:hover .pop, .pop:hover {
343+
.pop-btn:hover .pop, .pop:hover, .pop:focus-within {
340344
display: block;
341345
}
342346

@@ -489,7 +493,7 @@ textarea {
489493
top: 50px;
490494
bottom: 0;
491495
left: 40%;
492-
z-index: 100;
496+
z-index: 1000;
493497
cursor: w-resize;
494498
border-right: rgba(221, 221, 221, 0.34) 1px solid;
495499
border-left: rgba(221, 221, 221, 0.34) 1px solid;
@@ -580,6 +584,58 @@ table.diff thead th.texttitle {
580584
height: 15px;
581585
}
582586

587+
.method-pop {
588+
left: 0;
589+
right: auto;
590+
top: 100%
591+
}
592+
593+
.method-pop li {
594+
display: block;
595+
padding: 0;
596+
padding-right: 0;
597+
border-bottom: 0;
598+
overflow: visible;
599+
}
600+
601+
.method-pop li a {
602+
display: block;
603+
width: 100%;
604+
height: 28px;
605+
line-height: 28px;
606+
padding: 0;
607+
border-bottom: #DDD 1px solid;
608+
box-sizing: border-box;
609+
color: black;
610+
text-align: center;
611+
}
612+
613+
.type-pop {
614+
left: 0;
615+
right: auto;
616+
top: 100%
617+
}
618+
619+
.type-pop li {
620+
display: block;
621+
padding: 0;
622+
padding-right: 0;
623+
border-bottom: 0;
624+
overflow: visible;
625+
}
626+
627+
.type-pop li a {
628+
display: block;
629+
width: 100%;
630+
height: 28px;
631+
line-height: 28px;
632+
padding: 0;
633+
padding-left: 4px;
634+
border-bottom: #DDD 1px solid;
635+
box-sizing: border-box;
636+
color: black;
637+
text-align: left;
638+
}
583639

584640
.projects {
585641
margin: 0;

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

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,32 @@
158158
<div class="side-left" style="padding-bottom: -4px">
159159
<div v-show="! isTestCaseShow" class="left-bar" >
160160
<button class="transfer" id="vTransfer" @click="transfer()">' / "</button>
161-
<button v-show="isShowMethod()" class="transfer" style="width: 60px" id="vMethod" :disabled="isEditResponse" @click="changeMethod()">{{ getMethodName(method, type) }}</button>
162-
<button v-show="isShowType()" class="transfer" id="vType" :disabled="isEditResponse" @click="changeType()">{{ getTypeName(type, method) }}</button>
161+
162+
<span v-show="isShowMethod()" class="pop-btn transfer" style="width: 60px">
163+
<button class="transfer" style="width: 60px" id="vMethod" :disabled="isEditResponse" @click="changeMethod()">{{ getMethodName(method, type) }}</button>
164+
<ul class="historys pop method-pop" style="width: 60px;">
165+
<li ><a href="javascript:void(0)" :style="{color: method == 'GET' ? 'red' : 'black'}" @click="changeMethod('GET')" >GET</a></li>
166+
<li ><a href="javascript:void(0)" :style="{color: method == 'POST' ? 'red' : 'black'}" @click="changeMethod('POST')" >POST</a></li>
167+
<li ><a href="javascript:void(0)" :style="{color: method == 'PUT' ? 'red' : 'black'}" @click="changeMethod('PUT')" >PUT</a></li>
168+
<li ><a href="javascript:void(0)" :style="{color: method == 'PATCH' ? 'red' : 'black'}" @click="changeMethod('PATCH')" >PATCH</a></li>
169+
<li ><a href="javascript:void(0)" :style="{color: method == 'DELETE' ? 'red' : 'black'}" @click="changeMethod('DELETE')" >DELETE</a></li>
170+
<li ><a href="javascript:void(0)" :style="{color: method == 'HEAD' ? 'red' : 'black'}" @click="changeMethod('HEAD')" >HEAD</a></li>
171+
<li ><a href="javascript:void(0)" :style="{color: method == 'OPTIONS' ? 'red' : 'black'}" @click="changeMethod('OPTIONS')" >OPTIONS</a></li>
172+
<li ><a href="javascript:void(0)" :style="{color: method == 'TRACE' ? 'red' : 'black'}" @click="changeMethod('TRACE')" >TRACE</a></li>
173+
</ul>
174+
</span>
175+
176+
<span v-show="isShowType()" class="pop-btn transfer">
177+
<button class="transfer" id="vType" :disabled="isEditResponse" @click="changeType()">{{ getTypeName(type, method) }}</button>
178+
<ul class="historys pop type-pop" style="width: 250px;">
179+
<li ><a href="javascript:void(0)" :style="{color: type == 'PARAM' ? 'red' : 'black'}" @click="changeType('PARAM')" >PARAM // ?a=1&b=c&key=value</a></li>
180+
<li ><a href="javascript:void(0)" :style="{color: type == 'FORM' ? 'red' : 'black'}" @click="changeType('FORM')" >FORM // x-www-form-urlencoded</a></li>
181+
<li ><a href="javascript:void(0)" :style="{color: type == 'DATA' ? 'red' : 'black'}" @click="changeType('DATA')" >DATA // form-data</a></li>
182+
<li ><a href="javascript:void(0)" :style="{color: type == 'JSON' ? 'red' : 'black'}" @click="changeType('JSON')" >JSON // application/json</a></li>
183+
<li ><a href="javascript:void(0)" :style="{color: type == 'GRPC' ? 'red' : 'black'}" @click="changeType('GRPC')" >GRPC // application/json</a></li>
184+
</ul>
185+
</span>
186+
163187
<div style="height: 100%;display: flex;flex-grow: 1">
164188
<input class="url" id="vUrlComment" :disabled="isEditResponse" type="text" style="width: 100%; position: absolute; z-index: -100; color: darkseagreen;background: #0000;" ></input>
165189
<textarea class="url" id="vUrl" :disabled="isEditResponse" type="text" @copy="doOnCopy" @paste="doOnPaste" @keyup="doOnKeyUp(event)"

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

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7309,18 +7309,23 @@ https://github.com/Tencent/APIJSON/issues
73097309

73107310
/**请求类型切换
73117311
*/
7312-
changeMethod: function () {
7313-
var methods = this.methods
7314-
var count = methods == null ? 0 : methods.length
7315-
if (count <= 0) {
7316-
methods = HTTP_METHODS
7317-
count = HTTP_METHODS.length
7318-
}
7312+
changeMethod: function (method) {
7313+
if (StringUtil.isNotEmpty(method)) {
7314+
CodeUtil.method = this.method = method
7315+
} else {
7316+
var methods = this.methods
7317+
var count = methods == null ? 0 : methods.length
7318+
if (count <= 0) {
7319+
methods = HTTP_METHODS
7320+
count = HTTP_METHODS.length
7321+
}
73197322

7320-
if (count > 1) {
7321-
var index = methods.indexOf(this.method) + 1
7322-
CodeUtil.method = this.method = methods[index % count]
7323+
if (count > 1) {
7324+
var index = methods.indexOf(this.method) + 1
7325+
CodeUtil.method = this.method = methods[index % count]
7326+
}
73237327
}
7328+
73247329
this.onChange(false);
73257330
},
73267331

@@ -7366,18 +7371,22 @@ https://github.com/Tencent/APIJSON/issues
73667371
},
73677372
/**请求类型切换
73687373
*/
7369-
changeType: function () {
7370-
var types = this.types
7371-
var count = types == null ? 0 : types.length
7372-
if (count <= 0) {
7373-
types = HTTP_CONTENT_TYPES
7374-
count = HTTP_CONTENT_TYPES.length
7375-
}
7374+
changeType: function (type) {
7375+
if (StringUtil.isNotEmpty(type)) {
7376+
CodeUtil.type = this.type = type
7377+
} else {
7378+
var types = this.types
7379+
var count = types == null ? 0 : types.length
7380+
if (count <= 0) {
7381+
types = HTTP_CONTENT_TYPES
7382+
count = HTTP_CONTENT_TYPES.length
7383+
}
73767384

7377-
if (count > 1) {
7378-
var index = types.indexOf(this.type) + 1
7379-
this.type = types[index % count]
7380-
CodeUtil.type = this.type;
7385+
if (count > 1) {
7386+
var index = types.indexOf(this.type) + 1
7387+
this.type = types[index % count]
7388+
CodeUtil.type = this.type;
7389+
}
73817390
}
73827391

73837392
var url = StringUtil.trim(vUrl.value).replaceAll('\n', '')

0 commit comments

Comments
 (0)