seeder-st2110-components 1.6.1 → 1.6.2
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/dist/index.css +1 -1
- package/dist/index.esm.js +144 -70
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +144 -70
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/styles/index.less +10 -0
package/dist/index.js
CHANGED
|
@@ -1088,16 +1088,13 @@ const NetworkSettingsModal = _ref2 => {
|
|
|
1088
1088
|
const allSucceeded = results.every(result => result.status === 'fulfilled');
|
|
1089
1089
|
if (allSucceeded) {
|
|
1090
1090
|
handleSuccess();
|
|
1091
|
-
} else {
|
|
1092
|
-
message.error('Some configurations failed to update');
|
|
1093
1091
|
}
|
|
1094
1092
|
} catch (error) {
|
|
1095
1093
|
console.error('Failed to update configurations: ', error);
|
|
1096
|
-
message.error('Failed to update configurations');
|
|
1097
1094
|
} finally {
|
|
1098
1095
|
setSubmitLoading(false);
|
|
1099
1096
|
}
|
|
1100
|
-
}, [form, sections, lanConfigs, st2110Interfaces, updateLanConfig, updateSysConfig, handleSuccess
|
|
1097
|
+
}, [form, sections, lanConfigs, st2110Interfaces, updateLanConfig, updateSysConfig, handleSuccess]);
|
|
1101
1098
|
|
|
1102
1099
|
// 合并默认模态框属性和传入的属性
|
|
1103
1100
|
const mergedModalProps = _objectSpread2({
|
|
@@ -1409,7 +1406,7 @@ const LeftList = /*#__PURE__*/React.memo(_ref => {
|
|
|
1409
1406
|
showDescription = false,
|
|
1410
1407
|
texts = {
|
|
1411
1408
|
newButton: "New Preset",
|
|
1412
|
-
removeButton: "
|
|
1409
|
+
removeButton: "Delete"
|
|
1413
1410
|
}
|
|
1414
1411
|
} = _ref;
|
|
1415
1412
|
// 动态计算列布局
|
|
@@ -1420,7 +1417,7 @@ const LeftList = /*#__PURE__*/React.memo(_ref => {
|
|
|
1420
1417
|
className: "list-container",
|
|
1421
1418
|
children: /*#__PURE__*/jsxRuntime.jsx(antd.List, {
|
|
1422
1419
|
header: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1423
|
-
className: "grid ".concat(gridColumns, " w-full list-header"),
|
|
1420
|
+
className: "grid ".concat(gridColumns, " gap-2 w-full list-header"),
|
|
1424
1421
|
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1425
1422
|
children: "Name"
|
|
1426
1423
|
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
@@ -1438,14 +1435,27 @@ const LeftList = /*#__PURE__*/React.memo(_ref => {
|
|
|
1438
1435
|
},
|
|
1439
1436
|
onClick: () => onSelectPreset(item),
|
|
1440
1437
|
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1441
|
-
className: "grid ".concat(gridColumns, " w-full text-text-normal"),
|
|
1438
|
+
className: "grid ".concat(gridColumns, " gap-2 w-full text-text-normal"),
|
|
1442
1439
|
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1443
|
-
|
|
1444
|
-
children:
|
|
1440
|
+
className: "min-w-0",
|
|
1441
|
+
children: /*#__PURE__*/jsxRuntime.jsx(antd.Typography.Text, {
|
|
1442
|
+
ellipsis: true,
|
|
1443
|
+
title: item.name,
|
|
1444
|
+
children: item.name || "Untitled Preset"
|
|
1445
|
+
})
|
|
1445
1446
|
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1446
|
-
|
|
1447
|
+
className: "min-w-0",
|
|
1448
|
+
children: /*#__PURE__*/jsxRuntime.jsx(antd.Typography.Text, {
|
|
1449
|
+
ellipsis: true,
|
|
1450
|
+
children: item.create_time
|
|
1451
|
+
})
|
|
1447
1452
|
}), showDescription && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1448
|
-
|
|
1453
|
+
className: "min-w-0",
|
|
1454
|
+
children: /*#__PURE__*/jsxRuntime.jsx(antd.Typography.Text, {
|
|
1455
|
+
ellipsis: true,
|
|
1456
|
+
title: item.description,
|
|
1457
|
+
children: item.description
|
|
1458
|
+
})
|
|
1449
1459
|
})]
|
|
1450
1460
|
})
|
|
1451
1461
|
}),
|
|
@@ -1461,7 +1471,7 @@ const LeftList = /*#__PURE__*/React.memo(_ref => {
|
|
|
1461
1471
|
onClick: onAddNew,
|
|
1462
1472
|
className: "p-0 h-auto",
|
|
1463
1473
|
icon: /*#__PURE__*/jsxRuntime.jsx(icons.PlusOutlined, {}),
|
|
1464
|
-
children: "Create
|
|
1474
|
+
children: "Create New Preset"
|
|
1465
1475
|
})
|
|
1466
1476
|
})
|
|
1467
1477
|
})
|
|
@@ -1477,18 +1487,16 @@ const LeftList = /*#__PURE__*/React.memo(_ref => {
|
|
|
1477
1487
|
size: "middle",
|
|
1478
1488
|
children: [/*#__PURE__*/jsxRuntime.jsx(antd.Button, {
|
|
1479
1489
|
type: "default",
|
|
1480
|
-
icon: /*#__PURE__*/jsxRuntime.jsx(icons.PlusOutlined, {})
|
|
1481
|
-
style:
|
|
1482
|
-
|
|
1483
|
-
},
|
|
1490
|
+
icon: /*#__PURE__*/jsxRuntime.jsx(icons.PlusOutlined, {})
|
|
1491
|
+
// style={{ padding: "20px 12px" }}
|
|
1492
|
+
,
|
|
1484
1493
|
className: "btn-gray",
|
|
1485
1494
|
onClick: onAddNew,
|
|
1486
1495
|
children: texts.newButton
|
|
1487
1496
|
}), /*#__PURE__*/jsxRuntime.jsx(antd.Button, {
|
|
1488
|
-
type: "default"
|
|
1489
|
-
style:
|
|
1490
|
-
|
|
1491
|
-
},
|
|
1497
|
+
type: "default"
|
|
1498
|
+
// style={{ padding: "20px 12px" }}
|
|
1499
|
+
,
|
|
1492
1500
|
className: "btn-gray",
|
|
1493
1501
|
onClick: onRemove,
|
|
1494
1502
|
children: texts.removeButton
|
|
@@ -1525,8 +1533,8 @@ const RightDetailForm = /*#__PURE__*/React.memo(_ref3 => {
|
|
|
1525
1533
|
originalPresetData,
|
|
1526
1534
|
fields = {
|
|
1527
1535
|
name: {
|
|
1528
|
-
label: "
|
|
1529
|
-
placeholder: "
|
|
1536
|
+
label: "Name",
|
|
1537
|
+
placeholder: "Please enter name",
|
|
1530
1538
|
required: true
|
|
1531
1539
|
}
|
|
1532
1540
|
},
|
|
@@ -1534,7 +1542,7 @@ const RightDetailForm = /*#__PURE__*/React.memo(_ref3 => {
|
|
|
1534
1542
|
loadButton: "Load",
|
|
1535
1543
|
saveButton: "Save"
|
|
1536
1544
|
},
|
|
1537
|
-
presetChanged
|
|
1545
|
+
presetChanged // 作用:在切换选中预设时强制触发 Checkbox 的重新初始化
|
|
1538
1546
|
} = _ref3;
|
|
1539
1547
|
const [initialSelected, setInitialSelected] = React.useState([]);
|
|
1540
1548
|
const currentSelected = antd.Form.useWatch('category_list', form) || [];
|
|
@@ -1594,32 +1602,40 @@ const RightDetailForm = /*#__PURE__*/React.memo(_ref3 => {
|
|
|
1594
1602
|
},
|
|
1595
1603
|
children: [/*#__PURE__*/jsxRuntime.jsx(antd.Form.Item, {
|
|
1596
1604
|
name: "name",
|
|
1597
|
-
label: fields.name.label
|
|
1598
|
-
rules
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
}
|
|
1605
|
+
label: fields.name.label
|
|
1606
|
+
// rules={[
|
|
1607
|
+
// {
|
|
1608
|
+
// required: fields.name.required,
|
|
1609
|
+
// validator: async (_, value) => {
|
|
1610
|
+
// if (!value || value.trim() === '') {
|
|
1611
|
+
// return Promise.reject(new Error('Preset name cannot be empty or spaces only'));
|
|
1612
|
+
// }
|
|
1613
|
+
// }
|
|
1614
|
+
// }
|
|
1615
|
+
// ]}
|
|
1616
|
+
,
|
|
1617
|
+
required: true,
|
|
1606
1618
|
children: /*#__PURE__*/jsxRuntime.jsx(antd.Input, {
|
|
1607
1619
|
placeholder: fields.name.placeholder,
|
|
1608
1620
|
disabled: isEditing
|
|
1609
1621
|
})
|
|
1610
1622
|
}), hasCategoryList && /*#__PURE__*/jsxRuntime.jsx(antd.Form.Item, {
|
|
1611
1623
|
name: "category_list",
|
|
1612
|
-
label: fields.category_list.label
|
|
1613
|
-
rules
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
}
|
|
1624
|
+
label: fields.category_list.label
|
|
1625
|
+
// rules={[
|
|
1626
|
+
// {
|
|
1627
|
+
// required: fields.category_list.required,
|
|
1628
|
+
// message: 'Please select at least one category',
|
|
1629
|
+
// validator: (_, value) => {
|
|
1630
|
+
// if (value && value.length > 0) {
|
|
1631
|
+
// return Promise.resolve();
|
|
1632
|
+
// }
|
|
1633
|
+
// return Promise.reject(new Error('Please select at least one category'));
|
|
1634
|
+
// }
|
|
1635
|
+
// }
|
|
1636
|
+
// ]}
|
|
1637
|
+
,
|
|
1638
|
+
required: true,
|
|
1623
1639
|
children: /*#__PURE__*/jsxRuntime.jsx(antd.Checkbox.Group, {
|
|
1624
1640
|
className: "grid grid-cols-2 gap-2",
|
|
1625
1641
|
onChange: handleCheckboxChange,
|
|
@@ -1635,7 +1651,10 @@ const RightDetailForm = /*#__PURE__*/React.memo(_ref3 => {
|
|
|
1635
1651
|
children: /*#__PURE__*/jsxRuntime.jsx(antd.Input.TextArea, {
|
|
1636
1652
|
rows: 4,
|
|
1637
1653
|
placeholder: fields.description.placeholder,
|
|
1638
|
-
disabled: isEditing
|
|
1654
|
+
disabled: isEditing,
|
|
1655
|
+
style: {
|
|
1656
|
+
resize: 'none'
|
|
1657
|
+
}
|
|
1639
1658
|
})
|
|
1640
1659
|
})]
|
|
1641
1660
|
}), isEditing ? /*#__PURE__*/jsxRuntime.jsx(SubmitButton, _objectSpread2(_objectSpread2({
|
|
@@ -1668,20 +1687,20 @@ const Preset = _ref => {
|
|
|
1668
1687
|
// 字段配置
|
|
1669
1688
|
fields = {
|
|
1670
1689
|
name: {
|
|
1671
|
-
label: "
|
|
1672
|
-
placeholder: "
|
|
1690
|
+
label: "Name",
|
|
1691
|
+
placeholder: "Please enter name",
|
|
1673
1692
|
required: true
|
|
1674
1693
|
}
|
|
1675
1694
|
},
|
|
1676
1695
|
texts = {
|
|
1677
1696
|
title: "Preset Management",
|
|
1678
1697
|
emptyText: "Select a preset from the list to view details",
|
|
1679
|
-
deleteConfirm: "Are you sure to delete preset",
|
|
1698
|
+
deleteConfirm: "Are you sure you want to delete preset",
|
|
1680
1699
|
loadConfirm: "Are you sure you want to load preset",
|
|
1681
1700
|
loadText: "Loading...",
|
|
1682
1701
|
successText: "Success",
|
|
1683
1702
|
newButton: "New Preset",
|
|
1684
|
-
removeButton: "
|
|
1703
|
+
removeButton: "Delete",
|
|
1685
1704
|
loadButton: "Load",
|
|
1686
1705
|
saveButton: "Save"
|
|
1687
1706
|
},
|
|
@@ -1699,16 +1718,19 @@ const Preset = _ref => {
|
|
|
1699
1718
|
const [loading, setLoading] = React.useState(false);
|
|
1700
1719
|
const [presetChanged, setPresetChanged] = React.useState(0);
|
|
1701
1720
|
const [form] = antd.Form.useForm();
|
|
1702
|
-
|
|
1703
|
-
// 获取预设列表
|
|
1704
|
-
React.useEffect(() => {
|
|
1705
|
-
fetchPresetList();
|
|
1706
|
-
}, []);
|
|
1707
1721
|
const fetchPresetList = React.useCallback(async () => {
|
|
1708
1722
|
try {
|
|
1709
1723
|
const data = await getPresetList();
|
|
1710
1724
|
const presets = (data === null || data === void 0 ? void 0 : data.preset_list) || data || [];
|
|
1711
1725
|
setPresetList(presets);
|
|
1726
|
+
|
|
1727
|
+
// 自动选中第一个预设
|
|
1728
|
+
if (presets.length > 0) {
|
|
1729
|
+
const firstPreset = presets[0];
|
|
1730
|
+
setSelectedPreset(firstPreset);
|
|
1731
|
+
form.setFieldsValue(firstPreset);
|
|
1732
|
+
setPresetChanged(prev => prev + 1);
|
|
1733
|
+
}
|
|
1712
1734
|
} catch (error) {
|
|
1713
1735
|
console.error('Failed to fetch preset list:', error);
|
|
1714
1736
|
}
|
|
@@ -1716,7 +1738,7 @@ const Preset = _ref => {
|
|
|
1716
1738
|
const handleSelectPreset = React.useCallback(preset => {
|
|
1717
1739
|
setSelectedPreset(preset);
|
|
1718
1740
|
form.setFieldsValue(preset);
|
|
1719
|
-
setPresetChanged(prev => prev + 1);
|
|
1741
|
+
setPresetChanged(prev => prev + 1);
|
|
1720
1742
|
}, [form]);
|
|
1721
1743
|
const handleAddNew = React.useCallback(() => {
|
|
1722
1744
|
var _fields$category_list;
|
|
@@ -1754,18 +1776,44 @@ const Preset = _ref => {
|
|
|
1754
1776
|
cancelText: 'No',
|
|
1755
1777
|
okText: 'Yes',
|
|
1756
1778
|
onOk: async () => {
|
|
1779
|
+
// 在删除前记录当前选中项的位置
|
|
1780
|
+
const currentIndex = presetList.findIndex(item => isUnsavedPreset ? !item.id : item.id === selectedPreset.id);
|
|
1757
1781
|
if (!isUnsavedPreset) {
|
|
1758
1782
|
await removePreset({
|
|
1759
1783
|
id: selectedPreset.id
|
|
1760
1784
|
});
|
|
1761
1785
|
AntdMessage.success(texts.successText);
|
|
1762
|
-
// 刷新列表
|
|
1763
|
-
await fetchPresetList();
|
|
1764
1786
|
} else {
|
|
1787
|
+
// 移除未保存的预设
|
|
1765
1788
|
setPresetList(prev => prev.filter(item => !!item.id));
|
|
1766
1789
|
}
|
|
1767
1790
|
|
|
1768
|
-
//
|
|
1791
|
+
// 获取删除后的列表
|
|
1792
|
+
const updatedList = isUnsavedPreset ? presetList.filter(item => !!item.id) : await getPresetList().then(data => (data === null || data === void 0 ? void 0 : data.preset_list) || data || []);
|
|
1793
|
+
|
|
1794
|
+
// 更新列表
|
|
1795
|
+
setPresetList(updatedList);
|
|
1796
|
+
if (updatedList.length > 0) {
|
|
1797
|
+
// 计算下一个索引
|
|
1798
|
+
let nextIndex = 0;
|
|
1799
|
+
if (currentIndex > 0) {
|
|
1800
|
+
// 如果删除的不是最后一项
|
|
1801
|
+
if (currentIndex < updatedList.length) {
|
|
1802
|
+
nextIndex = currentIndex; // 保持相同位置
|
|
1803
|
+
} else {
|
|
1804
|
+
nextIndex = updatedList.length - 1; // 选最后一个
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
const nextPreset = updatedList[nextIndex];
|
|
1808
|
+
if (nextPreset) {
|
|
1809
|
+
setSelectedPreset(nextPreset);
|
|
1810
|
+
form.setFieldsValue(nextPreset);
|
|
1811
|
+
setPresetChanged(prev => prev + 1);
|
|
1812
|
+
return;
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
|
|
1816
|
+
// 列表为空
|
|
1769
1817
|
setSelectedPreset(null);
|
|
1770
1818
|
form.resetFields();
|
|
1771
1819
|
}
|
|
@@ -1773,7 +1821,7 @@ const Preset = _ref => {
|
|
|
1773
1821
|
} catch (error) {
|
|
1774
1822
|
console.error('Failed to delete preset:', error);
|
|
1775
1823
|
}
|
|
1776
|
-
}, [selectedPreset, form, AntdModal, AntdMessage,
|
|
1824
|
+
}, [selectedPreset, form, AntdModal, AntdMessage, texts, removePreset, getPresetList]);
|
|
1777
1825
|
const handleLoadPreset = React.useCallback(async loadData => {
|
|
1778
1826
|
if (!loadData) return;
|
|
1779
1827
|
|
|
@@ -1829,27 +1877,53 @@ const Preset = _ref => {
|
|
|
1829
1877
|
const handleSave = React.useCallback(async () => {
|
|
1830
1878
|
setLoading(true);
|
|
1831
1879
|
try {
|
|
1832
|
-
|
|
1833
|
-
|
|
1880
|
+
var _fields$name, _fields$category_list2;
|
|
1881
|
+
const values = await form.getFieldsValue();
|
|
1882
|
+
|
|
1883
|
+
// 验证预设名称
|
|
1884
|
+
if ((_fields$name = fields.name) !== null && _fields$name !== void 0 && _fields$name.required) {
|
|
1885
|
+
if (!values.name || values.name.trim() === '') {
|
|
1886
|
+
AntdMessage.error('Name is required.');
|
|
1887
|
+
return; // 直接返回 不执行
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
|
|
1891
|
+
// 验证分类列表
|
|
1892
|
+
if ((_fields$category_list2 = fields.category_list) !== null && _fields$category_list2 !== void 0 && _fields$category_list2.required) {
|
|
1893
|
+
if (!values.category_list || values.category_list.length === 0) {
|
|
1894
|
+
AntdMessage.error('No category selected.');
|
|
1895
|
+
return;
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1834
1898
|
await savePreset(values);
|
|
1835
1899
|
AntdMessage.success(texts.successText);
|
|
1900
|
+
const savedPresetName = values.name;
|
|
1901
|
+
|
|
1836
1902
|
// 刷新列表
|
|
1837
|
-
await
|
|
1903
|
+
const data = await getPresetList();
|
|
1904
|
+
const presets = (data === null || data === void 0 ? void 0 : data.preset_list) || data || [];
|
|
1905
|
+
setPresetList(presets);
|
|
1838
1906
|
|
|
1839
|
-
//
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
console.error('Form validation failed:', error.errorFields);
|
|
1907
|
+
// 在刷新后的列表中查找同名的预设
|
|
1908
|
+
const newlySavedPreset = presets.find(item => item.name === savedPresetName);
|
|
1909
|
+
if (newlySavedPreset) {
|
|
1910
|
+
setSelectedPreset(newlySavedPreset);
|
|
1911
|
+
form.setFieldsValue(newlySavedPreset);
|
|
1912
|
+
setPresetChanged(prev => prev + 1);
|
|
1846
1913
|
} else {
|
|
1847
|
-
|
|
1914
|
+
setSelectedPreset(values);
|
|
1848
1915
|
}
|
|
1916
|
+
} catch (error) {
|
|
1917
|
+
console.error('Failed to save preset:', error);
|
|
1849
1918
|
} finally {
|
|
1850
1919
|
setLoading(false);
|
|
1851
1920
|
}
|
|
1852
|
-
}, [form, AntdMessage,
|
|
1921
|
+
}, [form, AntdMessage, texts, savePreset, getPresetList]);
|
|
1922
|
+
|
|
1923
|
+
// 初始化数据
|
|
1924
|
+
React.useEffect(() => {
|
|
1925
|
+
fetchPresetList();
|
|
1926
|
+
}, [fetchPresetList]);
|
|
1853
1927
|
return /*#__PURE__*/jsxRuntime.jsx(antd.Modal, {
|
|
1854
1928
|
title: texts.title,
|
|
1855
1929
|
width: width,
|