feat: Enhance EditChannelModal with JSONEditor key updates and input reset

- Added unique keys for JSONEditor components to ensure proper re-rendering based on channelId.
- Implemented input reset to clear previous JSON field values when the modal is opened.
This commit is contained in:
CaIon
2025-08-10 12:22:18 +08:00
parent 1d578b73ce
commit 1cc81deb69

View File

@@ -587,6 +587,8 @@ const EditChannelModal = (props) => {
if (formApiRef.current) {
formApiRef.current.setValue('key_mode', undefined);
}
// 重置本地输入,避免下次打开残留上一次的 JSON 字段值
setInputs(getInitValues());
}
}, [props.visible, channelId]);
@@ -1257,6 +1259,7 @@ const EditChannelModal = (props) => {
{inputs.type === 41 && (
<JSONEditor
key={`region-${isEdit ? channelId : 'new'}`}
field='other'
label={t('部署地区')}
placeholder={t(
@@ -1552,6 +1555,7 @@ const EditChannelModal = (props) => {
/>
<JSONEditor
key={`model_mapping-${isEdit ? channelId : 'new'}`}
field='model_mapping'
label={t('模型重定向')}
placeholder={
@@ -1655,6 +1659,7 @@ const EditChannelModal = (props) => {
/>
<JSONEditor
key={`status_code_mapping-${isEdit ? channelId : 'new'}`}
field='status_code_mapping'
label={t('状态码复写')}
placeholder={