mirror of https://github.com/jeecgboot/jeecg-boot
parent
dfbbd1bd1f
commit
727b67a50d
|
@ -28,14 +28,15 @@
|
|||
<a-divider>{{item.name}}
|
||||
<a-icon type="delete" size="22" @click="removePredicate(router,index)"/>
|
||||
</a-divider>
|
||||
<div>
|
||||
<template v-for="(tag, index) in item.args">
|
||||
<a-input v-if="index==currentTagIndex" ref="input" type="text" size="small"
|
||||
<!--当name在 genKeyRouter 时不需要指定key,后台自动拼key -->
|
||||
<div v-if="genKeyRouter.includes(item.name)">
|
||||
<template v-for="(tag, tagIndex) in item.args">
|
||||
<a-input v-if="tagIndex==currentTagIndex&&index==currentNameIndex" ref="input" type="text" size="small"
|
||||
:style="{ width: '190px' }"
|
||||
:value="tag"
|
||||
@change="handleInputChange" @blur="handleInputEditConfirm(item,tag,index)"
|
||||
@keyup.enter="handleInputEditConfirm(item,tag,index)"/>
|
||||
<a-tag v-else :key="tag" :closable="true" @close="() => removeTag(item,tag)" @click="editTag(tag,index)">
|
||||
@change="handleInputChange" @blur="handleInputEditConfirm(item,tag,tagIndex)"
|
||||
@keyup.enter="handleInputEditConfirm(item,tag,tagIndex)"/>
|
||||
<a-tag v-else :key="tag" :closable="true" @close="() => removeTag(item,tag)" @click="editTag(tag,tagIndex,index)">
|
||||
{{ tag }}
|
||||
</a-tag>
|
||||
</template>
|
||||
|
@ -49,11 +50,27 @@
|
|||
新建{{item.name}}
|
||||
</a-tag>
|
||||
</div>
|
||||
<!--当name不在 genKeyRouter 时需要指定key-->
|
||||
<div v-if="!genKeyRouter.includes(item.name)">
|
||||
<template v-for="(value, key) in item.args">
|
||||
<a-row>
|
||||
<a-col :span="5" style="margin-top:2px">
|
||||
<span v-if="key=='header'" >Header名称</span>
|
||||
<span v-if="key=='regexp'">参数值</span>
|
||||
<span v-if="key=='param'">参数名</span>
|
||||
<span v-if="key=='name'">Cookie名称</span>
|
||||
</a-col>
|
||||
<a-col :span="18">
|
||||
<a-input :defaultValue="value" placeholder="参数值" style="width: 70%; margin-right: 8px;margin-top: 3px" @change="(e)=>valueChange(e,item.args,key)"/>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
<p class="btn" style="padding-top: 10px">
|
||||
<a-dropdown>
|
||||
<a-menu slot="overlay" @click="predicatesHandleMenuClick">
|
||||
<a-menu-item :key="item" v-for="item in tagArray">{{item}}</a-menu-item>
|
||||
<a-menu slot="overlay">
|
||||
<a-menu-item :key="item.name" v-for="item in tagArray" @click="predicatesHandleMenuClick(item)">{{item.name}}</a-menu-item>
|
||||
</a-menu>
|
||||
<a-button type="dashed" style="margin-left: 8px;width:100%"> 添加路由条件
|
||||
<a-icon type="down"/>
|
||||
|
@ -113,8 +130,55 @@
|
|||
currentNameIndex: 0,
|
||||
currentTagIndex:-1,
|
||||
predicates: {},
|
||||
filterArray: [{ key: 0, name: '熔断器' }, { key: 1, name: '限流过滤器' }],
|
||||
tagArray: ['Path', 'Host', 'Cookie', 'Header', 'Method', 'Query', 'After', 'Before', 'Between', 'RemoteAddr'],
|
||||
filterArray: [ { key: 1, name: '限流过滤器' }],
|
||||
//gateway对应的规则key
|
||||
tagArray: [
|
||||
{
|
||||
name:'Header',
|
||||
args:{
|
||||
header:'',
|
||||
regexp:''
|
||||
}
|
||||
},
|
||||
{
|
||||
name:'Query',
|
||||
args:{
|
||||
param:'',
|
||||
regexp:''
|
||||
}
|
||||
},
|
||||
{
|
||||
name:'Method',
|
||||
args:[]
|
||||
},
|
||||
{
|
||||
name:'Host',
|
||||
args:[]
|
||||
},
|
||||
{
|
||||
name:'Cookie',
|
||||
args:{
|
||||
name:'',
|
||||
regexp:''
|
||||
}
|
||||
},
|
||||
{
|
||||
name:'After',
|
||||
args:[]
|
||||
},
|
||||
{
|
||||
name:'Before',
|
||||
args:[]
|
||||
},
|
||||
{
|
||||
name:'Between',
|
||||
args:[]
|
||||
},
|
||||
{
|
||||
name:'RemoteAddr',
|
||||
args:[]
|
||||
}
|
||||
],
|
||||
inputVisible: false,
|
||||
inputValue: '',
|
||||
url: {
|
||||
|
@ -124,7 +188,8 @@
|
|||
router: this.getRouter(),
|
||||
title: '路由编辑',
|
||||
visible: false,
|
||||
loading: false
|
||||
loading: false,
|
||||
genKeyRouter:["Path","Host","Method","After","Before","Between","RemoteAddr"]
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -163,12 +228,22 @@
|
|||
//添加路由选项
|
||||
predicatesHandleMenuClick(e) {
|
||||
this.router.predicates.push({
|
||||
args: [],
|
||||
name: e.key
|
||||
args: e.args,
|
||||
name: e.name,
|
||||
})
|
||||
},
|
||||
editTag(tag,index){
|
||||
this.currentTagIndex=index
|
||||
editTag(tag, tagIndex,index){
|
||||
this.currentNameIndex = index;
|
||||
this.currentTagIndex=tagIndex
|
||||
},
|
||||
/**
|
||||
* 值修改事件
|
||||
* @param e
|
||||
* @param item
|
||||
* @param key
|
||||
*/
|
||||
valueChange(e,item,key){
|
||||
item[key]=e.target.value
|
||||
},
|
||||
//显示输入框
|
||||
showInput(item, index) {
|
||||
|
@ -226,7 +301,7 @@
|
|||
value: 20
|
||||
}],
|
||||
name:"RequestRateLimiter",
|
||||
title: this.filterArray[1].name
|
||||
title: this.filterArray[0].name
|
||||
})
|
||||
}
|
||||
},
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,6 @@
|
|||
package org.jeecg.loader;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
|
@ -35,6 +36,7 @@ import java.net.URI;
|
|||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
|
@ -55,7 +57,10 @@ public class DynamicRouteLoader implements ApplicationEventPublisherAware {
|
|||
private DynamicRouteService dynamicRouteService;
|
||||
private ConfigService configService;
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
/**
|
||||
* 需要拼接key的路由条件
|
||||
*/
|
||||
private static String[] GEN_KEY_ROUTERS = new String[]{"Path", "Host", "Method", "After", "Before", "Between", "RemoteAddr"};
|
||||
|
||||
public DynamicRouteLoader(MyInMemoryRouteDefinitionRepository repository, DynamicRouteService dynamicRouteService, RedisUtil redisUtil) {
|
||||
|
||||
|
@ -195,11 +200,27 @@ public class DynamicRouteLoader implements ApplicationEventPublisherAware {
|
|||
for (Object map : list) {
|
||||
JSONObject json = (JSONObject) map;
|
||||
PredicateDefinition predicateDefinition = new PredicateDefinition();
|
||||
predicateDefinition.setName(json.getString("name"));
|
||||
//update-begin-author:zyf date:20220419 for:【VUEN-762】路由条件添加异常问题,原因是部分路由条件参数需要设置固定key
|
||||
String name=json.getString("name");
|
||||
predicateDefinition.setName(name);
|
||||
//路由条件是否拼接Key
|
||||
if(ArrayUtil.contains(GEN_KEY_ROUTERS,name)) {
|
||||
JSONArray jsonArray = json.getJSONArray("args");
|
||||
for (int j = 0; j < jsonArray.size(); j++) {
|
||||
predicateDefinition.addArg("_genkey" + j, jsonArray.get(j).toString());
|
||||
}
|
||||
}else{
|
||||
JSONObject jsonObject = json.getJSONObject("args");
|
||||
if(ObjectUtil.isNotEmpty(jsonObject)){
|
||||
for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
|
||||
Object valueObj=entry.getValue();
|
||||
if(ObjectUtil.isNotEmpty(valueObj)) {
|
||||
predicateDefinition.addArg(entry.getKey(), valueObj.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//update-end-author:zyf date:20220419 for:【VUEN-762】路由条件添加异常问题,原因是部分路由条件参数需要设置固定key
|
||||
predicateDefinitionList.add(predicateDefinition);
|
||||
}
|
||||
route.setPredicates(predicateDefinitionList);
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package com.alibaba.nacos.control;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
/**
|
||||
* 积木报表-设置默认首页跳转
|
||||
*/
|
||||
@Controller
|
||||
public class IndexController {
|
||||
private Logger logger = LoggerFactory.getLogger(IndexController.class);
|
||||
|
||||
@GetMapping("/")
|
||||
public String index(Model model) {
|
||||
return "/nacos"; // 视图重定向 - 跳转
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue