-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
### What problem does this PR solve? feat: Add component BaiduFanyi #1739 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
- Loading branch information
Showing
9 changed files
with
308 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { useTranslate } from '@/hooks/common-hooks'; | ||
import { Form, Input, Select } from 'antd'; | ||
import { useMemo } from 'react'; | ||
import { | ||
BaiduFanyiDomainOptions, | ||
BaiduFanyiSourceLangOptions, | ||
} from '../constant'; | ||
import { IOperatorForm } from '../interface'; | ||
|
||
const BaiduFanyiForm = ({ onValuesChange, form }: IOperatorForm) => { | ||
const { t } = useTranslate('flow'); | ||
const options = useMemo(() => { | ||
return ['translate', 'fieldtranslate'].map((x) => ({ | ||
value: x, | ||
label: t(`baiduSecretKeyOptions.${x}`), | ||
})); | ||
}, [t]); | ||
|
||
const baiduFanyiOptions = useMemo(() => { | ||
return BaiduFanyiDomainOptions.map((x) => ({ | ||
value: x, | ||
label: t(`baiduDomainOptions.${x}`), | ||
})); | ||
}, [t]); | ||
|
||
const baiduFanyiSourceLangOptions = useMemo(() => { | ||
return BaiduFanyiSourceLangOptions.map((x) => ({ | ||
value: x, | ||
label: t(`baiduSourceLangOptions.${x}`), | ||
})); | ||
}, [t]); | ||
|
||
return ( | ||
<Form | ||
name="basic" | ||
labelCol={{ span: 8 }} | ||
wrapperCol={{ span: 16 }} | ||
autoComplete="off" | ||
form={form} | ||
onValuesChange={onValuesChange} | ||
> | ||
<Form.Item label={t('appid')} name={'appid'}> | ||
<Input></Input> | ||
</Form.Item> | ||
<Form.Item label={t('secretKey')} name={'secret_key'}> | ||
<Input></Input> | ||
</Form.Item> | ||
<Form.Item label={t('transType')} name={'trans_type'}> | ||
<Select options={options}></Select> | ||
</Form.Item> | ||
<Form.Item noStyle dependencies={['model_type']}> | ||
{({ getFieldValue }) => | ||
getFieldValue('trans_type') === 'fieldtranslate' && ( | ||
<Form.Item label={t('domain')} name={'domain'}> | ||
<Select options={baiduFanyiOptions}></Select> | ||
</Form.Item> | ||
) | ||
} | ||
</Form.Item> | ||
<Form.Item label={t('sourceLang')} name={'source_lang'}> | ||
<Select options={baiduFanyiSourceLangOptions}></Select> | ||
</Form.Item> | ||
<Form.Item label={t('targetLang')} name={'target_lang'}> | ||
<Select options={baiduFanyiSourceLangOptions}></Select> | ||
</Form.Item> | ||
</Form> | ||
); | ||
}; | ||
|
||
export default BaiduFanyiForm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.