whistle.mock-plugins 1.0.6 → 1.1.0
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/app/cgi-bin/interfaces.js +35 -0
- package/app/cgi-bin/test-interface.js +260 -262
- package/app/public/js/index.js +1 -1
- package/app/public/js/index.js.LICENSE.txt +8 -2
- package/lib/models.js +12 -1
- package/lib/routes/interfaces.js +274 -56
- package/lib/ruleManager.js +41 -2
- package/lib/rules-server.js +246 -139
- package/package.json +1 -1
- package/ui/src/components/interface-management/InterfaceTestModal.js +313 -0
- package/ui/src/components/interface-management/PreviewModal.js +50 -0
- package/ui/src/components/interface-management/README.md +184 -0
- package/ui/src/components/interface-management/ResponseContentEditor.js +427 -0
- package/ui/src/components/interface-management/constants.js +36 -0
- package/ui/src/components/interface-management/index.js +6 -0
- package/ui/src/components/interface-management/utils.js +103 -0
- package/ui/src/pages/InterfaceManagement.js +360 -653
- package/ui/src/pages/MockData.js +32 -0
package/ui/src/pages/MockData.js
CHANGED
|
@@ -4,10 +4,22 @@ import AppLayout from '../components/AppLayout';
|
|
|
4
4
|
import { Card, Row, Col, Button, Modal, Form, Input, message, Switch, Empty, Spin, Typography, Tooltip, Badge } from 'antd';
|
|
5
5
|
import { PlusOutlined, EditOutlined, DeleteOutlined, ApiOutlined, ExportOutlined, InfoCircleOutlined, CalendarOutlined } from '@ant-design/icons';
|
|
6
6
|
import '../styles/mock-data.css';
|
|
7
|
+
import axios from 'axios';
|
|
7
8
|
|
|
8
9
|
const { Text, Title, Paragraph } = Typography;
|
|
9
10
|
const { TextArea } = Input;
|
|
10
11
|
|
|
12
|
+
// 刷新缓存服务
|
|
13
|
+
const flushCache = async () => {
|
|
14
|
+
try {
|
|
15
|
+
const response = await axios.get(`/_flush_cache`);
|
|
16
|
+
return response.data;
|
|
17
|
+
} catch (error) {
|
|
18
|
+
console.error('刷新缓存失败:', error);
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
11
23
|
const MockData = () => {
|
|
12
24
|
const history = useHistory();
|
|
13
25
|
const [mockFeatures, setMockFeatures] = useState([]);
|
|
@@ -69,6 +81,17 @@ const MockData = () => {
|
|
|
69
81
|
setShowModal(false);
|
|
70
82
|
};
|
|
71
83
|
|
|
84
|
+
// 更新成功后刷新缓存
|
|
85
|
+
const refreshCacheAfterUpdate = async () => {
|
|
86
|
+
try {
|
|
87
|
+
await flushCache();
|
|
88
|
+
// 不显示提示,避免干扰主操作的反馈
|
|
89
|
+
} catch (error) {
|
|
90
|
+
// 记录错误但不影响用户体验
|
|
91
|
+
console.error('刷新缓存失败,可能需要等待缓存自动过期:', error);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
72
95
|
const handleSubmit = async (values) => {
|
|
73
96
|
try {
|
|
74
97
|
const featureData = {
|
|
@@ -96,6 +119,9 @@ const MockData = () => {
|
|
|
96
119
|
message.success(currentFeature ? '功能模块更新成功' : '功能模块创建成功');
|
|
97
120
|
fetchFeatures();
|
|
98
121
|
closeModal();
|
|
122
|
+
|
|
123
|
+
// 刷新缓存
|
|
124
|
+
refreshCacheAfterUpdate();
|
|
99
125
|
} else {
|
|
100
126
|
message.error('操作失败: ' + result.message);
|
|
101
127
|
}
|
|
@@ -127,6 +153,9 @@ const MockData = () => {
|
|
|
127
153
|
setMockFeatures(mockFeatures.map(feature =>
|
|
128
154
|
feature.id === id ? { ...feature, active: !currentActive } : feature
|
|
129
155
|
));
|
|
156
|
+
|
|
157
|
+
// 刷新缓存 - 功能启用状态变化是最关键的需要刷新缓存的操作
|
|
158
|
+
refreshCacheAfterUpdate();
|
|
130
159
|
} else {
|
|
131
160
|
message.error(`${currentActive ? '禁用' : '启用'}功能模块失败: ${result.message}`);
|
|
132
161
|
}
|
|
@@ -156,6 +185,9 @@ const MockData = () => {
|
|
|
156
185
|
message.success('功能模块已成功删除');
|
|
157
186
|
// 更新本地状态
|
|
158
187
|
setMockFeatures(mockFeatures.filter(f => f.id !== id));
|
|
188
|
+
|
|
189
|
+
// 刷新缓存
|
|
190
|
+
refreshCacheAfterUpdate();
|
|
159
191
|
} else {
|
|
160
192
|
message.error('删除失败: ' + result.message);
|
|
161
193
|
}
|