fix: key is wrongly updated

This commit is contained in:
JustSong 2024-04-21 17:38:39 +08:00
parent 541182102e
commit d14e4aa01b

View File

@ -57,7 +57,8 @@ const EditChannel = () => {
const [config, setConfig] = useState({ const [config, setConfig] = useState({
region: '', region: '',
sk: '', sk: '',
ak: '' ak: '',
user_id: ''
}); });
const handleInputChange = (e, { name, value }) => { const handleInputChange = (e, { name, value }) => {
setInputs((inputs) => ({ ...inputs, [name]: value })); setInputs((inputs) => ({ ...inputs, [name]: value }));
@ -156,9 +157,11 @@ const EditChannel = () => {
}, []); }, []);
const submit = async () => { const submit = async () => {
if (inputs.key === "") { if (inputs.key === '') {
if (config.ak !== '' && config.sk !== '' && config.region !== '') {
inputs.key = `${config.ak}|${config.sk}|${config.region}`; inputs.key = `${config.ak}|${config.sk}|${config.region}`;
} }
}
if (!isEdit && (inputs.name === '' || inputs.key === '')) { if (!isEdit && (inputs.name === '' || inputs.key === '')) {
showInfo('请填写渠道名称和渠道密钥!'); showInfo('请填写渠道名称和渠道密钥!');
return; return;
@ -442,6 +445,18 @@ const EditChannel = () => {
</Form.Field> </Form.Field>
) )
} }
{
inputs.type === 34 && (
<Form.Input
label='User ID'
name='user_id'
required
placeholder={'生成该密钥的用户 ID'}
onChange={handleConfigChange}
value={config.user_id}
autoComplete=''
/>)
}
{ {
inputs.type !== 33 && (batch ? <Form.Field> inputs.type !== 33 && (batch ? <Form.Field>
<Form.TextArea <Form.TextArea