seeder-st2110-components 1.6.10 → 1.7.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/dist/index.esm.js +143 -23
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +143 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1533,17 +1533,21 @@ const SubmitButton = _ref2 => {
|
|
|
1533
1533
|
loading,
|
|
1534
1534
|
action,
|
|
1535
1535
|
children,
|
|
1536
|
-
disabled = false
|
|
1536
|
+
disabled = false,
|
|
1537
|
+
editButtonEle = null
|
|
1537
1538
|
} = _ref2;
|
|
1538
1539
|
return /*#__PURE__*/jsx("div", {
|
|
1539
1540
|
className: "submit-btn-wrapper",
|
|
1540
|
-
children: /*#__PURE__*/
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1541
|
+
children: /*#__PURE__*/jsxs(Space, {
|
|
1542
|
+
size: "middle",
|
|
1543
|
+
children: [editButtonEle, /*#__PURE__*/jsx(Button, {
|
|
1544
|
+
type: "default",
|
|
1545
|
+
className: "btn-gray",
|
|
1546
|
+
loading: loading,
|
|
1547
|
+
onClick: action,
|
|
1548
|
+
disabled: disabled,
|
|
1549
|
+
children: children
|
|
1550
|
+
})]
|
|
1547
1551
|
})
|
|
1548
1552
|
});
|
|
1549
1553
|
};
|
|
@@ -1552,8 +1556,11 @@ const RightDetailForm = /*#__PURE__*/memo(_ref3 => {
|
|
|
1552
1556
|
form,
|
|
1553
1557
|
onSave,
|
|
1554
1558
|
onLoad,
|
|
1559
|
+
onEdit,
|
|
1560
|
+
onCancelEdit,
|
|
1561
|
+
onUpdate,
|
|
1555
1562
|
isLoading,
|
|
1556
|
-
|
|
1563
|
+
isSavedPreset,
|
|
1557
1564
|
originalPresetData,
|
|
1558
1565
|
fields = {
|
|
1559
1566
|
name: {
|
|
@@ -1564,11 +1571,14 @@ const RightDetailForm = /*#__PURE__*/memo(_ref3 => {
|
|
|
1564
1571
|
},
|
|
1565
1572
|
texts = {
|
|
1566
1573
|
loadButton: "Load",
|
|
1567
|
-
saveButton: "Save"
|
|
1574
|
+
saveButton: "Save",
|
|
1575
|
+
editButton: "Edit",
|
|
1576
|
+
cancelButton: "Cancel"
|
|
1568
1577
|
},
|
|
1569
1578
|
presetChanged // 作用:在切换选中预设时强制触发 Checkbox 的重新初始化
|
|
1570
1579
|
} = _ref3;
|
|
1571
1580
|
const [initialSelected, setInitialSelected] = useState([]);
|
|
1581
|
+
const [isEditMode, setIsEditMode] = useState(false); // 是否进入编辑模式
|
|
1572
1582
|
const currentSelected = Form.useWatch('category_list', form) || [];
|
|
1573
1583
|
|
|
1574
1584
|
// 检查是否包含category_list字段
|
|
@@ -1582,23 +1592,53 @@ const RightDetailForm = /*#__PURE__*/memo(_ref3 => {
|
|
|
1582
1592
|
}
|
|
1583
1593
|
}, [presetChanged, form, hasCategoryList]); // 当presetChanged变化时更新
|
|
1584
1594
|
|
|
1595
|
+
// 当 isSavedPreset 或 presetChanged 变化时,重置编辑模式
|
|
1596
|
+
useEffect(() => {
|
|
1597
|
+
setIsEditMode(false);
|
|
1598
|
+
}, [isSavedPreset, presetChanged]);
|
|
1599
|
+
|
|
1585
1600
|
// 动态生成 checkbox 选项
|
|
1586
1601
|
const checkboxOptions = useMemo(() => {
|
|
1587
1602
|
if (!hasCategoryList) return [];
|
|
1588
1603
|
return fields.category_list.options.map(category => {
|
|
1589
1604
|
const isInitiallySelected = initialSelected.includes(category.name);
|
|
1590
|
-
const shouldDisable =
|
|
1605
|
+
const shouldDisable = isSavedPreset ? !isInitiallySelected : false;
|
|
1591
1606
|
return _objectSpread2(_objectSpread2({}, category), {}, {
|
|
1592
1607
|
disabled: shouldDisable,
|
|
1593
1608
|
initiallySelected: isInitiallySelected
|
|
1594
1609
|
});
|
|
1595
1610
|
});
|
|
1596
|
-
}, [initialSelected,
|
|
1611
|
+
}, [initialSelected, isSavedPreset, hasCategoryList, fields.category_list]);
|
|
1597
1612
|
const handleCheckboxChange = checkedValues => {
|
|
1598
1613
|
form.setFieldsValue({
|
|
1599
1614
|
category_list: checkedValues
|
|
1600
1615
|
});
|
|
1601
1616
|
};
|
|
1617
|
+
const handleEditClick = () => {
|
|
1618
|
+
setIsEditMode(true);
|
|
1619
|
+
if (onEdit) {
|
|
1620
|
+
onEdit(); // 如果有外部回调
|
|
1621
|
+
}
|
|
1622
|
+
};
|
|
1623
|
+
const handleCancelEdit = () => {
|
|
1624
|
+
if (originalPresetData) {
|
|
1625
|
+
form.setFieldsValue(originalPresetData);
|
|
1626
|
+
}
|
|
1627
|
+
setIsEditMode(false);
|
|
1628
|
+
if (onCancelEdit) {
|
|
1629
|
+
onCancelEdit();
|
|
1630
|
+
}
|
|
1631
|
+
};
|
|
1632
|
+
const handleSaveEdit = async () => {
|
|
1633
|
+
try {
|
|
1634
|
+
if (onUpdate) {
|
|
1635
|
+
await onUpdate();
|
|
1636
|
+
}
|
|
1637
|
+
setIsEditMode(false);
|
|
1638
|
+
} catch (error) {
|
|
1639
|
+
console.error('update fail:', error);
|
|
1640
|
+
}
|
|
1641
|
+
};
|
|
1602
1642
|
const handleLoad = async () => {
|
|
1603
1643
|
try {
|
|
1604
1644
|
const formValues = await form.validateFields();
|
|
@@ -1613,6 +1653,11 @@ const RightDetailForm = /*#__PURE__*/memo(_ref3 => {
|
|
|
1613
1653
|
console.error('表单验证失败:', error);
|
|
1614
1654
|
}
|
|
1615
1655
|
};
|
|
1656
|
+
|
|
1657
|
+
// 在编辑模式下,name 和 description 可以编辑,但 categories 不可编辑
|
|
1658
|
+
const shouldDisableNameAndDesc = isSavedPreset && !isEditMode;
|
|
1659
|
+
const shouldDisableCategories = isEditMode; // categories 在编辑模式下总是不可编辑
|
|
1660
|
+
|
|
1616
1661
|
return /*#__PURE__*/jsxs(Flex, {
|
|
1617
1662
|
vertical: true,
|
|
1618
1663
|
style: {
|
|
@@ -1644,7 +1689,7 @@ const RightDetailForm = /*#__PURE__*/memo(_ref3 => {
|
|
|
1644
1689
|
required: true,
|
|
1645
1690
|
children: /*#__PURE__*/jsx(Input, {
|
|
1646
1691
|
placeholder: fields.name.placeholder,
|
|
1647
|
-
disabled:
|
|
1692
|
+
disabled: shouldDisableNameAndDesc
|
|
1648
1693
|
})
|
|
1649
1694
|
}), hasCategoryList && /*#__PURE__*/jsx(Form.Item, {
|
|
1650
1695
|
name: "category_list",
|
|
@@ -1666,9 +1711,10 @@ const RightDetailForm = /*#__PURE__*/memo(_ref3 => {
|
|
|
1666
1711
|
children: /*#__PURE__*/jsx(Checkbox.Group, {
|
|
1667
1712
|
className: "grid grid-cols-2 gap-2",
|
|
1668
1713
|
onChange: handleCheckboxChange,
|
|
1714
|
+
disabled: shouldDisableCategories,
|
|
1669
1715
|
children: checkboxOptions.map(category => /*#__PURE__*/jsx(Checkbox, {
|
|
1670
1716
|
value: category.name,
|
|
1671
|
-
disabled: category.disabled,
|
|
1717
|
+
disabled: category.disabled || shouldDisableCategories,
|
|
1672
1718
|
children: category.label
|
|
1673
1719
|
}, category.name))
|
|
1674
1720
|
})
|
|
@@ -1678,17 +1724,46 @@ const RightDetailForm = /*#__PURE__*/memo(_ref3 => {
|
|
|
1678
1724
|
children: /*#__PURE__*/jsx(Input.TextArea, {
|
|
1679
1725
|
rows: 4,
|
|
1680
1726
|
placeholder: fields.description.placeholder,
|
|
1681
|
-
disabled:
|
|
1727
|
+
disabled: shouldDisableNameAndDesc,
|
|
1682
1728
|
style: {
|
|
1683
1729
|
resize: 'none'
|
|
1684
1730
|
}
|
|
1685
1731
|
})
|
|
1686
1732
|
})]
|
|
1687
|
-
}),
|
|
1733
|
+
}), isSavedPreset ? isEditMode ?
|
|
1734
|
+
/*#__PURE__*/
|
|
1735
|
+
// 编辑模式下的按钮
|
|
1736
|
+
jsx("div", {
|
|
1737
|
+
className: "submit-btn-wrapper",
|
|
1738
|
+
children: /*#__PURE__*/jsxs(Space, {
|
|
1739
|
+
size: "middle",
|
|
1740
|
+
children: [/*#__PURE__*/jsx(Button, {
|
|
1741
|
+
type: "default",
|
|
1742
|
+
className: "btn-gray",
|
|
1743
|
+
onClick: handleCancelEdit,
|
|
1744
|
+
children: texts.cancelButton
|
|
1745
|
+
}), /*#__PURE__*/jsx(Button, {
|
|
1746
|
+
type: "default",
|
|
1747
|
+
className: "btn-gray",
|
|
1748
|
+
onClick: handleSaveEdit,
|
|
1749
|
+
loading: isLoading,
|
|
1750
|
+
children: texts.saveButton
|
|
1751
|
+
})]
|
|
1752
|
+
})
|
|
1753
|
+
}) :
|
|
1754
|
+
/*#__PURE__*/
|
|
1755
|
+
// 非编辑模式下的按钮
|
|
1756
|
+
jsx(SubmitButton, _objectSpread2(_objectSpread2({
|
|
1688
1757
|
action: handleLoad
|
|
1689
1758
|
}, hasCategoryList && {
|
|
1690
1759
|
disabled: !currentSelected.length
|
|
1691
1760
|
}), {}, {
|
|
1761
|
+
editButtonEle: /*#__PURE__*/jsx(Button, {
|
|
1762
|
+
type: "default",
|
|
1763
|
+
className: "btn-gray",
|
|
1764
|
+
onClick: handleEditClick,
|
|
1765
|
+
children: texts.editButton
|
|
1766
|
+
}),
|
|
1692
1767
|
children: texts.loadButton
|
|
1693
1768
|
})) : /*#__PURE__*/jsx(SubmitButton, {
|
|
1694
1769
|
action: onSave,
|
|
@@ -1707,6 +1782,7 @@ const Preset = _ref => {
|
|
|
1707
1782
|
savePreset,
|
|
1708
1783
|
removePreset,
|
|
1709
1784
|
loadPreset,
|
|
1785
|
+
updatePreset,
|
|
1710
1786
|
onLoadSuccess,
|
|
1711
1787
|
// 加载成功后的回调
|
|
1712
1788
|
onLoadError,
|
|
@@ -1729,7 +1805,9 @@ const Preset = _ref => {
|
|
|
1729
1805
|
newButton: "New Preset",
|
|
1730
1806
|
removeButton: "Delete",
|
|
1731
1807
|
loadButton: "Load",
|
|
1732
|
-
saveButton: "Save"
|
|
1808
|
+
saveButton: "Save",
|
|
1809
|
+
editButton: "Edit",
|
|
1810
|
+
cancelButton: "Cancel"
|
|
1733
1811
|
},
|
|
1734
1812
|
// 样式定制
|
|
1735
1813
|
width = 1000,
|
|
@@ -1946,6 +2024,47 @@ const Preset = _ref => {
|
|
|
1946
2024
|
setLoading(false);
|
|
1947
2025
|
}
|
|
1948
2026
|
}, [form, AntdMessage, texts, savePreset, getPresetList]);
|
|
2027
|
+
const handleUpdate = useCallback(async () => {
|
|
2028
|
+
if (!selectedPreset || !selectedPreset.id) {
|
|
2029
|
+
AntdMessage.error('No preset selected or preset ID is missing.');
|
|
2030
|
+
return;
|
|
2031
|
+
}
|
|
2032
|
+
setLoading(true);
|
|
2033
|
+
try {
|
|
2034
|
+
var _fields$name2;
|
|
2035
|
+
const values = await form.getFieldsValue();
|
|
2036
|
+
|
|
2037
|
+
// 验证预设名称
|
|
2038
|
+
if ((_fields$name2 = fields.name) !== null && _fields$name2 !== void 0 && _fields$name2.required) {
|
|
2039
|
+
if (!values.name || values.name.trim() === '') {
|
|
2040
|
+
AntdMessage.error('Name is required.');
|
|
2041
|
+
return; // 直接返回 不执行
|
|
2042
|
+
}
|
|
2043
|
+
}
|
|
2044
|
+
await updatePreset({
|
|
2045
|
+
id: selectedPreset.id,
|
|
2046
|
+
name: values.name,
|
|
2047
|
+
description: values.description
|
|
2048
|
+
});
|
|
2049
|
+
|
|
2050
|
+
// 刷新列表
|
|
2051
|
+
const data = await getPresetList();
|
|
2052
|
+
const presets = (data === null || data === void 0 ? void 0 : data.preset_list) || data || [];
|
|
2053
|
+
setPresetList(presets);
|
|
2054
|
+
|
|
2055
|
+
// 更新当前选中的预设
|
|
2056
|
+
const updatedPreset = presets.find(item => item.id === selectedPreset.id);
|
|
2057
|
+
if (updatedPreset) {
|
|
2058
|
+
setSelectedPreset(updatedPreset);
|
|
2059
|
+
}
|
|
2060
|
+
AntdMessage.success(texts.successText);
|
|
2061
|
+
} catch (error) {
|
|
2062
|
+
console.error('Failed to update preset:', error);
|
|
2063
|
+
throw error;
|
|
2064
|
+
} finally {
|
|
2065
|
+
setLoading(false);
|
|
2066
|
+
}
|
|
2067
|
+
}, [form, AntdMessage, texts, updatePreset, selectedPreset]);
|
|
1949
2068
|
|
|
1950
2069
|
// 初始化数据
|
|
1951
2070
|
useEffect(() => {
|
|
@@ -1991,14 +2110,17 @@ const Preset = _ref => {
|
|
|
1991
2110
|
form: form,
|
|
1992
2111
|
onSave: handleSave,
|
|
1993
2112
|
onLoad: handleLoadPreset,
|
|
2113
|
+
onUpdate: handleUpdate,
|
|
1994
2114
|
isLoading: loading,
|
|
1995
|
-
|
|
2115
|
+
isSavedPreset: !!(selectedPreset !== null && selectedPreset !== void 0 && selectedPreset.id),
|
|
1996
2116
|
originalPresetData: selectedPreset // 传递原始数据
|
|
1997
2117
|
,
|
|
1998
2118
|
fields: fields,
|
|
1999
2119
|
texts: {
|
|
2000
2120
|
loadButton: texts.loadButton,
|
|
2001
|
-
saveButton: texts.saveButton
|
|
2121
|
+
saveButton: texts.saveButton,
|
|
2122
|
+
editButton: texts.editButton,
|
|
2123
|
+
cancelButton: texts.cancelButton
|
|
2002
2124
|
},
|
|
2003
2125
|
presetChanged: presetChanged
|
|
2004
2126
|
}) : /*#__PURE__*/jsx(Flex, {
|
|
@@ -3435,9 +3557,7 @@ const CommonHeader = _ref => {
|
|
|
3435
3557
|
className = '',
|
|
3436
3558
|
style = {},
|
|
3437
3559
|
// 新增插槽
|
|
3438
|
-
leftContent
|
|
3439
|
-
// 左侧额外内容
|
|
3440
|
-
rightContent = null // 右侧额外内容
|
|
3560
|
+
leftContent // 左侧额外内容
|
|
3441
3561
|
} = _ref;
|
|
3442
3562
|
const [logo] = useSpaLogo$1(logoProps);
|
|
3443
3563
|
|
|
@@ -3471,7 +3591,7 @@ const CommonHeader = _ref => {
|
|
|
3471
3591
|
}), /*#__PURE__*/jsxs(Flex, {
|
|
3472
3592
|
align: "center",
|
|
3473
3593
|
gap: 10,
|
|
3474
|
-
children: [
|
|
3594
|
+
children: [showHardwareUsage && usageElement, /*#__PURE__*/jsxs("div", {
|
|
3475
3595
|
className: "header-controls",
|
|
3476
3596
|
children: [menuElement && /*#__PURE__*/jsx("div", {
|
|
3477
3597
|
className: "control-icon",
|