whistle.mock-plugins 1.0.6-beta.13 → 1.0.6-beta.14
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.
|
@@ -69,12 +69,16 @@
|
|
|
69
69
|
|
|
70
70
|
/** */
|
|
71
71
|
|
|
72
|
+
/** */
|
|
73
|
+
|
|
72
74
|
/** */
|
|
73
75
|
|
|
74
76
|
/** */
|
|
75
77
|
|
|
76
78
|
/** */
|
|
77
79
|
|
|
80
|
+
/** */
|
|
81
|
+
|
|
78
82
|
/** */
|
|
79
83
|
|
|
80
84
|
/** */
|
|
@@ -105,6 +109,8 @@
|
|
|
105
109
|
|
|
106
110
|
/** */
|
|
107
111
|
|
|
112
|
+
/** */
|
|
113
|
+
|
|
108
114
|
/** */
|
|
109
115
|
|
|
110
116
|
/** */
|
|
@@ -113,8 +119,6 @@
|
|
|
113
119
|
|
|
114
120
|
/** */
|
|
115
121
|
|
|
116
|
-
/** */
|
|
117
|
-
|
|
118
122
|
/** */
|
|
119
123
|
|
|
120
124
|
/** */
|
|
@@ -135,6 +139,8 @@
|
|
|
135
139
|
|
|
136
140
|
/** */
|
|
137
141
|
|
|
142
|
+
/** */
|
|
143
|
+
|
|
138
144
|
/** */
|
|
139
145
|
|
|
140
146
|
/** */
|
package/package.json
CHANGED
|
@@ -1242,17 +1242,25 @@ const InterfaceManagement = () => {
|
|
|
1242
1242
|
|
|
1243
1243
|
{/* 响应管理 */}
|
|
1244
1244
|
<Card
|
|
1245
|
-
title=
|
|
1245
|
+
title={
|
|
1246
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
|
|
1247
|
+
<FileTextOutlined />
|
|
1248
|
+
<span>响应管理</span>
|
|
1249
|
+
<Badge count={responses.length} style={{ backgroundColor: '#52c41a' }} />
|
|
1250
|
+
</div>
|
|
1251
|
+
}
|
|
1246
1252
|
extra={
|
|
1247
1253
|
<Button
|
|
1248
1254
|
type="primary"
|
|
1249
|
-
icon={<
|
|
1255
|
+
icon={<PlusCircleOutlined />}
|
|
1250
1256
|
onClick={handleAddResponse}
|
|
1257
|
+
size="small"
|
|
1251
1258
|
>
|
|
1252
1259
|
添加响应
|
|
1253
1260
|
</Button>
|
|
1254
1261
|
}
|
|
1255
1262
|
style={{ marginBottom: 16 }}
|
|
1263
|
+
bodyStyle={{ padding: '16px' }}
|
|
1256
1264
|
>
|
|
1257
1265
|
<Form.Item
|
|
1258
1266
|
name="responses"
|
|
@@ -1290,187 +1298,217 @@ const InterfaceManagement = () => {
|
|
|
1290
1298
|
|
|
1291
1299
|
const activeResponseId = getFieldValue('activeResponseId');
|
|
1292
1300
|
|
|
1301
|
+
if (responses.length === 0) {
|
|
1302
|
+
return (
|
|
1303
|
+
<div style={{
|
|
1304
|
+
textAlign: 'center',
|
|
1305
|
+
padding: '40px 20px',
|
|
1306
|
+
background: '#fafafa',
|
|
1307
|
+
borderRadius: '6px',
|
|
1308
|
+
border: '1px dashed #d9d9d9'
|
|
1309
|
+
}}>
|
|
1310
|
+
<FileAddOutlined style={{ fontSize: '32px', color: '#d9d9d9', marginBottom: '8px' }} />
|
|
1311
|
+
<div style={{ color: '#999', marginBottom: '16px' }}>暂无响应数据</div>
|
|
1312
|
+
<Button
|
|
1313
|
+
type="primary"
|
|
1314
|
+
icon={<PlusCircleOutlined />}
|
|
1315
|
+
onClick={handleAddResponse}
|
|
1316
|
+
>
|
|
1317
|
+
创建第一个响应
|
|
1318
|
+
</Button>
|
|
1319
|
+
</div>
|
|
1320
|
+
);
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1293
1323
|
return (
|
|
1294
|
-
<
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
border: '1px solid #d9d9d9',
|
|
1306
|
-
borderRadius: 4,
|
|
1307
|
-
backgroundColor: (item.id === activeResponseId) ? '#e6f7ff' : 'transparent',
|
|
1308
|
-
borderLeft: (item.id === activeResponseId) ? '3px solid #1890ff' : '1px solid #d9d9d9'
|
|
1309
|
-
}}
|
|
1310
|
-
actions={[
|
|
1311
|
-
<Button
|
|
1312
|
-
key="select"
|
|
1313
|
-
type={(item.id === activeResponseId) ? "primary" : "default"}
|
|
1314
|
-
size="small"
|
|
1315
|
-
onClick={() => handleResponseSelect(item.id)}
|
|
1324
|
+
<div>
|
|
1325
|
+
{/* 响应选择器 */}
|
|
1326
|
+
<div style={{ marginBottom: '16px' }}>
|
|
1327
|
+
<Row gutter={12} align="middle">
|
|
1328
|
+
<Col flex="auto">
|
|
1329
|
+
<Select
|
|
1330
|
+
style={{ width: '100%' }}
|
|
1331
|
+
placeholder="选择要编辑的响应"
|
|
1332
|
+
value={activeResponseId}
|
|
1333
|
+
onChange={(value) => handleResponseSelect(value)}
|
|
1334
|
+
optionLabelProp="label"
|
|
1316
1335
|
>
|
|
1317
|
-
{(
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1336
|
+
{responses.map((resp, index) => (
|
|
1337
|
+
<Option
|
|
1338
|
+
key={resp.id}
|
|
1339
|
+
value={resp.id}
|
|
1340
|
+
label={
|
|
1341
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
|
|
1342
|
+
<CheckCircleOutlined style={{ color: '#52c41a' }} />
|
|
1343
|
+
<span>{resp.name || `响应 ${index + 1}`}</span>
|
|
1344
|
+
</div>
|
|
1345
|
+
}
|
|
1346
|
+
>
|
|
1347
|
+
<div style={{ padding: '4px 0' }}>
|
|
1348
|
+
<div style={{
|
|
1349
|
+
display: 'flex',
|
|
1350
|
+
alignItems: 'center',
|
|
1351
|
+
justifyContent: 'space-between',
|
|
1352
|
+
marginBottom: '4px'
|
|
1353
|
+
}}>
|
|
1354
|
+
<span style={{ fontWeight: 'bold' }}>
|
|
1355
|
+
{resp.name || `响应 ${index + 1}`}
|
|
1356
|
+
</span>
|
|
1357
|
+
{resp.id === activeResponseId && (
|
|
1358
|
+
<Badge status="processing" text="当前选中" />
|
|
1359
|
+
)}
|
|
1360
|
+
</div>
|
|
1361
|
+
{resp.description && (
|
|
1362
|
+
<div style={{
|
|
1363
|
+
color: '#666',
|
|
1364
|
+
fontSize: '12px',
|
|
1365
|
+
marginBottom: '4px'
|
|
1366
|
+
}}>
|
|
1367
|
+
{resp.description}
|
|
1368
|
+
</div>
|
|
1369
|
+
)}
|
|
1370
|
+
<div style={{
|
|
1371
|
+
color: '#999',
|
|
1372
|
+
fontSize: '11px',
|
|
1373
|
+
fontFamily: 'monospace'
|
|
1374
|
+
}}>
|
|
1375
|
+
{resp.content ? `${resp.content.length} 字符` : '空内容'}
|
|
1376
|
+
</div>
|
|
1377
|
+
</div>
|
|
1378
|
+
</Option>
|
|
1379
|
+
))}
|
|
1380
|
+
</Select>
|
|
1381
|
+
</Col>
|
|
1382
|
+
<Col>
|
|
1383
|
+
<Tooltip title="删除当前响应">
|
|
1384
|
+
<Button
|
|
1385
|
+
type="text"
|
|
1386
|
+
danger
|
|
1387
|
+
icon={<DeleteOutlined />}
|
|
1388
|
+
onClick={() => activeResponseId && handleResponseDelete(activeResponseId)}
|
|
1389
|
+
disabled={responses.length <= 1}
|
|
1347
1390
|
/>
|
|
1391
|
+
</Tooltip>
|
|
1392
|
+
</Col>
|
|
1393
|
+
</Row>
|
|
1394
|
+
</div>
|
|
1395
|
+
|
|
1396
|
+
{/* 响应配置区域 */}
|
|
1397
|
+
{activeResponseId && (() => {
|
|
1398
|
+
const activeResponse = responses.find(r => r.id === activeResponseId);
|
|
1399
|
+
const activeIndex = responses.findIndex(r => r.id === activeResponseId);
|
|
1400
|
+
|
|
1401
|
+
if (!activeResponse) return null;
|
|
1402
|
+
|
|
1403
|
+
return (
|
|
1404
|
+
<div style={{
|
|
1405
|
+
background: '#fafafa',
|
|
1406
|
+
borderRadius: '6px',
|
|
1407
|
+
padding: '16px',
|
|
1408
|
+
border: '1px solid #e8e8e8',
|
|
1409
|
+
marginBottom: '16px'
|
|
1410
|
+
}}>
|
|
1411
|
+
<div style={{
|
|
1412
|
+
display: 'flex',
|
|
1413
|
+
alignItems: 'center',
|
|
1414
|
+
gap: '8px',
|
|
1415
|
+
marginBottom: '16px',
|
|
1416
|
+
paddingBottom: '12px',
|
|
1417
|
+
borderBottom: '1px solid #e8e8e8'
|
|
1418
|
+
}}>
|
|
1419
|
+
<CodeOutlined style={{ color: '#1890ff' }} />
|
|
1420
|
+
<span style={{ fontWeight: 'bold', color: '#1890ff' }}>
|
|
1421
|
+
编辑响应:{activeResponse.name || `响应 ${activeIndex + 1}`}
|
|
1422
|
+
</span>
|
|
1423
|
+
</div>
|
|
1424
|
+
|
|
1425
|
+
<Row gutter={12}>
|
|
1426
|
+
<Col span={12}>
|
|
1427
|
+
<div style={{ marginBottom: '8px' }}>
|
|
1428
|
+
<label style={{
|
|
1429
|
+
fontSize: '12px',
|
|
1430
|
+
color: '#666',
|
|
1431
|
+
fontWeight: 'bold'
|
|
1432
|
+
}}>
|
|
1433
|
+
响应名称 *
|
|
1434
|
+
</label>
|
|
1435
|
+
</div>
|
|
1436
|
+
<Input
|
|
1437
|
+
placeholder="为响应取一个有意义的名称"
|
|
1438
|
+
value={activeResponse.name || ''}
|
|
1439
|
+
onChange={(e) => {
|
|
1440
|
+
const currentResponses = getFieldValue('responses') || [];
|
|
1441
|
+
const newResponses = currentResponses.map(resp =>
|
|
1442
|
+
resp.id === activeResponseId
|
|
1443
|
+
? { ...resp, name: e.target.value }
|
|
1444
|
+
: resp
|
|
1445
|
+
);
|
|
1446
|
+
setFieldsValue({ responses: newResponses });
|
|
1447
|
+
}}
|
|
1448
|
+
style={{ marginBottom: '12px' }}
|
|
1449
|
+
/>
|
|
1450
|
+
</Col>
|
|
1451
|
+
<Col span={12}>
|
|
1452
|
+
<div style={{ marginBottom: '8px' }}>
|
|
1453
|
+
<label style={{
|
|
1454
|
+
fontSize: '12px',
|
|
1455
|
+
color: '#666',
|
|
1456
|
+
fontWeight: 'bold'
|
|
1457
|
+
}}>
|
|
1458
|
+
内容统计
|
|
1459
|
+
</label>
|
|
1460
|
+
</div>
|
|
1461
|
+
<div style={{
|
|
1462
|
+
padding: '8px 12px',
|
|
1463
|
+
background: '#fff',
|
|
1464
|
+
border: '1px solid #d9d9d9',
|
|
1465
|
+
borderRadius: '4px',
|
|
1466
|
+
fontSize: '12px',
|
|
1467
|
+
color: '#666',
|
|
1468
|
+
marginBottom: '12px'
|
|
1469
|
+
}}>
|
|
1470
|
+
{activeResponse.content ?
|
|
1471
|
+
`${activeResponse.content.length} 字符 | ${new Blob([activeResponse.content]).size} 字节` :
|
|
1472
|
+
'内容为空'
|
|
1473
|
+
}
|
|
1474
|
+
</div>
|
|
1475
|
+
</Col>
|
|
1476
|
+
</Row>
|
|
1477
|
+
|
|
1478
|
+
<div style={{ marginBottom: '8px' }}>
|
|
1479
|
+
<label style={{
|
|
1480
|
+
fontSize: '12px',
|
|
1481
|
+
color: '#666',
|
|
1482
|
+
fontWeight: 'bold'
|
|
1483
|
+
}}>
|
|
1484
|
+
响应描述
|
|
1485
|
+
</label>
|
|
1348
1486
|
</div>
|
|
1349
1487
|
<Input.TextArea
|
|
1350
|
-
placeholder="
|
|
1351
|
-
value={
|
|
1488
|
+
placeholder="描述此响应的用途和场景(可选)"
|
|
1489
|
+
value={activeResponse.description || ''}
|
|
1352
1490
|
onChange={(e) => {
|
|
1353
|
-
console.log(`更新响应 ${item.id} 的描述:`, e.target.value);
|
|
1354
1491
|
const currentResponses = getFieldValue('responses') || [];
|
|
1355
1492
|
const newResponses = currentResponses.map(resp =>
|
|
1356
|
-
resp.id ===
|
|
1493
|
+
resp.id === activeResponseId
|
|
1357
1494
|
? { ...resp, description: e.target.value }
|
|
1358
1495
|
: resp
|
|
1359
1496
|
);
|
|
1360
|
-
console.log('新的响应列表:', newResponses);
|
|
1361
1497
|
setFieldsValue({ responses: newResponses });
|
|
1362
1498
|
}}
|
|
1363
|
-
style={{ marginBottom: 8 }}
|
|
1364
1499
|
rows={2}
|
|
1365
|
-
maxLength={
|
|
1500
|
+
maxLength={200}
|
|
1501
|
+
showCount
|
|
1502
|
+
style={{ marginBottom: '12px' }}
|
|
1366
1503
|
/>
|
|
1367
1504
|
</div>
|
|
1368
|
-
|
|
1369
|
-
)}
|
|
1370
|
-
|
|
1505
|
+
);
|
|
1506
|
+
})()}
|
|
1507
|
+
</div>
|
|
1371
1508
|
);
|
|
1372
1509
|
}}
|
|
1373
1510
|
</Form.Item>
|
|
1374
1511
|
</Card>
|
|
1375
|
-
|
|
1376
|
-
<Form.Item noStyle shouldUpdate>
|
|
1377
|
-
{({ getFieldValue, setFieldsValue }) => {
|
|
1378
|
-
let responses = getFieldValue('responses') || [];
|
|
1379
|
-
const activeResponseId = getFieldValue('activeResponseId');
|
|
1380
|
-
|
|
1381
|
-
// 确保是数组
|
|
1382
|
-
if (!Array.isArray(responses)) {
|
|
1383
|
-
console.warn('内容编辑器 - responses 不是数组类型:', responses);
|
|
1384
|
-
try {
|
|
1385
|
-
if (typeof responses === 'string') {
|
|
1386
|
-
responses = JSON.parse(responses);
|
|
1387
|
-
}
|
|
1388
|
-
} catch (e) {
|
|
1389
|
-
responses = [];
|
|
1390
|
-
}
|
|
1391
|
-
|
|
1392
|
-
if (!Array.isArray(responses)) {
|
|
1393
|
-
responses = [];
|
|
1394
|
-
}
|
|
1395
|
-
}
|
|
1396
|
-
|
|
1397
|
-
if (responses.length === 0) {
|
|
1398
|
-
console.warn('没有响应数据');
|
|
1399
|
-
}
|
|
1400
|
-
|
|
1401
|
-
// 查找激活的响应
|
|
1402
|
-
const activeResponseIndex = responses.findIndex(r => r.id === activeResponseId);
|
|
1403
|
-
const activeResponse = activeResponseIndex >= 0 ? responses[activeResponseIndex] : null;
|
|
1404
|
-
|
|
1405
|
-
console.log('当前激活的响应:', activeResponseId, activeResponse ? activeResponse.name : 'null');
|
|
1406
|
-
|
|
1407
|
-
// 更新当前激活的响应内容
|
|
1408
|
-
const updateActiveResponseContent = (content) => {
|
|
1409
|
-
if (activeResponseIndex >= 0) {
|
|
1410
|
-
const newResponses = [...responses];
|
|
1411
|
-
newResponses[activeResponseIndex] = {
|
|
1412
|
-
...newResponses[activeResponseIndex],
|
|
1413
|
-
content
|
|
1414
|
-
};
|
|
1415
|
-
setFieldsValue({ responses: newResponses });
|
|
1416
|
-
}
|
|
1417
|
-
};
|
|
1418
|
-
|
|
1419
|
-
return (
|
|
1420
|
-
<Form.Item
|
|
1421
|
-
label={
|
|
1422
|
-
<div style={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}>
|
|
1423
|
-
<span>
|
|
1424
|
-
响应内容
|
|
1425
|
-
{activeResponse && activeResponse.name && (
|
|
1426
|
-
<span style={{ marginLeft: 8, fontWeight: 'normal', fontSize: '12px', color: '#999' }}>
|
|
1427
|
-
({activeResponse.name})
|
|
1428
|
-
</span>
|
|
1429
|
-
)}
|
|
1430
|
-
</span>
|
|
1431
|
-
<Space>
|
|
1432
|
-
<Button
|
|
1433
|
-
type="link"
|
|
1434
|
-
icon={<EyeOutlined />}
|
|
1435
|
-
onClick={handlePreview}
|
|
1436
|
-
style={{ padding: 0 }}
|
|
1437
|
-
disabled={!activeResponse}
|
|
1438
|
-
>
|
|
1439
|
-
预览
|
|
1440
|
-
</Button>
|
|
1441
|
-
<Button
|
|
1442
|
-
type="link"
|
|
1443
|
-
icon={<FormatPainterOutlined />}
|
|
1444
|
-
onClick={formatJsonContent}
|
|
1445
|
-
style={{ padding: 0 }}
|
|
1446
|
-
disabled={!activeResponse}
|
|
1447
|
-
>
|
|
1448
|
-
格式化JSON
|
|
1449
|
-
</Button>
|
|
1450
|
-
</Space>
|
|
1451
|
-
</div>
|
|
1452
|
-
}
|
|
1453
|
-
>
|
|
1454
|
-
{activeResponse ? (
|
|
1455
|
-
<TextArea
|
|
1456
|
-
rows={12}
|
|
1457
|
-
placeholder="请输入响应内容"
|
|
1458
|
-
style={{ fontFamily: 'monospace' }}
|
|
1459
|
-
value={activeResponse.content || ''}
|
|
1460
|
-
onChange={(e) => updateActiveResponseContent(e.target.value)}
|
|
1461
|
-
/>
|
|
1462
|
-
) : (
|
|
1463
|
-
<Alert
|
|
1464
|
-
message="未选择响应"
|
|
1465
|
-
description="请选择或添加一个响应"
|
|
1466
|
-
type="warning"
|
|
1467
|
-
showIcon
|
|
1468
|
-
/>
|
|
1469
|
-
)}
|
|
1470
|
-
</Form.Item>
|
|
1471
|
-
);
|
|
1472
|
-
}}
|
|
1473
|
-
</Form.Item>
|
|
1474
1512
|
</>
|
|
1475
1513
|
);
|
|
1476
1514
|
}
|