[go: nahoru, domu]

Skip to content

Commit

Permalink
新增支持 项目 维度,关联 Base URL、账号、用例 等
Browse files Browse the repository at this point in the history
  • Loading branch information
TommyLemon committed May 3, 2024
1 parent 56b064f commit 6d0edc1
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 7 deletions.
35 changes: 34 additions & 1 deletion css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,6 @@ table.diff thead th.texttitle {
background-color: #FFF;
}


.historys li {
display: block;
padding: 10px;
Expand All @@ -582,6 +581,40 @@ table.diff thead th.texttitle {
}


.projects {
margin: 0;
padding: 0;
width: 200px;

background-color: #FFF;
}

.projects li {
display: block;
padding: 10px;
border-bottom: #DDD 1px solid;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
padding-right: 20px;
position: relative
}

.projects li a {
display: inline-block;
width: 100%;
}

.projects svg {
position: absolute;
display: inline-block;
cursor: pointer;
right: 5px;
width: 15px;
height: 15px;
}


.pop-save {
padding: 10px;
width: 250px;
Expand Down
17 changes: 14 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,19 @@

<img src="img/logo.png" class="logo-img"/>
<a class="logo" href="http://apijson.cn" target="_blank">
<span class="on">APIAuto</span><span >: APIJSON.cn</span>
</a>
<span class="on">APIAuto:</span>
</a><span class="pop-btn">
<a href="javascript:void(0)" style="padding: 14px; font-size: 24px">{{ project }}</a>
<ul class="projects pop" style="z-index: 200; min-width: 440px; right: -240px; width: 100%; padding-top: 50px; background: transparent">
<li v-for="(project, index) in projects" style="background: white">
<a style="padding: 0px" href="javascript:void(0)" @click="host = ''; vUrl.value = project.url + getBranchUrl()" > {{project.url + (StringUtil.isEmpty(project.name, true) ? '' : ' // ' + project.name)}}</a>

<svg class="icon" @click="remove(project, index, false, false, true)">
<use xlink:href="svg/icon.svg#trash"></use>
</svg>
</li>
</ul>
</span>
<a v-show="isDelayShow" >2s</a>


Expand Down Expand Up @@ -128,7 +139,7 @@
<a v-show="User.id == null || User.id <= 0" style="border-bottom: #DDD 1px solid;width: 100%" href="javascript:void(0)" @click="showConfig(true, 6)">托管服务器地址 URL: {{ server || '点击设置' }}</a>
<a v-show="User.id != null && User.id > 0" style="border-bottom: #DDD 1px solid;width: 100%" href="javascript:void(0)" @click="showConfig(true, 8)">导入第三方文档(平台名 URL): <br/>{{ thirdParty || '点击设置' }}</a>
</ul>
</span>
</span>


<!-- 部分头像加载不出,或者显示为开源中国LOGO -->
Expand Down
21 changes: 18 additions & 3 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,12 @@ https://github.com/Tencent/APIJSON/issues
thirdParty: 'SWAGGER /v2/api-docs', //apijson.cn
// thirdParty: 'RAP /repository/joined /repository/get',
// thirdParty: 'YAPI /api/interface/list_menu /api/interface/get',
project: 'APIJSON.cn',
projects: [
{name: 'localhost', url: 'http://localhost:8080'},
{name: 'APIJSON.cn', url: 'http://apijson.cn:8080'},
{name: 'APIJSON.cn:9090', url: 'http://apijson.cn:9090'}
],
language: CodeUtil.LANGUAGE_KOTLIN,
header: {},
page: 0,
Expand Down Expand Up @@ -2166,8 +2172,14 @@ https://github.com/Tencent/APIJSON/issues
},

// 删除已保存的
remove: function (item, index, isRemote, isRandom) {
remove: function (item, index, isRemote, isRandom, isProject) {
if (isRemote == null || isRemote == false) { //null != false
if (isProject) {
this.projects.splice(index, 1)
this.saveCache('', 'projects', this.projects)
return
}

localforage.removeItem(item.key, function () {
App.historys.splice(index, 1)
})
Expand Down Expand Up @@ -4182,15 +4194,18 @@ https://github.com/Tencent/APIJSON/issues
var allCount = testCases == null ? 0 : testCases.length
App.allCount = allCount
if (allCount > 0) {

var accountIndex = (this.accounts[this.currentAccountIndex] || {}).isLoggedIn ? this.currentAccountIndex : -1
this.currentAccountIndex = accountIndex //解决 onTestResponse 用 -1 存进去, handleTest 用 currentAccountIndex 取出来为空
// var account = this.accounts[accountIndex]
// baseUrl = this.getBaseUrl()

var reportId = this.reportId
if (reportId == null || Number.isNaN(reportId)) {
reportId = null
}

var tests = this.tests[String(accountIndex)]
var tests = this.tests[String(accountIndex)] // FIXME account.phone + '@' + (account.baseUrl || baseUrl)]
if ((reportId != null && reportId >= 0) || (tests != null && JSONObject.isEmpty(tests) != true)) {
for (var i = 0; i < allCount; i++) {
var item = testCases[i]
Expand Down Expand Up @@ -6192,7 +6207,7 @@ https://github.com/Tencent/APIJSON/issues

var baseUrls = this.getCache('', 'baseUrls', [])
var bu = this.getBaseUrl(url)
if (baseUrls.indexOf(bu) < 0) {
if (StringUtil.isNotEmpty(bu, true) && baseUrls.indexOf(bu) < 0) {
baseUrls.push(bu)
this.saveCache('', 'baseUrls', baseUrls)
}
Expand Down

0 comments on commit 6d0edc1

Please sign in to comment.