✨ 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:
@@ -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={
|
||||
|
||||
Reference in New Issue
Block a user