whistle.mock-plugins 1.1.2 → 1.1.3-beta.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 CHANGED
@@ -1,8 +1,4 @@
1
1
  # 🔄 版本更新记录
2
- ## v1.1.2
3
- ### 🐛 Fix
4
- - **问题修复**: 接口管理禁用启用接口失效
5
-
6
2
  ## v1.1.1
7
3
  ### 🆕 更新功能
8
4
  - **项目优化**:版本号同步显示在页面右上角,支持点击查看详细更新记录
@@ -383,27 +383,9 @@ module.exports = function(req, res) {
383
383
 
384
384
  // 处理 PATCH 请求 - 部分更新接口(如启用/禁用状态)
385
385
  if (req.method === 'PATCH') {
386
- // 支持从路径中获取ID (RESTful风格) 或 从查询参数获取ID
387
- let id = req.query.id;
388
-
389
- // 检查路径,支持 /cgi-bin/interfaces/123 形式的请求
390
- const pathMatch = req.path.match(/\/interfaces\/([^\/]+)$/);
391
- if (pathMatch && pathMatch[1]) {
392
- id = pathMatch[1];
393
- }
394
-
395
- const { active } = req.query;
386
+ const { id, active } = req.query;
396
387
  const patchData = req.body;
397
388
 
398
- // 记录请求信息
399
- console.log('PATCH请求:', {
400
- path: req.path,
401
- pathMatch: pathMatch ? pathMatch[1] : null,
402
- id,
403
- active,
404
- body: patchData
405
- });
406
-
407
389
  // 读取接口数据
408
390
  let interfacesData;
409
391
  try {
@@ -420,8 +402,8 @@ module.exports = function(req, res) {
420
402
  });
421
403
  }
422
404
 
423
- // 批量更新接口状态 - 按分组和功能模块
424
- if (active !== undefined && !id && (patchData.featureId || patchData.group)) {
405
+ // 批量更新接口状态
406
+ if (active !== undefined) {
425
407
  const { featureId, group } = patchData;
426
408
 
427
409
  if (!featureId) {
@@ -432,12 +414,6 @@ module.exports = function(req, res) {
432
414
  });
433
415
  }
434
416
 
435
- console.log('批量更新接口状态:', {
436
- active,
437
- featureId,
438
- group
439
- });
440
-
441
417
  // 根据分组筛选要更新的接口
442
418
  let updatedCount = 0;
443
419
  interfacesData.interfaces = interfacesData.interfaces.map(item => {
@@ -481,9 +457,8 @@ module.exports = function(req, res) {
481
457
  });
482
458
  }
483
459
 
484
- // 处理单个接口状态更新或其他字段更新
460
+ // 单个接口更新
485
461
  if (!id) {
486
- console.error('单个接口更新错误: 缺少接口ID');
487
462
  return res.status(400).json({
488
463
  code: 400,
489
464
  message: '接口ID不能为空',
@@ -491,19 +466,13 @@ module.exports = function(req, res) {
491
466
  });
492
467
  }
493
468
 
494
- console.log('更新单个接口状态,ID:', id, '数据:', patchData);
495
-
496
469
  // 查找接口
497
470
  const index = interfacesData.interfaces.findIndex(item => item.id === id);
498
471
 
499
472
  if (index === -1) {
500
- console.error(`接口不存在,ID: ${id},当前共有 ${interfacesData.interfaces.length} 个接口`);
501
- if (interfacesData.interfaces.length > 0) {
502
- console.log('所有接口ID:', interfacesData.interfaces.map(i => i.id));
503
- }
504
473
  return res.status(404).json({
505
474
  code: 404,
506
- message: `接口不存在 (ID: ${id})`,
475
+ message: '接口不存在',
507
476
  data: null
508
477
  });
509
478
  }
@@ -515,12 +484,6 @@ module.exports = function(req, res) {
515
484
  updatedAt: new Date().toISOString()
516
485
  };
517
486
 
518
- console.log('接口更新成功,接口数据:', {
519
- id: updatedInterface.id,
520
- name: updatedInterface.name,
521
- active: updatedInterface.active
522
- });
523
-
524
487
  interfacesData.interfaces[index] = updatedInterface;
525
488
  fs.writeJsonSync(interfacesFile, interfacesData, { spaces: 2 });
526
489