feat: Add warning modal for base URL input and display warning banner for specific channel type in EditChannel component

This commit is contained in:
1808837298@qq.com
2025-03-15 19:38:05 +08:00
parent dd393cd0d9
commit 54e738941d

View File

@@ -6,7 +6,7 @@ import {
isMobile,
showError,
showInfo,
showSuccess,
showSuccess, showWarning,
verifyJSON
} from '../../helpers';
import { CHANNEL_OPTIONS } from '../../constants';
@@ -22,11 +22,9 @@ import {
Select,
TextArea,
Checkbox,
Banner
Banner, Modal
} from '@douyinfe/semi-ui';
import { Divider } from 'semantic-ui-react';
import { getChannelModels, loadChannelModels } from '../../components/utils.js';
import axios from 'axios';
const MODEL_MAPPING_EXAMPLE = {
'gpt-3.5-turbo': 'gpt-3.5-turbo-0125'
@@ -41,8 +39,6 @@ const REGION_EXAMPLE = {
'claude-3-5-sonnet-20240620': 'europe-west1'
};
const fetchButtonTips = '1. 新建渠道时请求通过当前浏览器发出2. 编辑已有渠道,请求通过后端服务器发出';
function type2secretPrompt(type) {
// inputs.type === 15 ? '按照如下格式输入APIKey|SecretKey' : (inputs.type === 18 ? '按照如下格式输入APPID|APISecret|APIKey' : '请输入渠道对应的鉴权密钥')
switch (type) {
@@ -99,6 +95,16 @@ const EditChannel = (props) => {
const [fullModels, setFullModels] = useState([]);
const [customModel, setCustomModel] = useState('');
const handleInputChange = (name, value) => {
if (name === 'base_url' && value.endsWith('/v1')) {
Modal.confirm({
title: '警告',
content: '不需要在末尾加/v1New API会自动处理添加后可能导致请求失败是否继续',
onOk: () => {
setInputs((inputs) => ({ ...inputs, [name]: value }));
}
})
return
}
setInputs((inputs) => ({ ...inputs, [name]: value }));
if (name === 'type') {
let localModels = [];
@@ -524,6 +530,16 @@ const EditChannel = (props) => {
/>
</>
)}
{inputs.type === 37 && (
<>
<div style={{ marginTop: 10 }}>
<Banner
type={'warning'}
description={t('Dify渠道只适配chatflow和agent并且agent不支持图片')}
></Banner>
</div>
</>
)}
<div style={{ marginTop: 10 }}>
<Typography.Text strong>{t('名称')}</Typography.Text>
</div>