whistle.mock-plugins 1.0.6-beta.20 → 1.0.6-beta.21
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/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Card, Button, Space, Badge, Row, Col, Input, Select, Tooltip, message } from 'antd';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Card, Button, Space, Badge, Row, Col, Input, Select, Tooltip, message, AutoComplete } from 'antd';
|
|
3
3
|
import {
|
|
4
4
|
CodeOutlined,
|
|
5
5
|
EyeOutlined,
|
|
@@ -7,7 +7,8 @@ import {
|
|
|
7
7
|
FileTextOutlined,
|
|
8
8
|
PlusCircleOutlined,
|
|
9
9
|
DeleteOutlined,
|
|
10
|
-
CheckCircleOutlined
|
|
10
|
+
CheckCircleOutlined,
|
|
11
|
+
EditOutlined
|
|
11
12
|
} from '@ant-design/icons';
|
|
12
13
|
import { generateResponseId } from './utils';
|
|
13
14
|
|
|
@@ -21,6 +22,8 @@ const ResponseContentEditor = ({
|
|
|
21
22
|
onPreview
|
|
22
23
|
}) => {
|
|
23
24
|
const { getFieldValue, setFieldsValue } = form;
|
|
25
|
+
const [isEditing, setIsEditing] = useState(false);
|
|
26
|
+
const [editingName, setEditingName] = useState('');
|
|
24
27
|
|
|
25
28
|
// 查找激活的响应
|
|
26
29
|
const activeResponseIndex = responses.findIndex(r => r.id === activeResponseId);
|
|
@@ -88,15 +91,34 @@ const ResponseContentEditor = ({
|
|
|
88
91
|
// 切换响应
|
|
89
92
|
const handleResponseSelect = (responseId) => {
|
|
90
93
|
setFieldsValue({ activeResponseId: responseId });
|
|
94
|
+
setIsEditing(false);
|
|
91
95
|
};
|
|
92
96
|
|
|
93
|
-
//
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
// 开始编辑响应名称
|
|
98
|
+
const handleStartEdit = () => {
|
|
99
|
+
if (activeResponse) {
|
|
100
|
+
setEditingName(activeResponse.name || '');
|
|
101
|
+
setIsEditing(true);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// 完成编辑响应名称
|
|
106
|
+
const handleFinishEdit = () => {
|
|
107
|
+
if (activeResponseId && editingName.trim()) {
|
|
108
|
+
const currentResponses = getFieldValue('responses') || [];
|
|
109
|
+
const updatedResponses = currentResponses.map(resp =>
|
|
110
|
+
resp.id === activeResponseId ? { ...resp, name: editingName.trim() } : resp
|
|
111
|
+
);
|
|
112
|
+
setFieldsValue({ responses: updatedResponses });
|
|
113
|
+
}
|
|
114
|
+
setIsEditing(false);
|
|
115
|
+
setEditingName('');
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// 取消编辑
|
|
119
|
+
const handleCancelEdit = () => {
|
|
120
|
+
setIsEditing(false);
|
|
121
|
+
setEditingName('');
|
|
100
122
|
};
|
|
101
123
|
|
|
102
124
|
// 更新响应内容
|
|
@@ -219,73 +241,95 @@ const ResponseContentEditor = ({
|
|
|
219
241
|
style={{ marginBottom: 16 }}
|
|
220
242
|
bodyStyle={{ padding: '16px' }}
|
|
221
243
|
>
|
|
222
|
-
{/*
|
|
244
|
+
{/* 响应选择和名称编辑合并区域 */}
|
|
223
245
|
<div style={{ marginBottom: '16px' }}>
|
|
224
246
|
<Row gutter={12} align="middle">
|
|
225
|
-
<Col span={
|
|
247
|
+
<Col span={20}>
|
|
226
248
|
<div style={{ marginBottom: '8px' }}>
|
|
227
249
|
<label style={{
|
|
228
250
|
fontSize: '12px',
|
|
229
251
|
color: '#666',
|
|
230
252
|
fontWeight: 'bold'
|
|
231
253
|
}}>
|
|
232
|
-
选择响应
|
|
254
|
+
选择响应 / 编辑名称
|
|
233
255
|
</label>
|
|
234
256
|
</div>
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
257
|
+
|
|
258
|
+
<div style={{ position: 'relative' }}>
|
|
259
|
+
{isEditing ? (
|
|
260
|
+
// 编辑模式:显示输入框
|
|
261
|
+
<Input.Group compact>
|
|
262
|
+
<Input
|
|
263
|
+
style={{ width: 'calc(100% - 80px)' }}
|
|
264
|
+
value={editingName}
|
|
265
|
+
onChange={(e) => setEditingName(e.target.value)}
|
|
266
|
+
onPressEnter={handleFinishEdit}
|
|
267
|
+
onBlur={handleFinishEdit}
|
|
268
|
+
placeholder="输入响应名称"
|
|
269
|
+
autoFocus
|
|
270
|
+
/>
|
|
271
|
+
<Button
|
|
272
|
+
style={{ width: '40px' }}
|
|
273
|
+
type="primary"
|
|
274
|
+
icon={<CheckCircleOutlined />}
|
|
275
|
+
onClick={handleFinishEdit}
|
|
276
|
+
/>
|
|
277
|
+
<Button
|
|
278
|
+
style={{ width: '40px' }}
|
|
279
|
+
icon={<DeleteOutlined />}
|
|
280
|
+
onClick={handleCancelEdit}
|
|
281
|
+
/>
|
|
282
|
+
</Input.Group>
|
|
283
|
+
) : (
|
|
284
|
+
// 选择模式:显示下拉选择器
|
|
285
|
+
<Input.Group compact>
|
|
286
|
+
<Select
|
|
287
|
+
style={{ width: 'calc(100% - 40px)' }}
|
|
288
|
+
placeholder="选择要编辑的响应"
|
|
289
|
+
value={activeResponseId}
|
|
290
|
+
onChange={handleResponseSelect}
|
|
291
|
+
optionLabelProp="label"
|
|
292
|
+
>
|
|
293
|
+
{responses.map((resp, index) => (
|
|
294
|
+
<Option
|
|
295
|
+
key={resp.id}
|
|
296
|
+
value={resp.id}
|
|
297
|
+
label={
|
|
298
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
|
|
299
|
+
<CheckCircleOutlined style={{ color: '#52c41a' }} />
|
|
300
|
+
<span>{resp.name || `响应 ${index + 1}`}</span>
|
|
301
|
+
</div>
|
|
302
|
+
}
|
|
303
|
+
>
|
|
304
|
+
<div style={{ padding: '4px 0' }}>
|
|
305
|
+
<div style={{
|
|
306
|
+
display: 'flex',
|
|
307
|
+
alignItems: 'center',
|
|
308
|
+
justifyContent: 'space-between',
|
|
309
|
+
marginBottom: '4px'
|
|
310
|
+
}}>
|
|
311
|
+
<span style={{ fontWeight: 'bold' }}>
|
|
312
|
+
{resp.name || `响应 ${index + 1}`}
|
|
313
|
+
</span>
|
|
314
|
+
{resp.id === activeResponseId && (
|
|
315
|
+
<Badge status="processing" text="当前选中" />
|
|
316
|
+
)}
|
|
317
|
+
</div>
|
|
318
|
+
</div>
|
|
319
|
+
</Option>
|
|
320
|
+
))}
|
|
321
|
+
</Select>
|
|
322
|
+
<Tooltip title="编辑响应名称">
|
|
323
|
+
<Button
|
|
324
|
+
style={{ width: '40px' }}
|
|
325
|
+
icon={<EditOutlined />}
|
|
326
|
+
onClick={handleStartEdit}
|
|
327
|
+
disabled={!activeResponse}
|
|
328
|
+
/>
|
|
329
|
+
</Tooltip>
|
|
330
|
+
</Input.Group>
|
|
331
|
+
)}
|
|
282
332
|
</div>
|
|
283
|
-
<Input
|
|
284
|
-
placeholder="响应名称"
|
|
285
|
-
value={activeResponse?.name || ''}
|
|
286
|
-
onChange={(e) => activeResponseId && handleNameChange(activeResponseId, e.target.value)}
|
|
287
|
-
disabled={!activeResponse}
|
|
288
|
-
/>
|
|
289
333
|
</Col>
|
|
290
334
|
|
|
291
335
|
<Col span={4}>
|