Skip to content

Commit

Permalink
2.0.6RELEASED
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoymin committed Oct 26, 2020
1 parent e7a0f2f commit e2169e1
Show file tree
Hide file tree
Showing 134 changed files with 5,746 additions and 5,267 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,9 @@ private void initGlobalRequestMappingArray(SwaggerExt swaggerExt){
for (RequestHandler requestHandler:requestHandlers){
if (requestHandler instanceof WebMvcRequestHandler){
WebMvcRequestHandler webMvcRequestHandler=(WebMvcRequestHandler)requestHandler;
Set<String> patterns =webMvcRequestHandler.getRequestMapping().getPatternsCondition().getPatterns();
Set<RequestMethod> restMethods=webMvcRequestHandler.getRequestMapping().getMethodsCondition().getMethods();
RequestMappingInfo requestMappingInfo= (RequestMappingInfo) webMvcRequestHandler.getRequestMapping().getOriginalInfo();
Set<RequestMethod> restMethods=requestMappingInfo.getMethodsCondition().getMethods();
Set<String> patterns =requestMappingInfo.getPatternsCondition().getPatterns();
HandlerMethod handlerMethod=webMvcRequestHandler.getHandlerMethod();
Class<?> controllerClazz=ClassUtils.getUserClass(handlerMethod.getBeanType());
Method method = ClassUtils.getMostSpecificMethod(handlerMethod.getMethod(),controllerClazz);
Expand Down
451 changes: 451 additions & 0 deletions backup/Knife4jOpenApi3ExtController.java

Large diffs are not rendered by default.

27 changes: 0 additions & 27 deletions knife4j-vue/package-lock.json

This file was deleted.

4 changes: 4 additions & 0 deletions knife4j-vue/public/oauth/jquery.min.js

Large diffs are not rendered by default.

92 changes: 92 additions & 0 deletions knife4j-vue/public/oauth/oauth2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<title>Knife4j-OAuth2</title>
<script src="jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(function(){
function OAuth2(url){
this.url=url;
this.code=null;
this.accessToken=null;
this.tokenType=null;
this.state=null;
//缓存在localStorage中的对象
this.cacheValue=null;
}
OAuth2.prototype.init=function(){
var local=this.url;
this.code=this.getKey("code",local,"");
this.accessToken=this.getKey("access_token",local,"");
this.tokenType=this.getKey("token_type",local,"Bearer");
this.state=this.getKey("state",local);
if(window.localStorage){
var value=window.localStorage.getItem(this.state);
if(this.strNotBlank(value)){
this.cacheValue=JSON.parse(value);
}
}
}
OAuth2.prototype.auth=function(){
if(this.strNotBlank(this.code)){
this.authorizationCode();
}else{
this.implicit();
}
}
OAuth2.prototype.getKey=function(key,str,defaultValue){
var reg=new RegExp(".*?"+key+"=(.*?)(&.*)?$","ig");
var val=defaultValue;
if(reg.test(str)){
val=RegExp.$1;
}
return val;
}
OAuth2.prototype.strNotBlank=function(str){
var flag = false;
if ( str != undefined &&str != null &&str != "") {
flag = true;
}
return flag;
}

OAuth2.prototype.implicit=function(){
this.cacheValue.accessToken=this.tokenType+" "+this.accessToken;
this.cacheValue.tokenType=this.tokenType;
this.cacheValue.granted=true;
window.localStorage.setItem(this.state,JSON.stringify(this.cacheValue))
window.close();
}
OAuth2.prototype.authorizationCode=function(){
var that=this;
console.log(this.cacheValue);
var url=this.cacheValue.tokenUrl;
var params={
"grant_type":"authorization_code",
"code":this.code,
"redirect_uri":decodeURIComponent(this.cacheValue.redirectUri),
"client_id":this.cacheValue.clientId,
"client_secret":this.cacheValue.clientSecret
}
$.post(url,params,function(data){
if(data!=null&&data!=undefined) {
that.cacheValue.accessToken=data.token_type+" "+data.access_token;
that.cacheValue.tokenType=data.token_type;
that.cacheValue.granted=true;
window.localStorage.setItem(that.state,JSON.stringify(that.cacheValue))
window.close();
}
})
}
var oauth=new OAuth2(window.location.href);
oauth.init();
oauth.auth();
})
</script>

</body>
</html>
8 changes: 8 additions & 0 deletions knife4j-vue/src/assets/common/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ const langOptions = {
curl:{
success: 'Copy curl successfully',
fail: 'Copy curl failed, your current browser version is not compatible, please copy manually.'
},
open:{
success: 'Copy OpenAPI successfully',
fail: 'Copy OpenAPI failed, your current browser version is not compatible, please copy manually.'
}
},
layer: {
Expand Down Expand Up @@ -520,6 +524,10 @@ const langOptions = {
}

},
open:{
copy:' Copy ',
download:' Download '
},
tab: {
closeCurrent: 'Close Current Tab',
closeOther: 'Close Other Tab',
Expand Down
8 changes: 8 additions & 0 deletions knife4j-vue/src/assets/common/lang/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,10 @@ const langOptions = {
curl:{
success: '复制curl成功',
fail: '复制curl失败,您当前浏览器版本不兼容,请手动复制.'
},
open:{
success: '复制OpenAPI成功',
fail: '复制OpenAPI失败,您当前浏览器版本不兼容,请手动复制.'
}
},
layer: {
Expand Down Expand Up @@ -511,6 +515,10 @@ const langOptions = {
}

},
open:{
copy:' 复 制 ',
download:' 下 载 '
},
tab: {
closeCurrent: '关闭当前标签页',
closeOther: '关闭其它标签页',
Expand Down
4 changes: 2 additions & 2 deletions knife4j-vue/src/components/GlobalHeader/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ export default {
methods: {
changeZh() {
//中文
console.log(this);
//console.log(this);
this.$i18n.locale = "zh-CN";
this.$store.dispatch("globals/setLang", "zh-CN");
this.$localStore.setItem(constant.globalI18nCache, "zh-CN");
},
changeEn() {
//英文
console.log(this);
//console.log(this);
this.$i18n.locale = "en-US";
this.$store.dispatch("globals/setLang", "en-US");
this.$localStore.setItem(constant.globalI18nCache, "en-US");
Expand Down
159 changes: 159 additions & 0 deletions knife4j-vue/src/core/Environment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
import localStore from '@/store/local'
import constant from '@/store/constants'
import KUtils from '@/core/utils';

var KEnvironment =function(settings){
window.console.log(settings)
this.groupid=settings.groupid||'afterScriptGroup';
this.allgroupids=settings.allgroupids||[];
this.response=settings.response||{
data:{},
headers:{}
};
this.global={
/**
* 设置当前逻辑分组下全局Header
* @param {*} name Header名称
* @param {*} value Header值
*/
setHeader:(name,value)=>{
this.global.setCommon(name,value,'header',false);
},
/**
* 设置所有逻辑分组下全局Header
* @param {*} name Header名称
* @param {*} value Header值
*/
setAllHeader:(name,value)=>{
this.global.setCommon(name,value,'header',true);
},
/**
* 当前逻辑分组下全局设置query类型的参数
* @param {*} name 参数名称
* @param {*} value 参数值
*/
setParameter:(name,value)=>{
this.global.setCommon(name,value,'query',false);
},
/**
* 所有逻辑分组下全局设置query类型的参数
* @param {*} name 参数名称
* @param {*} value 参数值
*/
setAllParameter:(name,value)=>{
this.global.setCommon(name,value,'query',true);
},
setCommon:(name,value,type,all)=>{
//window.console.log('setCommon,name:'+name+',value:'+value+',type:'+type);
var key=this.groupid;
var pkid=name+type;
if(all){
var allGroup=this.allgroupids;
//更新所有逻辑分组下的全局参数
localStore.getItem(constant.globalParameter).then(val => {
if(KUtils.checkUndefined(val)){
var tmpVal={};
allGroup.forEach(gid=>{
var tmpValue=val[gid];
if(KUtils.checkUndefined(tmpValue)||KUtils.arrEmpty(tmpValue)){
//空的,直接push
tmpValue=[];
tmpValue.push({
name: name,
value: value,
in: type,
pkid: pkid
})
tmpVal[gid]=tmpValue;
}else{
//不为空,更新
//1.是否包含该参数,包含则更新,不包含新增
var exlength=tmpValue.filter(p=>p.pkid==pkid && p.in==type).length;
if(exlength==0){
//不存在
tmpValue.push({
name: name,
value: value,
in: type,
pkid: pkid
})
}else{
tmpValue.forEach(gp=>{
if(gp.in==type && gp.pkid==pkid){
gp.value=value;
}
})
}
tmpVal[gid]=tmpValue;
}
})
//存储
localStore.setItem(constant.globalParameter, tmpVal);
}else{
var tmpGlobalParams=[];
tmpGlobalParams.push({
name: name,
value: value,
in: type,
pkid: pkid
})
var groupVal={};
allGroup.forEach(gid=>{
groupVal[gid]=tmpGlobalParams;
})
//存储
localStore.setItem(constant.globalParameter, groupVal);
}
})
}else{
//设置当前逻辑分组的全局参数
localStore.getItem(constant.globalParameter).then(val => {
//存在全局参数
var groupParameters=[];
var tmpVal={};
if(KUtils.checkUndefined(val)){
for(var gid in val){
if(gid==key){
groupParameters=val[gid];
}else{
tmpVal[gid]=val[gid];
}
}
var exlength=groupParameters.filter(p=>p.pkid==pkid && p.in==type).length;
if(exlength==0){
//不存在
groupParameters.push({
name: name,
value: value,
in: type,
pkid: pkid
})
}else{
groupParameters.forEach(gp=>{
if(gp.in==type && gp.pkid==pkid){
gp.value=value;
}
})
}
tmpVal[key]=groupParameters;
//存储
localStore.setItem(constant.globalParameter, tmpVal);
}else{
groupParameters.push({
name: name,
value: value,
in: type,
pkid: pkid
})
}
tmpVal[key]=groupParameters;
// window.console.log(tmpVal)
//存储
localStore.setItem(constant.globalParameter, tmpVal);
})
}
}
}
};

export default KEnvironment;
Loading

0 comments on commit e2169e1

Please sign in to comment.