各种细节打磨优化,增加提示
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
<velocity.engine.core.version>2.0</velocity.engine.core.version>
|
||||
<dozer.core.version>6.1.0</dozer.core.version>
|
||||
<alibaba.druid.version>1.1.9</alibaba.druid.version>
|
||||
<swagger.bootstrap.ui.version>1.8.7</swagger.bootstrap.ui.version>
|
||||
<swagger.bootstrap.ui.version>1.8.9</swagger.bootstrap.ui.version>
|
||||
<springfox.swagger.ui.version>2.9.2</springfox.swagger.ui.version>
|
||||
<springfox.swagger.version>2.9.2</springfox.swagger.version>
|
||||
<zyplayer.doc.db.version>1.0.1</zyplayer.doc.db.version>
|
||||
|
||||
@@ -22,6 +22,8 @@ import org.springframework.security.web.authentication.rememberme.RememberMeAuth
|
||||
import org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices;
|
||||
import org.springframework.util.DigestUtils;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Order(1)
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
@@ -98,7 +100,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
@Override
|
||||
public boolean matches(CharSequence charSequence, String s) {
|
||||
String digestAsHex = DigestUtils.md5DigestAsHex(charSequence.toString().getBytes());
|
||||
return s.equals(digestAsHex);
|
||||
return Objects.equals(s, digestAsHex);
|
||||
}
|
||||
}).and().authenticationProvider(rememberMeAuthenticationProvider());
|
||||
}
|
||||
|
||||
@@ -16,23 +16,22 @@
|
||||
<div class="heading divider primary-pale">
|
||||
<div class="title">登录 <span class="reason"> 您没有权限访问该内容或需要登录</span></div>
|
||||
</div>
|
||||
|
||||
<div class="content box">
|
||||
<div class="control has-label-left"><!-- has-error -->
|
||||
<input type="text" name="username" class="input" v-model="userId" placeholder="用户名">
|
||||
<label for="account"><i class="icon-user"></i></label>
|
||||
<div class="help-text" v-if="errorInfo.length > 0">{{errorInfo}}</div>
|
||||
<input type="text" name="username" class="input enter-input" v-model="userId" placeholder="用户名">
|
||||
<label><i class="icon-user"></i></label>
|
||||
<div class="help-text red-txt" v-if="userNameError.length > 0">{{userNameError}}</div>
|
||||
</div>
|
||||
<div class="control has-label-left">
|
||||
<input type="password" name="password" v-model="password" class="input" placeholder="密码">
|
||||
<input type="password" name="password" v-model="password" class="input enter-input" placeholder="密码">
|
||||
<input type="hidden" name="validateCode" value="1234">
|
||||
<label for="account"><i class="icon-key"></i></label>
|
||||
<label><i class="icon-key"></i></label>
|
||||
<div class="help-text red-txt" v-if="passwordError.length > 0">{{passwordError}}</div>
|
||||
</div>
|
||||
<div class="control">
|
||||
<button type="submit" v-on:click="loginSubmit" class="btn block primary">登录</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -42,6 +41,7 @@
|
||||
<script src="../lib/mzui/js/mzui.min.js"></script>
|
||||
<script src="../lib/vue/vue.js"></script>
|
||||
<script src="../lib/mg/js/common.js"></script>
|
||||
<script src="../lib/mg/js/toast.js"></script>
|
||||
|
||||
<script>
|
||||
var app = new Vue({
|
||||
@@ -49,7 +49,11 @@
|
||||
data: {
|
||||
userId: "",
|
||||
password: "",
|
||||
errorInfo: ""
|
||||
userNameError: "",
|
||||
passwordError: ""
|
||||
},
|
||||
mounted: function(){
|
||||
this.init();
|
||||
},
|
||||
methods: {
|
||||
loginSubmit: function() {
|
||||
@@ -58,12 +62,29 @@
|
||||
password: app.password,
|
||||
validateCode: "1234"
|
||||
};
|
||||
post(ctx + "login", param, function(result) {
|
||||
app.userNameError = "";
|
||||
app.passwordError = "";
|
||||
if(app.userId == "") {
|
||||
app.userNameError = "用户名不能为空";
|
||||
return;
|
||||
}
|
||||
if(app.password == "") {
|
||||
app.passwordError = "密码不能为空";
|
||||
return;
|
||||
}
|
||||
post(ctx + "login", param, function (result) {
|
||||
console.log(result);
|
||||
if(result.errCode == 200) {
|
||||
if (result.errCode == 200) {
|
||||
location.href = result.data;
|
||||
} else {
|
||||
alert("登录失败," + result.errMsg);
|
||||
app.passwordError = "登录失败," + result.errMsg;
|
||||
}
|
||||
});
|
||||
},
|
||||
init: function () {
|
||||
$(".enter-input").keyup(function (e) {
|
||||
if (e.keyCode == 13) {
|
||||
app.loginSubmit();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -73,6 +94,7 @@
|
||||
|
||||
<style>
|
||||
.reason{color: #f00;font-size: 12px;}
|
||||
.red-txt{color: #f00;}
|
||||
</style>
|
||||
</html>
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -126,9 +125,11 @@ public class MgDocumentController {
|
||||
}
|
||||
locationList.addAll(locationListStorage);
|
||||
this.storageSwaggerLocationList(locationListStorage);
|
||||
|
||||
AtomicInteger idIndex = new AtomicInteger(1);
|
||||
resourcesSet.forEach(val -> val.setId(idIndex.getAndIncrement()));
|
||||
resourcesSet.forEach(val -> {
|
||||
if (val.getId() == null) {
|
||||
val.setId(storageService.getNextId());
|
||||
}
|
||||
});
|
||||
storageService.put(StorageKeys.SWAGGER_RESOURCES_LIST, JSON.toJSONString(resourcesSet));
|
||||
}
|
||||
List<String> swaggerResourceStrList = new LinkedList<>();
|
||||
@@ -316,15 +317,18 @@ public class MgDocumentController {
|
||||
SwaggerResourcesInfoVo resourcesInfoVo = new SwaggerResourcesInfoVo(resourcesUrl, resourceList);
|
||||
resourcesInfoVo.setRewriteDomainUrl(rewriteDomainUrl);
|
||||
resourcesList.add(resourcesInfoVo);
|
||||
AtomicInteger idIndex = new AtomicInteger(1);
|
||||
resourcesList.forEach(val -> val.setId(idIndex.getAndIncrement()));
|
||||
resourcesList.forEach(val -> {
|
||||
if (val.getId() == null) {
|
||||
val.setId(storageService.getNextId());
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("获取文档失败:{},{}", resourcesUrl, e.getMessage());
|
||||
return DocResponseJson.warn("该地址查找文档失败");
|
||||
}
|
||||
// 去重
|
||||
resourcesList = resourcesList.stream().distinct().collect(Collectors.toList());
|
||||
resourcesList = resourcesList.stream().distinct().sorted(Comparator.comparing(SwaggerResourcesInfoVo::getId)).collect(Collectors.toList());
|
||||
storageService.put(StorageKeys.SWAGGER_RESOURCES_LIST, JSON.toJSONString(resourcesList));
|
||||
return DocResponseJson.ok();
|
||||
}
|
||||
@@ -366,20 +370,16 @@ public class MgDocumentController {
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2018年8月21日
|
||||
* @param docUrl 文档地址
|
||||
* @param location 文档地址
|
||||
* @return 删除结果
|
||||
*/
|
||||
@Deprecated
|
||||
@PostMapping(value = "/deleteSwaggerDoc")
|
||||
public ResponseJson<Object> deleteSwaggerDoc(String docUrl) {
|
||||
// String swaggerDocsDeleteStr = storageService.get(StorageKeys.SWAGGER_DOCS_DELETE_LIST);
|
||||
// Set<String> swaggerDocsDeleteSet = new HashSet<>();
|
||||
// if (StringUtils.isNotBlank(swaggerDocsDeleteStr)) {
|
||||
// List<String> swaggerDocsDeleteList = JSON.parseArray(swaggerDocsDeleteStr, String.class);
|
||||
// swaggerDocsDeleteSet.addAll(swaggerDocsDeleteList);
|
||||
// }
|
||||
// swaggerDocsDeleteSet.add(docUrl);
|
||||
// storageService.put(StorageKeys.SWAGGER_DOCS_DELETE_LIST, JSON.toJSONString(swaggerDocsDeleteSet));
|
||||
public ResponseJson<Object> deleteSwaggerDoc(String location) {
|
||||
List<LocationListVo> locationList = this.getLocationSet();
|
||||
String locationDel = this.encodeUrlParam(location);
|
||||
locationList = locationList.stream().filter(val -> !Objects.equals(val.getLocation(), locationDel)).collect(Collectors.toList());
|
||||
this.storageSwaggerLocationList(locationList);
|
||||
return DocResponseJson.ok();
|
||||
}
|
||||
|
||||
@@ -405,15 +405,16 @@ public class MgDocumentController {
|
||||
List<LocationListVo> locationList = this.getLocationSet();
|
||||
// 组装新的对象
|
||||
LocationListVo locationListVo = new LocationListVo(locationUrl, "");
|
||||
locationListVo.setRewriteDomainUrl(rewriteDomainUrl);
|
||||
locationListVo.setOpenVisit(openVisit);
|
||||
// 如果旧的不为空,使用旧的uuid
|
||||
for (LocationListVo location : locationList) {
|
||||
if (Objects.equals(location.getLocation(), oldUrl) && StringUtils.isNotBlank(location.getUuid())) {
|
||||
locationListVo.setUuid(location.getUuid());
|
||||
locationListVo = location;
|
||||
break;
|
||||
}
|
||||
}
|
||||
locationListVo.setLocation(locationUrl);
|
||||
locationListVo.setRewriteDomainUrl(rewriteDomainUrl);
|
||||
locationListVo.setOpenVisit(openVisit);
|
||||
// 去除旧的,加入新的
|
||||
locationList = locationList.stream().filter(val -> !Objects.equals(val.getLocation(), oldUrl)).collect(Collectors.toList());
|
||||
locationList.add(locationListVo);
|
||||
@@ -431,14 +432,18 @@ public class MgDocumentController {
|
||||
*/
|
||||
private void addSwaggerLocationList(List<SwaggerResource> resourceList, String resourcesUrl, String rewriteDomainUrl, Integer openVisit) {
|
||||
List<LocationListVo> locationList = this.getLocationSet();
|
||||
Map<String, LocationListVo> locationListVoMap = locationList.stream().collect(Collectors.toMap(LocationListVo::getLocation, val -> val));
|
||||
// 加入到location列表
|
||||
String resourcesDomain = resourcesUrl.substring(0, resourcesUrl.lastIndexOf("/") + 1);
|
||||
for (SwaggerResource swaggerResource : resourceList) {
|
||||
String location = this.getLocationUrl(resourcesDomain, swaggerResource.getLocation(), swaggerResource.getName());
|
||||
LocationListVo locationListVo = new LocationListVo(location, resourcesUrl);
|
||||
LocationListVo locationListVo = locationListVoMap.get(location);
|
||||
if (locationListVo == null) {
|
||||
locationListVo = new LocationListVo(location, resourcesUrl);
|
||||
locationList.add(locationListVo);
|
||||
}
|
||||
locationListVo.setRewriteDomainUrl(rewriteDomainUrl);
|
||||
locationListVo.setOpenVisit(openVisit);
|
||||
locationList.add(locationListVo);
|
||||
}
|
||||
this.storageSwaggerLocationList(locationList);
|
||||
}
|
||||
@@ -447,9 +452,13 @@ public class MgDocumentController {
|
||||
* 保存location列表
|
||||
*/
|
||||
private void storageSwaggerLocationList(List<LocationListVo> locationSet) {
|
||||
AtomicInteger idIndex = new AtomicInteger(1);
|
||||
locationSet = locationSet.stream().distinct().collect(Collectors.toList());
|
||||
locationSet.forEach(val -> val.setId(idIndex.getAndIncrement()));
|
||||
locationSet.forEach(val -> {
|
||||
if (val.getId() == null) {
|
||||
val.setId(storageService.getNextId());
|
||||
}
|
||||
});
|
||||
locationSet = locationSet.stream().sorted(Comparator.comparing(LocationListVo::getId)).collect(Collectors.toList());
|
||||
storageService.put(StorageKeys.SWAGGER_LOCATION_LIST, JSON.toJSONString(locationSet));
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public class MgHttpRequestController {
|
||||
}
|
||||
paramUrl = paramUrl.replace("http://", "").replace("https://", "");
|
||||
String regexStr = paramUrl.substring(0, paramUrl.indexOf("/"));
|
||||
long inWhiteList = whiteDomain.stream().filter(val -> regexStr.matches(val)).count();
|
||||
long inWhiteList = whiteDomain.stream().filter(regexStr::matches).count();
|
||||
if (inWhiteList <= 0) {
|
||||
return DocResponseJson.warn("该域名不在白名单内,不能代理请求");
|
||||
}
|
||||
|
||||
@@ -25,15 +25,12 @@ public class LocationListVo {
|
||||
this.uuid = RandomUtil.simpleUUID();
|
||||
// 修正名字
|
||||
int indexGroup = location.indexOf("group=");
|
||||
int indexV2 = location.indexOf("/v2");
|
||||
if (indexGroup >= 0 && location.length() > indexGroup) {
|
||||
try {
|
||||
this.name = URLDecoder.decode(location.substring(indexGroup + 6), "utf-8");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if (indexV2 >= 0) {
|
||||
this.name = location.substring(indexV2 + 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,4 +15,6 @@ public class StorageKeys {
|
||||
public static final String SWAGGER_LOCATION_LIST = "swagger-location-list";
|
||||
// 文档的离线数据key
|
||||
public static final String SWAGGER_OFFLINE_DOC_START = "swagger-offline-doc-";
|
||||
// 自增ID的key
|
||||
public static final String SWAGGER_ID_WORKER = "swagger-id-worker";
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.zyplayer.doc.swagger.framework.service;
|
||||
|
||||
import com.zyplayer.doc.swagger.framework.constant.StorageKeys;
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -52,4 +55,17 @@ public interface MgStorageService {
|
||||
*/
|
||||
List<String> getProxyRequestWhiteDomain();
|
||||
|
||||
/**
|
||||
* 获取一个自增的ID
|
||||
* @author 暮光:城中城
|
||||
* @since 2019年1月27日
|
||||
*/
|
||||
default Integer getNextId() {
|
||||
synchronized (StorageKeys.SWAGGER_ID_WORKER) {
|
||||
String idWorker = this.get(StorageKeys.SWAGGER_ID_WORKER);
|
||||
Integer nextId = NumberUtils.toInt(idWorker, 1);
|
||||
this.put(StorageKeys.SWAGGER_ID_WORKER, String.valueOf(nextId + 1));
|
||||
return nextId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,8 +39,8 @@
|
||||
<ul>
|
||||
<li id="onlineDebugLi1" class="local-storage"><a href="javascript:void(0)" path=""><i class="icon-bug"></i> 在线调试管理</a></li>
|
||||
<li><a href="#" class="page-nav" data-id="docShowConfig" data-href="webjars/zpages/docShowConfig.html" data-icon="icon-cog" data-reload="0"><i class="icon-cog"></i> 文档展示配置</a></li>
|
||||
<li><a href="#" class="page-nav" data-id="docUrlConfig" data-href="webjars/zpages/docUrlConfig.html" data-icon="icon-list-ul" data-reload="1"><i class="icon-list-ul"></i> 文档地址管理</a></li>
|
||||
<li><a href="#" class="page-nav" data-id="docUrlDetailConfig" data-href="webjars/zpages/docUrlDetailConfig.html" data-icon="icon-list-ul" data-reload="1"><i class="icon-list-ul"></i> 详细地址管理</a></li>
|
||||
<li><a href="#" class="page-nav" data-id="docUrlConfig" data-href="webjars/zpages/docUrlConfig.html" data-icon="icon-list" data-reload="1"><i class="icon-list"></i> 文档地址管理</a></li>
|
||||
<li><a href="#" class="page-nav" data-id="docUrlDetailConfig" data-href="webjars/zpages/docUrlDetailConfig.html" data-icon="icon-list-alt" data-reload="1"><i class="icon-list-alt"></i> 详细地址管理</a></li>
|
||||
<li><a href="#" class="page-nav" data-id="globalParamConfig" data-href="webjars/zpages/globalParamConfig.html" data-icon="icon-globe" data-reload="1"><i class="icon-globe"></i> 全局参数管理</a></li>
|
||||
<li><a href="#" class="page-nav" data-id="debugDataConfig" data-href="webjars/zpages/debugDataConfig.html" data-icon="icon-bug" data-reload="1"><i class="icon-bug"></i> 调试数据管理</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -11,6 +11,7 @@ ul{list-style: none;list-style-type: none;}
|
||||
.tree-menu li li li li li li li li li a{padding-left: 168px;}
|
||||
.tree-menu li li li li li li li li li li a{padding-left: 188px;}
|
||||
.table td, .table th {vertical-align: middle;}
|
||||
.dropdown-menu>li>a{max-width: 100%;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;}
|
||||
#tabDocInfo{position: absolute; bottom: 0;top: 60px;overflow-y: auto; right: 0; left: 10px;}
|
||||
#tabOnlineDebug .param-response-box{position: absolute; bottom: 0;top: 100px;overflow-y: auto; right: 0; left: 10px;padding-right: 10px;}
|
||||
#tabOnlineDebug .panel{margin-bottom: 10px;}
|
||||
@@ -21,6 +22,7 @@ ul{list-style: none;list-style-type: none;}
|
||||
.choice-location-list{margin-bottom: 10px; width: 100%;}
|
||||
.choice-location-list .btn.dropdown-toggle{width: 100%; text-align: left;}
|
||||
.choice-location-list .dropdown-menu{width: 100%;}
|
||||
.choice-location-list .choice-text{max-width: calc(100% - 15px);overflow: hidden;float: left;white-space: nowrap;text-overflow: ellipsis;}
|
||||
.choice-location-list .caret{float: right;margin-top: 8px;}
|
||||
|
||||
/**lable的覆盖样式*/
|
||||
|
||||
@@ -96,6 +96,7 @@ function getDocumentListByService() {
|
||||
var item = json.data[i];
|
||||
$("#choiceLocationList .dropdown-menu").append('<li><a href="javascript:void(0);" data-location="' + item.location + '">' + item.name + '</a></li>');
|
||||
}
|
||||
$("#choiceLocationList .dropdown-menu").append('<li><a href="javascript:void(0);" data-location="">全部文档</a></li>');
|
||||
$("#choiceLocationList .choice-text").text(json.data[0].name);
|
||||
addDocumentByLocationService(json.data[0].location);
|
||||
} else {
|
||||
@@ -412,7 +413,7 @@ $("#apiPathTree").on("click", ".show-doc", function(){
|
||||
$("#simulationResultUrlTest").text(data.domain + docUrl + "?zyplayerApiTest=1");
|
||||
$("#simulationResultUrlTest").attr("href", data.domain + docUrl + "?zyplayerApiTest=1");
|
||||
$("#simulationResultText").val("");
|
||||
getStorage('p-simulation-response-' + docUrl, function(data){
|
||||
getStorage(cacheKeys.pSimulationResponse + docUrl, function(data){
|
||||
var resultText = getNotEmptyStr(data);
|
||||
resultText = (typeof resultText == 'string') ? resultText : JSON.stringify(resultText, null, 4);
|
||||
$("#simulationResultText").val(resultText);
|
||||
|
||||
@@ -7,5 +7,5 @@ var cacheKeys = {
|
||||
swaggerLocationList: 'swagger-location-list',
|
||||
globalParamList: 'zyplayer-doc-global-param-list',
|
||||
pRequestObjStart: 'p-request-obj-',
|
||||
pSimulationResponse: 'p-simulation-response',
|
||||
pSimulationResponse: 'p-simulation-response-',
|
||||
}
|
||||
@@ -10,7 +10,7 @@
|
||||
<body>
|
||||
<div id="app">
|
||||
<div class="alert alert-primary">
|
||||
<div class="content">Tips:开放文档地址 可以不需要登录即可访问</div>
|
||||
<div class="content">Tips:开放文档地址 可以不需要登录即可访问,重写域名地址 填写后需开启:文档展示配置->强制重写域名 后才生效</div>
|
||||
</div>
|
||||
<table class="table table-bordered setting-table">
|
||||
<thead>
|
||||
@@ -26,10 +26,14 @@
|
||||
<tr v-for="(item,index) in swaggerLocationList" :key="item.id" :data-id="item.id" :data-index="index" >
|
||||
<td>{{index+1}}</td>
|
||||
<td>{{item.location}}</td>
|
||||
<td><a :href="'../../open-doc.html?doc='+item.uuid" target="_blank">{{item.uuid}}</a></td>
|
||||
<td>
|
||||
<!--未开放时即使访问这个地址也看不了-->
|
||||
<a v-if="item.openVisit == 1" :href="'../../open-doc.html?doc='+item.uuid" target="_blank">{{item.uuid}}</a>
|
||||
<span v-else>暂未开放</span>
|
||||
</td>
|
||||
<td>{{item.rewriteDomainUrl}}</td>
|
||||
<td>
|
||||
<button class="btn btn-danger" type="button" v-on:click="deleteDocUrl($event)">删除</button>
|
||||
<button class="btn btn-danger" type="button" @click="deleteDocUrl(item.location)">删除</button>
|
||||
<button class="btn btn-info" type="button" v-on:click="editDocUrl($event)">编辑</button>
|
||||
<!--<button class="btn btn-danger" type="button" v-on:click="syncDocData($event)">持久化</button>-->
|
||||
</td>
|
||||
@@ -146,20 +150,14 @@
|
||||
}
|
||||
});
|
||||
},
|
||||
deleteDocUrl: function (event) {
|
||||
deleteDocUrl: function (location) {
|
||||
if (!confirm("确定要删除吗?")) {
|
||||
return;
|
||||
}
|
||||
var tr = $(event.currentTarget).parents("tr");
|
||||
var index = tr.data("index");
|
||||
var newDocList = [];
|
||||
for (var i = 0; i < app.swaggerLocationList.length; i++) {
|
||||
if (i !== index) {
|
||||
newDocList.push(app.swaggerLocationList[i]);
|
||||
ajaxTemp(urlBase + "swagger-mg-ui/document/deleteSwaggerDoc", "post", "json", {location: location}, function (json) {
|
||||
if (validateResult(json)) {
|
||||
app.refreshList();
|
||||
}
|
||||
}
|
||||
setStorage(cacheKeys.swaggerLocationList, newDocList, function () {
|
||||
app.swaggerLocationList = newDocList;
|
||||
});
|
||||
},
|
||||
syncDocData: function (event) {
|
||||
|
||||
Reference in New Issue
Block a user