whistle.mock-plugins 1.1.1-dev.11 → 1.1.1-dev.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/routes/interfaces.js
CHANGED
|
@@ -23,6 +23,7 @@ const processInterfaceData = (data) => {
|
|
|
23
23
|
console.log('=== 开始处理接口数据 ===');
|
|
24
24
|
console.log('原始数据:', JSON.stringify({
|
|
25
25
|
name: result.name,
|
|
26
|
+
group: result.group, // 添加分组信息的日志
|
|
26
27
|
hasResponses: !!result.responses,
|
|
27
28
|
responsesType: typeof result.responses,
|
|
28
29
|
responsesLength: result.responses ? result.responses.length : 0,
|
|
@@ -108,6 +109,7 @@ const processInterfaceData = (data) => {
|
|
|
108
109
|
console.log('=== 处理后的最终接口数据 ===');
|
|
109
110
|
console.log('最终数据:', JSON.stringify({
|
|
110
111
|
name: result.name,
|
|
112
|
+
group: result.group, // 添加分组信息的日志
|
|
111
113
|
responsesLength: result.responses.length,
|
|
112
114
|
responses: result.responses,
|
|
113
115
|
activeResponseId: result.activeResponseId,
|
package/package.json
CHANGED
|
@@ -299,10 +299,16 @@ const InterfaceManagement = () => {
|
|
|
299
299
|
}));
|
|
300
300
|
}
|
|
301
301
|
|
|
302
|
+
// 处理分组值,确保它是字符串而不是数组
|
|
303
|
+
let groupValue = record.group;
|
|
304
|
+
if (Array.isArray(groupValue)) {
|
|
305
|
+
groupValue = groupValue.length > 0 ? groupValue[0] : undefined;
|
|
306
|
+
}
|
|
307
|
+
|
|
302
308
|
// 设置表单值
|
|
303
309
|
form.setFieldsValue({
|
|
304
310
|
name: record.name,
|
|
305
|
-
group:
|
|
311
|
+
group: groupValue || undefined, // 使用undefined而不是空字符串
|
|
306
312
|
pattern: record.urlPattern,
|
|
307
313
|
proxyType: record.proxyType || 'response',
|
|
308
314
|
statusCode: (record.httpStatus || record.statusCode || 200).toString(),
|
|
@@ -316,7 +322,7 @@ const InterfaceManagement = () => {
|
|
|
316
322
|
responseDelay: record.responseDelay ? record.responseDelay.toString() : '0'
|
|
317
323
|
});
|
|
318
324
|
|
|
319
|
-
console.log('编辑接口时设置的分组值:',
|
|
325
|
+
console.log('编辑接口时设置的分组值:', groupValue);
|
|
320
326
|
|
|
321
327
|
setCurrentResponseId(activeResponseId);
|
|
322
328
|
setEditingInterface(record);
|
|
@@ -377,10 +383,16 @@ const InterfaceManagement = () => {
|
|
|
377
383
|
});
|
|
378
384
|
}
|
|
379
385
|
|
|
386
|
+
// 处理分组值,确保它是字符串而不是数组
|
|
387
|
+
let groupValue = values.group;
|
|
388
|
+
if (Array.isArray(groupValue)) {
|
|
389
|
+
groupValue = groupValue.length > 0 ? groupValue[0] : '';
|
|
390
|
+
}
|
|
391
|
+
|
|
380
392
|
// 构建接口数据
|
|
381
393
|
const interfaceData = {
|
|
382
394
|
name: values.name,
|
|
383
|
-
group:
|
|
395
|
+
group: groupValue || '', // 确保group不为undefined
|
|
384
396
|
urlPattern: values.pattern,
|
|
385
397
|
proxyType: values.proxyType,
|
|
386
398
|
featureId: selectedFeatureId,
|
|
@@ -393,7 +405,7 @@ const InterfaceManagement = () => {
|
|
|
393
405
|
active: true
|
|
394
406
|
};
|
|
395
407
|
|
|
396
|
-
console.log('提交的分组值:',
|
|
408
|
+
console.log('提交的分组值:', groupValue);
|
|
397
409
|
|
|
398
410
|
// 根据代理类型添加不同字段
|
|
399
411
|
if (values.proxyType === 'redirect' || values.proxyType === 'url_redirect') {
|
|
@@ -429,6 +441,8 @@ const InterfaceManagement = () => {
|
|
|
429
441
|
const response = await axios.post('/cgi-bin/interfaces', interfaceData);
|
|
430
442
|
if (response.data && response.data.code === 0) {
|
|
431
443
|
message.success('接口创建成功');
|
|
444
|
+
console.log('接口创建成功,返回数据:', response.data);
|
|
445
|
+
console.log('返回的接口数据中的分组信息:', response.data.data?.group);
|
|
432
446
|
setModalVisible(false);
|
|
433
447
|
fetchInterfaces();
|
|
434
448
|
|
|
@@ -1164,6 +1178,17 @@ const InterfaceManagement = () => {
|
|
|
1164
1178
|
showSearch
|
|
1165
1179
|
allowClear
|
|
1166
1180
|
style={{ width: '100%' }}
|
|
1181
|
+
mode="tags"
|
|
1182
|
+
maxTagCount="responsive"
|
|
1183
|
+
maxTagTextLength={10}
|
|
1184
|
+
onChange={(value) => {
|
|
1185
|
+
// 如果值是数组(tags模式),只取第一个元素
|
|
1186
|
+
if (Array.isArray(value) && value.length > 0) {
|
|
1187
|
+
// 如果第一个元素是空字符串,则设置为undefined
|
|
1188
|
+
const groupValue = value[0] === '' ? undefined : value[0];
|
|
1189
|
+
form.setFieldsValue({ group: groupValue });
|
|
1190
|
+
}
|
|
1191
|
+
}}
|
|
1167
1192
|
onInputKeyDown={(e) => {
|
|
1168
1193
|
// 防止回车键提交表单
|
|
1169
1194
|
if (e.key === 'Enter') {
|