whistle.mock-plugins 1.2.2-beta.22 → 1.2.2-beta.23

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,6 +1,6 @@
1
1
  {
2
2
  "name": "whistle.mock-plugins",
3
- "version": "1.2.2-beta.22",
3
+ "version": "1.2.2-beta.23",
4
4
  "description": "Whistle 插件,用于快速创建 API 模拟数据",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -1,10 +1,11 @@
1
1
  import React, { useState, useEffect } from 'react';
2
2
  import AppLayout from '../components/AppLayout';
3
- import { Card, Typography, Switch, Space, Divider } from 'antd';
3
+ import { Card, Typography, Switch, Space, Modal, Button } from 'antd';
4
+ import { QuestionCircleOutlined } from '@ant-design/icons';
4
5
  import axios from 'axios';
5
6
  import '../styles/settings.css';
6
7
 
7
- const { Title, Text, Paragraph } = Typography;
8
+ const { Text } = Typography;
8
9
 
9
10
  const syncSettingsToBackend = (patch) => {
10
11
  axios.put('/cgi-bin/settings', patch).catch(() => {});
@@ -68,6 +69,55 @@ const Settings = () => {
68
69
  window.dispatchEvent(new Event('storage'));
69
70
  };
70
71
 
72
+ const showMatcherRuleModal = (type) => {
73
+ if (type === 'interface') {
74
+ Modal.info({
75
+ title: '接口入参匹配规则说明',
76
+ width: 560,
77
+ content: (
78
+ <div>
79
+ <p>用于区分同一 URL 下的不同接口定义(接口级匹配)。</p>
80
+ <p>执行顺序与优先级:</p>
81
+ <ul>
82
+ <li>先进行 URL 匹配,命中多个接口时,按接口匹配条件顺序查找第一条命中规则。</li>
83
+ <li>若命中规则且配置了目标响应,则直接返回该响应(最高优先级)。</li>
84
+ <li>若命中规则但未配置目标响应,则进入“响应入参匹配”阶段继续判断。</li>
85
+ <li>若本开关关闭,则跳过接口级匹配,直接走“响应入参匹配”(若开启)。</li>
86
+ </ul>
87
+ <p>兜底逻辑:</p>
88
+ <ul>
89
+ <li>若最终没有任何入参规则命中,系统返回默认响应。</li>
90
+ <li>支持嵌套参数路径,例如:data.user.id。</li>
91
+ </ul>
92
+ </div>
93
+ )
94
+ });
95
+ return;
96
+ }
97
+
98
+ Modal.info({
99
+ title: '响应入参匹配规则说明',
100
+ width: 560,
101
+ content: (
102
+ <div>
103
+ <p>用于在同一接口内,根据请求参数选择具体响应(响应级匹配)。</p>
104
+ <p>执行顺序与优先级:</p>
105
+ <ul>
106
+ <li>仅在“接口入参匹配”未直接确定目标响应时才会执行。</li>
107
+ <li>按响应配置顺序匹配,命中第一条规则即返回对应响应。</li>
108
+ <li>支持精确匹配、包含匹配、正则匹配。</li>
109
+ <li>若本开关关闭,则跳过响应级匹配,直接使用默认响应。</li>
110
+ </ul>
111
+ <p>兜底逻辑:</p>
112
+ <ul>
113
+ <li>开启但未命中任一规则时,使用默认响应。</li>
114
+ <li>与接口级都关闭时,请求将直接返回默认响应。</li>
115
+ </ul>
116
+ </div>
117
+ )
118
+ });
119
+ };
120
+
71
121
  return (
72
122
  <AppLayout>
73
123
  <div className="page-container">
@@ -124,7 +174,16 @@ const Settings = () => {
124
174
  <div className="settings-item">
125
175
  <div className="settings-item-header">
126
176
  <div>
127
- <div className="settings-item-title">接口入参匹配</div>
177
+ <div className="settings-item-title">
178
+ 接口入参匹配
179
+ <Button
180
+ type="text"
181
+ size="small"
182
+ className="settings-help-icon"
183
+ icon={<QuestionCircleOutlined />}
184
+ onClick={() => showMatcherRuleModal('interface')}
185
+ />
186
+ </div>
128
187
  <div className="settings-item-description">
129
188
  是否在接口编辑表单中显示「接口匹配条件」配置区域
130
189
  </div>
@@ -144,7 +203,16 @@ const Settings = () => {
144
203
  <div className="settings-item">
145
204
  <div className="settings-item-header">
146
205
  <div>
147
- <div className="settings-item-title">响应入参匹配</div>
206
+ <div className="settings-item-title">
207
+ 响应入参匹配
208
+ <Button
209
+ type="text"
210
+ size="small"
211
+ className="settings-help-icon"
212
+ icon={<QuestionCircleOutlined />}
213
+ onClick={() => showMatcherRuleModal('response')}
214
+ />
215
+ </div>
148
216
  <div className="settings-item-description">
149
217
  是否在响应内容编辑器中显示「入参匹配规则」配置区域
150
218
  </div>
@@ -166,4 +234,4 @@ const Settings = () => {
166
234
  );
167
235
  };
168
236
 
169
- export default Settings;
237
+ export default Settings;
@@ -54,6 +54,9 @@
54
54
  font-weight: 500;
55
55
  color: #262626;
56
56
  margin-bottom: 4px;
57
+ display: inline-flex;
58
+ align-items: center;
59
+ gap: 2px;
57
60
  }
58
61
 
59
62
  .settings-item-description {
@@ -62,6 +65,18 @@
62
65
  line-height: 1.5;
63
66
  }
64
67
 
68
+ .settings-help-icon {
69
+ color: #8c8c8c;
70
+ padding: 0;
71
+ min-width: auto;
72
+ height: auto;
73
+ line-height: 1;
74
+ }
75
+
76
+ .settings-help-icon:hover {
77
+ color: #1677ff;
78
+ }
79
+
65
80
  .settings-section {
66
81
  margin-bottom: 32px;
67
82
  }
@@ -234,4 +249,4 @@ input:checked + .slider:before {
234
249
  width: 100%;
235
250
  margin-bottom: 8px;
236
251
  }
237
- }
252
+ }