fix: press enter to submit custom model name
This commit is contained in:
parent
621eb91b46
commit
276163affd
@ -14,13 +14,13 @@ function type2secretPrompt(type) {
|
|||||||
// inputs.type === 15 ? '按照如下格式输入:APIKey|SecretKey' : (inputs.type === 18 ? '按照如下格式输入:APPID|APISecret|APIKey' : '请输入渠道对应的鉴权密钥')
|
// inputs.type === 15 ? '按照如下格式输入:APIKey|SecretKey' : (inputs.type === 18 ? '按照如下格式输入:APPID|APISecret|APIKey' : '请输入渠道对应的鉴权密钥')
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 15:
|
case 15:
|
||||||
return "按照如下格式输入:APIKey|SecretKey"
|
return '按照如下格式输入:APIKey|SecretKey';
|
||||||
case 18:
|
case 18:
|
||||||
return "按照如下格式输入:APPID|APISecret|APIKey"
|
return '按照如下格式输入:APPID|APISecret|APIKey';
|
||||||
case 22:
|
case 22:
|
||||||
return "按照如下格式输入:APIKey-AppId,例如:fastgpt-0sp2gtvfdgyi4k30jwlgwf1i-64f335d84283f05518e9e041"
|
return '按照如下格式输入:APIKey-AppId,例如:fastgpt-0sp2gtvfdgyi4k30jwlgwf1i-64f335d84283f05518e9e041';
|
||||||
default:
|
default:
|
||||||
return "请输入渠道对应的鉴权密钥"
|
return '请输入渠道对应的鉴权密钥';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,6 +207,24 @@ const EditChannel = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const addCustomModel = () => {
|
||||||
|
if (customModel.trim() === '') return;
|
||||||
|
if (inputs.models.includes(customModel)) return;
|
||||||
|
let localModels = [...inputs.models];
|
||||||
|
localModels.push(customModel);
|
||||||
|
let localModelOptions = [];
|
||||||
|
localModelOptions.push({
|
||||||
|
key: customModel,
|
||||||
|
text: customModel,
|
||||||
|
value: customModel
|
||||||
|
});
|
||||||
|
setModelOptions(modelOptions => {
|
||||||
|
return [...modelOptions, ...localModelOptions];
|
||||||
|
});
|
||||||
|
setCustomModel('');
|
||||||
|
handleInputChange(null, { name: 'models', value: localModels });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Segment loading={loading}>
|
<Segment loading={loading}>
|
||||||
@ -350,29 +368,19 @@ const EditChannel = () => {
|
|||||||
}}>清除所有模型</Button>
|
}}>清除所有模型</Button>
|
||||||
<Input
|
<Input
|
||||||
action={
|
action={
|
||||||
<Button type={'button'} onClick={() => {
|
<Button type={'button'} onClick={addCustomModel}>填入</Button>
|
||||||
if (customModel.trim() === '') return;
|
|
||||||
if (inputs.models.includes(customModel)) return;
|
|
||||||
let localModels = [...inputs.models];
|
|
||||||
localModels.push(customModel);
|
|
||||||
let localModelOptions = [];
|
|
||||||
localModelOptions.push({
|
|
||||||
key: customModel,
|
|
||||||
text: customModel,
|
|
||||||
value: customModel
|
|
||||||
});
|
|
||||||
setModelOptions(modelOptions => {
|
|
||||||
return [...modelOptions, ...localModelOptions];
|
|
||||||
});
|
|
||||||
setCustomModel('');
|
|
||||||
handleInputChange(null, { name: 'models', value: localModels });
|
|
||||||
}}>填入</Button>
|
|
||||||
}
|
}
|
||||||
placeholder='输入自定义模型名称'
|
placeholder='输入自定义模型名称'
|
||||||
value={customModel}
|
value={customModel}
|
||||||
onChange={(e, { value }) => {
|
onChange={(e, { value }) => {
|
||||||
setCustomModel(value);
|
setCustomModel(value);
|
||||||
}}
|
}}
|
||||||
|
onKeyDown={(e) => {
|
||||||
|
if (e.key === 'Enter') {
|
||||||
|
addCustomModel();
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Form.Field>
|
<Form.Field>
|
||||||
|
Loading…
Reference in New Issue
Block a user