whistle.mock-plugins 1.0.6-beta.13 → 1.0.6-beta.15
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,32 @@ const InterfaceManagement = () => {
|
|
|
1242
1242
|
|
|
1243
1243
|
{/* 响应管理 */}
|
|
1244
1244
|
<Card
|
|
1245
|
-
title=
|
|
1245
|
+
title={
|
|
1246
|
+
<Form.Item noStyle shouldUpdate>
|
|
1247
|
+
{({ getFieldValue }) => {
|
|
1248
|
+
const responses = getFieldValue('responses') || [];
|
|
1249
|
+
return (
|
|
1250
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
|
|
1251
|
+
<FileTextOutlined />
|
|
1252
|
+
<span>响应管理</span>
|
|
1253
|
+
<Badge count={Array.isArray(responses) ? responses.length : 0} style={{ backgroundColor: '#52c41a' }} />
|
|
1254
|
+
</div>
|
|
1255
|
+
);
|
|
1256
|
+
}}
|
|
1257
|
+
</Form.Item>
|
|
1258
|
+
}
|
|
1246
1259
|
extra={
|
|
1247
1260
|
<Button
|
|
1248
1261
|
type="primary"
|
|
1249
|
-
icon={<
|
|
1262
|
+
icon={<PlusCircleOutlined />}
|
|
1250
1263
|
onClick={handleAddResponse}
|
|
1264
|
+
size="small"
|
|
1251
1265
|
>
|
|
1252
1266
|
添加响应
|
|
1253
1267
|
</Button>
|
|
1254
1268
|
}
|
|
1255
1269
|
style={{ marginBottom: 16 }}
|
|
1270
|
+
bodyStyle={{ padding: '16px' }}
|
|
1256
1271
|
>
|
|
1257
1272
|
<Form.Item
|
|
1258
1273
|
name="responses"
|
|
@@ -1290,187 +1305,217 @@ const InterfaceManagement = () => {
|
|
|
1290
1305
|
|
|
1291
1306
|
const activeResponseId = getFieldValue('activeResponseId');
|
|
1292
1307
|
|
|
1308
|
+
if (responses.length === 0) {
|
|
1309
|
+
return (
|
|
1310
|
+
<div style={{
|
|
1311
|
+
textAlign: 'center',
|
|
1312
|
+
padding: '40px 20px',
|
|
1313
|
+
background: '#fafafa',
|
|
1314
|
+
borderRadius: '6px',
|
|
1315
|
+
border: '1px dashed #d9d9d9'
|
|
1316
|
+
}}>
|
|
1317
|
+
<FileAddOutlined style={{ fontSize: '32px', color: '#d9d9d9', marginBottom: '8px' }} />
|
|
1318
|
+
<div style={{ color: '#999', marginBottom: '16px' }}>暂无响应数据</div>
|
|
1319
|
+
<Button
|
|
1320
|
+
type="primary"
|
|
1321
|
+
icon={<PlusCircleOutlined />}
|
|
1322
|
+
onClick={handleAddResponse}
|
|
1323
|
+
>
|
|
1324
|
+
创建第一个响应
|
|
1325
|
+
</Button>
|
|
1326
|
+
</div>
|
|
1327
|
+
);
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1293
1330
|
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)}
|
|
1331
|
+
<div>
|
|
1332
|
+
{/* 响应选择器 */}
|
|
1333
|
+
<div style={{ marginBottom: '16px' }}>
|
|
1334
|
+
<Row gutter={12} align="middle">
|
|
1335
|
+
<Col flex="auto">
|
|
1336
|
+
<Select
|
|
1337
|
+
style={{ width: '100%' }}
|
|
1338
|
+
placeholder="选择要编辑的响应"
|
|
1339
|
+
value={activeResponseId}
|
|
1340
|
+
onChange={(value) => handleResponseSelect(value)}
|
|
1341
|
+
optionLabelProp="label"
|
|
1316
1342
|
>
|
|
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
|
-
|
|
1343
|
+
{responses.map((resp, index) => (
|
|
1344
|
+
<Option
|
|
1345
|
+
key={resp.id}
|
|
1346
|
+
value={resp.id}
|
|
1347
|
+
label={
|
|
1348
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
|
|
1349
|
+
<CheckCircleOutlined style={{ color: '#52c41a' }} />
|
|
1350
|
+
<span>{resp.name || `响应 ${index + 1}`}</span>
|
|
1351
|
+
</div>
|
|
1352
|
+
}
|
|
1353
|
+
>
|
|
1354
|
+
<div style={{ padding: '4px 0' }}>
|
|
1355
|
+
<div style={{
|
|
1356
|
+
display: 'flex',
|
|
1357
|
+
alignItems: 'center',
|
|
1358
|
+
justifyContent: 'space-between',
|
|
1359
|
+
marginBottom: '4px'
|
|
1360
|
+
}}>
|
|
1361
|
+
<span style={{ fontWeight: 'bold' }}>
|
|
1362
|
+
{resp.name || `响应 ${index + 1}`}
|
|
1363
|
+
</span>
|
|
1364
|
+
{resp.id === activeResponseId && (
|
|
1365
|
+
<Badge status="processing" text="当前选中" />
|
|
1366
|
+
)}
|
|
1367
|
+
</div>
|
|
1368
|
+
{resp.description && (
|
|
1369
|
+
<div style={{
|
|
1370
|
+
color: '#666',
|
|
1371
|
+
fontSize: '12px',
|
|
1372
|
+
marginBottom: '4px'
|
|
1373
|
+
}}>
|
|
1374
|
+
{resp.description}
|
|
1375
|
+
</div>
|
|
1376
|
+
)}
|
|
1377
|
+
<div style={{
|
|
1378
|
+
color: '#999',
|
|
1379
|
+
fontSize: '11px',
|
|
1380
|
+
fontFamily: 'monospace'
|
|
1381
|
+
}}>
|
|
1382
|
+
{resp.content ? `${resp.content.length} 字符` : '空内容'}
|
|
1383
|
+
</div>
|
|
1384
|
+
</div>
|
|
1385
|
+
</Option>
|
|
1386
|
+
))}
|
|
1387
|
+
</Select>
|
|
1388
|
+
</Col>
|
|
1389
|
+
<Col>
|
|
1390
|
+
<Tooltip title="删除当前响应">
|
|
1391
|
+
<Button
|
|
1392
|
+
type="text"
|
|
1393
|
+
danger
|
|
1394
|
+
icon={<DeleteOutlined />}
|
|
1395
|
+
onClick={() => activeResponseId && handleResponseDelete(activeResponseId)}
|
|
1396
|
+
disabled={responses.length <= 1}
|
|
1347
1397
|
/>
|
|
1398
|
+
</Tooltip>
|
|
1399
|
+
</Col>
|
|
1400
|
+
</Row>
|
|
1401
|
+
</div>
|
|
1402
|
+
|
|
1403
|
+
{/* 响应配置区域 */}
|
|
1404
|
+
{activeResponseId && (() => {
|
|
1405
|
+
const activeResponse = responses.find(r => r.id === activeResponseId);
|
|
1406
|
+
const activeIndex = responses.findIndex(r => r.id === activeResponseId);
|
|
1407
|
+
|
|
1408
|
+
if (!activeResponse) return null;
|
|
1409
|
+
|
|
1410
|
+
return (
|
|
1411
|
+
<div style={{
|
|
1412
|
+
background: '#fafafa',
|
|
1413
|
+
borderRadius: '6px',
|
|
1414
|
+
padding: '16px',
|
|
1415
|
+
border: '1px solid #e8e8e8',
|
|
1416
|
+
marginBottom: '16px'
|
|
1417
|
+
}}>
|
|
1418
|
+
<div style={{
|
|
1419
|
+
display: 'flex',
|
|
1420
|
+
alignItems: 'center',
|
|
1421
|
+
gap: '8px',
|
|
1422
|
+
marginBottom: '16px',
|
|
1423
|
+
paddingBottom: '12px',
|
|
1424
|
+
borderBottom: '1px solid #e8e8e8'
|
|
1425
|
+
}}>
|
|
1426
|
+
<CodeOutlined style={{ color: '#1890ff' }} />
|
|
1427
|
+
<span style={{ fontWeight: 'bold', color: '#1890ff' }}>
|
|
1428
|
+
编辑响应:{activeResponse.name || `响应 ${activeIndex + 1}`}
|
|
1429
|
+
</span>
|
|
1430
|
+
</div>
|
|
1431
|
+
|
|
1432
|
+
<Row gutter={12}>
|
|
1433
|
+
<Col span={12}>
|
|
1434
|
+
<div style={{ marginBottom: '8px' }}>
|
|
1435
|
+
<label style={{
|
|
1436
|
+
fontSize: '12px',
|
|
1437
|
+
color: '#666',
|
|
1438
|
+
fontWeight: 'bold'
|
|
1439
|
+
}}>
|
|
1440
|
+
响应名称 *
|
|
1441
|
+
</label>
|
|
1442
|
+
</div>
|
|
1443
|
+
<Input
|
|
1444
|
+
placeholder="为响应取一个有意义的名称"
|
|
1445
|
+
value={activeResponse.name || ''}
|
|
1446
|
+
onChange={(e) => {
|
|
1447
|
+
const currentResponses = getFieldValue('responses') || [];
|
|
1448
|
+
const newResponses = currentResponses.map(resp =>
|
|
1449
|
+
resp.id === activeResponseId
|
|
1450
|
+
? { ...resp, name: e.target.value }
|
|
1451
|
+
: resp
|
|
1452
|
+
);
|
|
1453
|
+
setFieldsValue({ responses: newResponses });
|
|
1454
|
+
}}
|
|
1455
|
+
style={{ marginBottom: '12px' }}
|
|
1456
|
+
/>
|
|
1457
|
+
</Col>
|
|
1458
|
+
<Col span={12}>
|
|
1459
|
+
<div style={{ marginBottom: '8px' }}>
|
|
1460
|
+
<label style={{
|
|
1461
|
+
fontSize: '12px',
|
|
1462
|
+
color: '#666',
|
|
1463
|
+
fontWeight: 'bold'
|
|
1464
|
+
}}>
|
|
1465
|
+
内容统计
|
|
1466
|
+
</label>
|
|
1467
|
+
</div>
|
|
1468
|
+
<div style={{
|
|
1469
|
+
padding: '8px 12px',
|
|
1470
|
+
background: '#fff',
|
|
1471
|
+
border: '1px solid #d9d9d9',
|
|
1472
|
+
borderRadius: '4px',
|
|
1473
|
+
fontSize: '12px',
|
|
1474
|
+
color: '#666',
|
|
1475
|
+
marginBottom: '12px'
|
|
1476
|
+
}}>
|
|
1477
|
+
{activeResponse.content ?
|
|
1478
|
+
`${activeResponse.content.length} 字符 | ${new Blob([activeResponse.content]).size} 字节` :
|
|
1479
|
+
'内容为空'
|
|
1480
|
+
}
|
|
1481
|
+
</div>
|
|
1482
|
+
</Col>
|
|
1483
|
+
</Row>
|
|
1484
|
+
|
|
1485
|
+
<div style={{ marginBottom: '8px' }}>
|
|
1486
|
+
<label style={{
|
|
1487
|
+
fontSize: '12px',
|
|
1488
|
+
color: '#666',
|
|
1489
|
+
fontWeight: 'bold'
|
|
1490
|
+
}}>
|
|
1491
|
+
响应描述
|
|
1492
|
+
</label>
|
|
1348
1493
|
</div>
|
|
1349
1494
|
<Input.TextArea
|
|
1350
|
-
placeholder="
|
|
1351
|
-
value={
|
|
1495
|
+
placeholder="描述此响应的用途和场景(可选)"
|
|
1496
|
+
value={activeResponse.description || ''}
|
|
1352
1497
|
onChange={(e) => {
|
|
1353
|
-
console.log(`更新响应 ${item.id} 的描述:`, e.target.value);
|
|
1354
1498
|
const currentResponses = getFieldValue('responses') || [];
|
|
1355
1499
|
const newResponses = currentResponses.map(resp =>
|
|
1356
|
-
resp.id ===
|
|
1500
|
+
resp.id === activeResponseId
|
|
1357
1501
|
? { ...resp, description: e.target.value }
|
|
1358
1502
|
: resp
|
|
1359
1503
|
);
|
|
1360
|
-
console.log('新的响应列表:', newResponses);
|
|
1361
1504
|
setFieldsValue({ responses: newResponses });
|
|
1362
1505
|
}}
|
|
1363
|
-
style={{ marginBottom: 8 }}
|
|
1364
1506
|
rows={2}
|
|
1365
|
-
maxLength={
|
|
1507
|
+
maxLength={200}
|
|
1508
|
+
showCount
|
|
1509
|
+
style={{ marginBottom: '12px' }}
|
|
1366
1510
|
/>
|
|
1367
1511
|
</div>
|
|
1368
|
-
|
|
1369
|
-
)}
|
|
1370
|
-
|
|
1512
|
+
);
|
|
1513
|
+
})()}
|
|
1514
|
+
</div>
|
|
1371
1515
|
);
|
|
1372
1516
|
}}
|
|
1373
1517
|
</Form.Item>
|
|
1374
1518
|
</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
1519
|
</>
|
|
1475
1520
|
);
|
|
1476
1521
|
}
|