whistle.mock-plugins 1.2.1 → 1.2.2-beta.3
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/COLUMN_RESIZE_IMPLEMENTATION.md +162 -0
- package/TEST_GUIDE.md +156 -0
- package/VERSION.md +13 -0
- package/app/public/js/index.js +1 -1
- package/package.json +2 -1
- package/ui/src/pages/InterfaceManagementV2.js +94 -4
- package/ui/src/styles/interface-management.css +37 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "whistle.mock-plugins",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2-beta.3",
|
|
4
4
|
"description": "Whistle 插件,用于快速创建 API 模拟数据",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"jest": "^29.7.0",
|
|
40
40
|
"react": "^18.2.0",
|
|
41
41
|
"react-dom": "^18.2.0",
|
|
42
|
+
"react-resizable": "^3.0.5",
|
|
42
43
|
"react-sortablejs": "^6.1.4",
|
|
43
44
|
"sortablejs": "^1.15.3",
|
|
44
45
|
"react-markdown": "^8.0.7",
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
FileTextOutlined, PlusCircleOutlined, SettingOutlined,
|
|
16
16
|
SearchOutlined, FilterOutlined, ReloadOutlined, DownOutlined, QuestionCircleOutlined, CopyOutlined
|
|
17
17
|
} from '@ant-design/icons';
|
|
18
|
+
// 移除 react-resizable,改用原生实现
|
|
18
19
|
import '../styles/interface-management.css';
|
|
19
20
|
import axios from 'axios';
|
|
20
21
|
|
|
@@ -97,13 +98,27 @@ const InterfaceManagement = () => {
|
|
|
97
98
|
const [tableConfig, setTableConfig] = useState(() => {
|
|
98
99
|
const cached = localStorage.getItem('interface-table-config');
|
|
99
100
|
const defaultVisibleColumns = COLUMN_CONFIG.map(col => col.key);
|
|
100
|
-
|
|
101
|
+
const defaultConfig = {
|
|
101
102
|
sortOrder: null,
|
|
102
103
|
sortField: null,
|
|
103
104
|
pageSize: 10,
|
|
104
105
|
current: 1,
|
|
105
|
-
visibleColumns: defaultVisibleColumns
|
|
106
|
+
visibleColumns: defaultVisibleColumns,
|
|
107
|
+
columnWidths: {
|
|
108
|
+
currentResponse: 180
|
|
109
|
+
}
|
|
106
110
|
};
|
|
111
|
+
|
|
112
|
+
if (cached) {
|
|
113
|
+
const parsedConfig = JSON.parse(cached);
|
|
114
|
+
// 确保 columnWidths 存在
|
|
115
|
+
if (!parsedConfig.columnWidths) {
|
|
116
|
+
parsedConfig.columnWidths = { currentResponse: 180 };
|
|
117
|
+
}
|
|
118
|
+
return parsedConfig;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return defaultConfig;
|
|
107
122
|
});
|
|
108
123
|
|
|
109
124
|
// 保存表格配置到localStorage
|
|
@@ -675,7 +690,12 @@ const InterfaceManagement = () => {
|
|
|
675
690
|
// 重置列配置
|
|
676
691
|
const handleResetColumns = () => {
|
|
677
692
|
const defaultColumns = COLUMN_CONFIG.map(col => col.key);
|
|
678
|
-
saveTableConfig({
|
|
693
|
+
saveTableConfig({
|
|
694
|
+
visibleColumns: defaultColumns,
|
|
695
|
+
columnWidths: {
|
|
696
|
+
currentResponse: 180
|
|
697
|
+
}
|
|
698
|
+
});
|
|
679
699
|
};
|
|
680
700
|
|
|
681
701
|
// 切换列配置面板显示
|
|
@@ -706,6 +726,61 @@ const InterfaceManagement = () => {
|
|
|
706
726
|
message.success('数据已刷新');
|
|
707
727
|
};
|
|
708
728
|
|
|
729
|
+
// 可调整大小的表头组件(使用原生实现)
|
|
730
|
+
const ResizableTitle = (props) => {
|
|
731
|
+
const { onResize, width, columnKey, ...restProps } = props;
|
|
732
|
+
|
|
733
|
+
if (!width || !onResize) {
|
|
734
|
+
return <th {...restProps} />;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
const handleMouseDown = (e) => {
|
|
738
|
+
e.preventDefault();
|
|
739
|
+
e.stopPropagation();
|
|
740
|
+
|
|
741
|
+
const startX = e.clientX;
|
|
742
|
+
const startWidth = width;
|
|
743
|
+
|
|
744
|
+
const handleMouseMove = (moveEvent) => {
|
|
745
|
+
const deltaX = moveEvent.clientX - startX;
|
|
746
|
+
const newWidth = Math.max(50, startWidth + deltaX); // 最小宽度 50px
|
|
747
|
+
onResize(columnKey, newWidth);
|
|
748
|
+
};
|
|
749
|
+
|
|
750
|
+
const handleMouseUp = () => {
|
|
751
|
+
document.removeEventListener('mousemove', handleMouseMove);
|
|
752
|
+
document.removeEventListener('mouseup', handleMouseUp);
|
|
753
|
+
document.body.style.cursor = '';
|
|
754
|
+
document.body.style.userSelect = '';
|
|
755
|
+
};
|
|
756
|
+
|
|
757
|
+
document.addEventListener('mousemove', handleMouseMove);
|
|
758
|
+
document.addEventListener('mouseup', handleMouseUp);
|
|
759
|
+
document.body.style.cursor = 'col-resize';
|
|
760
|
+
document.body.style.userSelect = 'none';
|
|
761
|
+
};
|
|
762
|
+
|
|
763
|
+
return (
|
|
764
|
+
<th {...restProps} style={{ ...restProps.style, position: 'relative' }}>
|
|
765
|
+
{restProps.children}
|
|
766
|
+
<span
|
|
767
|
+
className="column-resize-handle"
|
|
768
|
+
onMouseDown={handleMouseDown}
|
|
769
|
+
onClick={(e) => e.stopPropagation()}
|
|
770
|
+
/>
|
|
771
|
+
</th>
|
|
772
|
+
);
|
|
773
|
+
};
|
|
774
|
+
|
|
775
|
+
// 处理列宽调整
|
|
776
|
+
const handleResize = (columnKey, newWidth) => {
|
|
777
|
+
const newColumnWidths = {
|
|
778
|
+
...tableConfig.columnWidths,
|
|
779
|
+
[columnKey]: newWidth
|
|
780
|
+
};
|
|
781
|
+
saveTableConfig({ columnWidths: newColumnWidths });
|
|
782
|
+
};
|
|
783
|
+
|
|
709
784
|
// 批量操作接口状态
|
|
710
785
|
const handleBatchOperation = async (active) => {
|
|
711
786
|
if (!selectedRowKeys || selectedRowKeys.length === 0) {
|
|
@@ -803,7 +878,16 @@ const InterfaceManagement = () => {
|
|
|
803
878
|
title: '当前响应',
|
|
804
879
|
dataIndex: 'activeResponseId',
|
|
805
880
|
key: 'currentResponse',
|
|
806
|
-
width: 180,
|
|
881
|
+
width: tableConfig.columnWidths?.currentResponse || 180,
|
|
882
|
+
className: 'current-response-column',
|
|
883
|
+
onHeaderCell: (column) => ({
|
|
884
|
+
width: column.width,
|
|
885
|
+
columnKey: 'currentResponse',
|
|
886
|
+
onResize: handleResize,
|
|
887
|
+
}),
|
|
888
|
+
onCell: () => ({
|
|
889
|
+
className: 'current-response-cell',
|
|
890
|
+
}),
|
|
807
891
|
render: (activeResponseId, record) => {
|
|
808
892
|
// 如果没有响应数据,返回空
|
|
809
893
|
if (!record.responses || !Array.isArray(record.responses) || record.responses.length === 0) {
|
|
@@ -822,6 +906,7 @@ const InterfaceManagement = () => {
|
|
|
822
906
|
style={{ width: '100%' }}
|
|
823
907
|
onChange={(value) => handleResponseSwitch(record.id, value)}
|
|
824
908
|
disabled={record.proxyType !== 'response'}
|
|
909
|
+
getPopupContainer={(trigger) => trigger.parentNode}
|
|
825
910
|
>
|
|
826
911
|
{record.responses.map(resp => (
|
|
827
912
|
<Option key={resp.id} value={resp.id}>
|
|
@@ -1333,6 +1418,11 @@ const InterfaceManagement = () => {
|
|
|
1333
1418
|
selectedRowKeys,
|
|
1334
1419
|
onChange: onSelectChange,
|
|
1335
1420
|
}}
|
|
1421
|
+
components={{
|
|
1422
|
+
header: {
|
|
1423
|
+
cell: ResizableTitle,
|
|
1424
|
+
},
|
|
1425
|
+
}}
|
|
1336
1426
|
size="middle"
|
|
1337
1427
|
pagination={{
|
|
1338
1428
|
current: tableConfig.current,
|
|
@@ -298,6 +298,11 @@
|
|
|
298
298
|
text-overflow: ellipsis;
|
|
299
299
|
}
|
|
300
300
|
|
|
301
|
+
/* 当前响应列需要 overflow: visible 以显示完整的下拉菜单 */
|
|
302
|
+
.interface-table td.current-response-cell {
|
|
303
|
+
overflow: visible !important;
|
|
304
|
+
}
|
|
305
|
+
|
|
301
306
|
/* 卡片视图样式 */
|
|
302
307
|
.interface-card-view {
|
|
303
308
|
padding-bottom: 20px;
|
|
@@ -1283,3 +1288,35 @@
|
|
|
1283
1288
|
.interface-table .ant-pagination-options {
|
|
1284
1289
|
margin-right: 16px;
|
|
1285
1290
|
}
|
|
1291
|
+
|
|
1292
|
+
/* 可调整列宽样式 */
|
|
1293
|
+
.column-resize-handle {
|
|
1294
|
+
position: absolute;
|
|
1295
|
+
right: -5px;
|
|
1296
|
+
top: 0;
|
|
1297
|
+
bottom: 0;
|
|
1298
|
+
width: 10px;
|
|
1299
|
+
cursor: col-resize;
|
|
1300
|
+
z-index: 1;
|
|
1301
|
+
user-select: none;
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
.column-resize-handle:hover {
|
|
1305
|
+
background-color: rgba(24, 144, 255, 0.2);
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
.column-resize-handle::after {
|
|
1309
|
+
content: '';
|
|
1310
|
+
position: absolute;
|
|
1311
|
+
right: 4px;
|
|
1312
|
+
top: 50%;
|
|
1313
|
+
transform: translateY(-50%);
|
|
1314
|
+
width: 2px;
|
|
1315
|
+
height: 20px;
|
|
1316
|
+
background-color: #d9d9d9;
|
|
1317
|
+
transition: background-color 0.3s;
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
.column-resize-handle:hover::after {
|
|
1321
|
+
background-color: #1890ff;
|
|
1322
|
+
}
|