人间不会有单纯的快乐,快乐总夹杂着烦恼和忧虑,人间也没有永远。——杨绛《我们仨》

pr如下:

https://github.com/apache/shenyu-dashboard/pull/555

思路是首先找到对应的字段,然后找到字段来源,比如从哪个接口请求到的,这里找到了

src/routes/Plugin/Common/Selector.jsdiscoveryConfig.discoveryType,往上追踪找到其discoveryConfig是在src/routes/Plugin/Common/index.js里,通过下面的dispatch回调赋值

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
dispatch({
type: "common/fetchSeItem",
payload: {
id,
namespaceId: currentNamespaceId,
},
callback: (selector) => {
if (isDiscovery) {
let discoveryConfig = {
props:
selector.discoveryVO && selector.discoveryVO.props
? selector.discoveryVO.props
: "{}",
discoveryType:
selector.discoveryVO && selector.discoveryVO.type
? selector.discoveryVO.type
: "local",
serverList:
selector.discoveryVO && selector.discoveryVO.serverList
? selector.discoveryVO.serverList
: "",
handler:
selector.discoveryHandler && selector.discoveryHandler.handler
? selector.discoveryHandler.handler
: "{}",
listenerNode:
selector.discoveryHandler &&
selector.discoveryHandler.listenerNode
? selector.discoveryHandler.listenerNode
: "",
};
let updateArray = [];
if (selector.discoveryUpstreams) {
updateArray = selector.discoveryUpstreams.map((item) => {
let propsObj = JSON.parse(item.props || "{}");
if (item.props === null) {
propsObj = {
warmupTime: 10,
gray: "false",
};
}
return {
...item,
key: item.id,
warmupTime: propsObj.warmupTime,
gray: propsObj.gray,
};
});
}
let discoveryHandlerId = selector.discoveryHandler
? selector.discoveryHandler.id
: "";
this.setState({
popup: (
<Selector
pluginName={name}
{...selector}
multiSelectorHandle={multiSelectorHandle}
discoveryConfig={discoveryConfig}
discoveryUpstreams={updateArray}
isAdd={false}
isDiscovery={true}
handleOk={(values) => {
dispatch({
type: "common/updateSelector",
payload: {
pluginId,
...values,
id,
namespaceId: currentNamespaceId,
},
fetchValue: {
pluginId,
currentPage: selectorPage,
pageSize: selectorPageSize,
namespaceId: currentNamespaceId,
},
callback: () => {
const {
name: selectorName,
handler,
upstreams,
serverList,
listenerNode,
discoveryProps,
importedDiscoveryId,
selectedDiscoveryType,
} = values;

if (!discoveryHandlerId) {
this.addDiscoveryUpstream({
selectorId: id,
selectorName,
pluginName: name,
listenerNode,
handler,
typeValue: this.getTypeValueByPluginName(name),
upstreamsWithProps:
this.getUpstreamsWithProps(upstreams),
importedDiscoveryId,
selectedDiscoveryType,
serverList,
discoveryProps,
namespaceId: currentNamespaceId,
});
} else {
this.updateDiscoveryUpstream(
discoveryHandlerId,
upstreams,
);
}
this.closeModal();
},
});
}}
onCancel={this.closeModal}
/>
),
});
} else {
this.setState({
popup: (
<Selector
pluginName={name}
{...selector}
multiSelectorHandle={multiSelectorHandle}
isDiscovery={false}
handleOk={(values) => {
dispatch({
type: "common/updateSelector",
payload: {
pluginId,
...values,
id,
namespaceId: currentNamespaceId,
},
fetchValue: {
pluginId,
currentPage: selectorPage,
pageSize: selectorPageSize,
namespaceId: currentNamespaceId,
},
callback: () => {
this.closeModal();
},
});
}}
onCancel={this.closeModal}
/>
),
});
}
},
})

dispatch({type:"common/fetchSeItem")调用的是src/models/common.js里的fetchSeItem,实际是src/services/api.js的${baseUrl}/selector/${params.id}请求

我们打开network查看到对应请求是有数据的

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
{
"code": 200,
"message": "detail success",
"data": {
"id": "1983487553797926912",
"pluginId": "5",
"name": "test",
"matchMode": 0,
"matchModeName": "and",
"type": 0,
"typeName": "full",
"sort": 1,
"enabled": true,
"loged": true,
"continued": true,
"matchRestful": false,
"handle": null,
"selectorConditions": [
{
"id": "1983487553802121216",
"selectorId": "1983487553797926912",
"paramType": "uri",
"paramTypeName": "uri",
"operator": "pathPattern",
"operatorName": "pathPattern",
"paramName": "/",
"paramValue": "",
"dateCreated": "2025-10-29 18:54:18",
"dateUpdated": "2025-10-29 18:54:18"
}
],
"dateCreated": "2025-10-29 18:54:18",
"dateUpdated": "2025-10-29 18:54:18",
"discoveryHandler": {
"id": "1983487553869230080",
"discoveryId": "1983487553865035776",
"handler": "{}",
"listenerNode": "1",
"props": null
},
"discoveryVO": {
"id": "1983487553865035776",
"discoveryName": "zookeeper",
"discoveryType": "zookeeper",
"level": "0",
"serverList": "1",
"pluginName": "divide",
"props": "{\"baseSleepTimeMilliseconds\":\"1000\",\"maxRetries\":\"3\",\"maxSleepTimeMilliseconds\":\"1000\",\"connectionTimeoutMilliseconds\":\"1000\",\"sessionTimeoutMilliseconds\":\"1000\",\"namespace\":\"\",\"digest\":null}",
"namespaceId": "649330b6-c2d7-4edc-be8e-8a54df9eb385",
"discoveryHandler": null,
"discoveryRel": null
},
"discoveryUpstreams": [],
"selectorRules": null,
"namespaceId": "649330b6-c2d7-4edc-be8e-8a54df9eb385"
}
}

是这个discoveryVO,看到里面的字段是discoveryType

但是代码里

1
2
3
4
discoveryType:
selector.discoveryVO && selector.discoveryVO.type
? selector.discoveryVO.type
: "local",

我们改为

1
2
3
4
discoveryType:
selector.discoveryVO && selector.discoveryVO.discoveryType
? selector.discoveryVO.discoveryType
: "local",

测试即可