whistle.mock-plugins 1.1.1-dev.8 → 1.1.1
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/VERSION.md +14 -16
- package/app/cgi-bin/interfaces.js +70 -9
- package/app/public/js/index.js +1 -1
- package/app/public/js/index.js.LICENSE.txt +6 -0
- package/lib/routes/interfaces.js +171 -0
- package/package.json +1 -1
- package/ui/src/pages/InterfaceManagement.js +568 -84
- package/ui/src/styles/interface-management.css +292 -16
package/VERSION.md
CHANGED
|
@@ -1,26 +1,24 @@
|
|
|
1
1
|
# 🔄 版本更新记录
|
|
2
|
-
## v1.1.1
|
|
3
|
-
### Fix
|
|
4
|
-
- **问题修复**: 模块禁用中接口任然被模拟代理使用了
|
|
5
|
-
|
|
6
|
-
## v1.1.1-beta.6
|
|
2
|
+
## v1.1.1
|
|
7
3
|
### 🆕 更新功能
|
|
4
|
+
- **项目优化**:版本号同步显示在页面右上角,支持点击查看详细更新记录
|
|
5
|
+
- **项目优化**:新增模拟响应入参校验功能,提升数据准确性
|
|
6
|
+
- **项目优化**:接口管理列表支持快速切换多个模拟响应数据
|
|
7
|
+
- **项目优化**:清理并标记项目中未使用的文件,提升代码质量
|
|
8
8
|
- **项目优化**:`模拟响应`在 `res.header` 中添加响应信息,方便标识
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
- **接口管理**:接口管理列表支持快速切换多个模拟响应数据
|
|
15
|
-
- **接口管理**:前端页面支持多维度排序,提升数据管理效率
|
|
16
|
-
- **接口管理**: 列表支持设置外显列
|
|
17
|
-
- **接口管理**:模拟响应数据编辑框支持全屏模式,新增 ESC 快捷键快速关闭
|
|
9
|
+
- **项目优化**:支持接口延迟响应功能,添加和编辑的时候可以设置
|
|
10
|
+
- **项目优化**:接口管理支持分组功能
|
|
11
|
+
- **界面精简**:前端页面支持多维度排序,提升数据管理效率
|
|
12
|
+
- **界面精简**: 列表支持设置外显列
|
|
13
|
+
- **界面精简**:模拟响应数据编辑框支持全屏模式,新增 ESC 快捷键快速关闭
|
|
18
14
|
- **界面精简**:移除模拟数据编辑框右上角冗余的 JSON 标签
|
|
19
|
-
|
|
15
|
+
|
|
16
|
+
### 🐛 Fix
|
|
17
|
+
- **问题修复**: 模块禁用中接口任然被模拟代理使用了
|
|
20
18
|
|
|
21
19
|
|
|
22
20
|
## v1.1.0
|
|
23
|
-
### 更新功能
|
|
21
|
+
### 🆕 更新功能
|
|
24
22
|
- **多响应管理系统**:每个接口支持配置多个不同的响应内容
|
|
25
23
|
- **响应切换功能**:可在多个响应之间快速切换,便于测试不同场景
|
|
26
24
|
- **响应描述系统**:为每个响应添加名称和详细描述
|
|
@@ -183,6 +183,7 @@ module.exports = function(req, res) {
|
|
|
183
183
|
interfacesData.interfaces[index] = {
|
|
184
184
|
...interfacesData.interfaces[index],
|
|
185
185
|
name: interfaceData.name,
|
|
186
|
+
group: interfaceData.group !== undefined ? interfaceData.group : interfacesData.interfaces[index].group || '', // 添加分组字段
|
|
186
187
|
urlPattern: interfaceData.urlPattern,
|
|
187
188
|
proxyType: interfaceData.proxyType,
|
|
188
189
|
responseContent: interfaceData.responseContent,
|
|
@@ -217,6 +218,7 @@ module.exports = function(req, res) {
|
|
|
217
218
|
id: Date.now().toString(),
|
|
218
219
|
featureId: interfaceData.featureId,
|
|
219
220
|
name: interfaceData.name,
|
|
221
|
+
group: interfaceData.group || '', // 添加分组字段
|
|
220
222
|
urlPattern: interfaceData.urlPattern,
|
|
221
223
|
proxyType: interfaceData.proxyType || 'response',
|
|
222
224
|
responseContent: interfaceData.responseContent || '',
|
|
@@ -235,6 +237,7 @@ module.exports = function(req, res) {
|
|
|
235
237
|
|
|
236
238
|
console.log('创建新接口,包含多响应数据:', {
|
|
237
239
|
name: newInterface.name,
|
|
240
|
+
group: newInterface.group, // 添加分组日志
|
|
238
241
|
responsesCount: newInterface.responses.length,
|
|
239
242
|
activeResponseId: newInterface.activeResponseId
|
|
240
243
|
});
|
|
@@ -343,6 +346,7 @@ module.exports = function(req, res) {
|
|
|
343
346
|
const updatedInterface = {
|
|
344
347
|
...interfacesData.interfaces[index],
|
|
345
348
|
name: interfaceData.name || interfacesData.interfaces[index].name,
|
|
349
|
+
group: interfaceData.group !== undefined ? interfaceData.group : interfacesData.interfaces[index].group || '', // 添加分组字段
|
|
346
350
|
urlPattern: interfaceData.urlPattern || interfacesData.interfaces[index].urlPattern,
|
|
347
351
|
proxyType: interfaceData.proxyType || interfacesData.interfaces[index].proxyType,
|
|
348
352
|
responseContent: interfaceData.responseContent !== undefined ? interfaceData.responseContent : interfacesData.interfaces[index].responseContent,
|
|
@@ -362,6 +366,7 @@ module.exports = function(req, res) {
|
|
|
362
366
|
|
|
363
367
|
console.log('PUT更新接口,包含多响应数据:', {
|
|
364
368
|
name: updatedInterface.name,
|
|
369
|
+
group: updatedInterface.group, // 添加分组日志
|
|
365
370
|
responsesCount: updatedInterface.responses.length,
|
|
366
371
|
activeResponseId: updatedInterface.activeResponseId
|
|
367
372
|
});
|
|
@@ -378,17 +383,9 @@ module.exports = function(req, res) {
|
|
|
378
383
|
|
|
379
384
|
// 处理 PATCH 请求 - 部分更新接口(如启用/禁用状态)
|
|
380
385
|
if (req.method === 'PATCH') {
|
|
381
|
-
const { id } = req.query;
|
|
386
|
+
const { id, active } = req.query;
|
|
382
387
|
const patchData = req.body;
|
|
383
388
|
|
|
384
|
-
if (!id) {
|
|
385
|
-
return res.status(400).json({
|
|
386
|
-
code: 400,
|
|
387
|
-
message: '接口ID不能为空',
|
|
388
|
-
data: null
|
|
389
|
-
});
|
|
390
|
-
}
|
|
391
|
-
|
|
392
389
|
// 读取接口数据
|
|
393
390
|
let interfacesData;
|
|
394
391
|
try {
|
|
@@ -405,6 +402,70 @@ module.exports = function(req, res) {
|
|
|
405
402
|
});
|
|
406
403
|
}
|
|
407
404
|
|
|
405
|
+
// 批量更新接口状态
|
|
406
|
+
if (active !== undefined) {
|
|
407
|
+
const { featureId, group } = patchData;
|
|
408
|
+
|
|
409
|
+
if (!featureId) {
|
|
410
|
+
return res.status(400).json({
|
|
411
|
+
code: 400,
|
|
412
|
+
message: '功能ID不能为空',
|
|
413
|
+
data: null
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
// 根据分组筛选要更新的接口
|
|
418
|
+
let updatedCount = 0;
|
|
419
|
+
interfacesData.interfaces = interfacesData.interfaces.map(item => {
|
|
420
|
+
// 只更新指定功能模块下的接口
|
|
421
|
+
if (item.featureId !== featureId) {
|
|
422
|
+
return item;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// 如果指定了分组,只更新该分组下的接口
|
|
426
|
+
if (group && item.group !== group) {
|
|
427
|
+
return item;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
// 更新接口状态
|
|
431
|
+
const isActive = active === 'true';
|
|
432
|
+
if (item.active !== isActive) {
|
|
433
|
+
updatedCount++;
|
|
434
|
+
return {
|
|
435
|
+
...item,
|
|
436
|
+
active: isActive,
|
|
437
|
+
updatedAt: new Date().toISOString()
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
return item;
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
// 保存更新后的接口列表
|
|
445
|
+
fs.writeJsonSync(interfacesFile, interfacesData, { spaces: 2 });
|
|
446
|
+
|
|
447
|
+
console.log(`批量${active === 'true' ? '启用' : '禁用'}接口:`, {
|
|
448
|
+
featureId,
|
|
449
|
+
group,
|
|
450
|
+
updatedCount
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
return res.json({
|
|
454
|
+
code: 0,
|
|
455
|
+
message: `成功${active === 'true' ? '启用' : '禁用'} ${updatedCount} 个接口`,
|
|
456
|
+
data: { updatedCount }
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
// 单个接口更新
|
|
461
|
+
if (!id) {
|
|
462
|
+
return res.status(400).json({
|
|
463
|
+
code: 400,
|
|
464
|
+
message: '接口ID不能为空',
|
|
465
|
+
data: null
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
|
|
408
469
|
// 查找接口
|
|
409
470
|
const index = interfacesData.interfaces.findIndex(item => item.id === id);
|
|
410
471
|
|