From 54e738941dc0c0eff2c5f0933d6b7190f0327940 Mon Sep 17 00:00:00 2001 From: "1808837298@qq.com" <1808837298@qq.com> Date: Sat, 15 Mar 2025 19:38:05 +0800 Subject: [PATCH] feat: Add warning modal for base URL input and display warning banner for specific channel type in EditChannel component --- web/src/pages/Channel/EditChannel.js | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/web/src/pages/Channel/EditChannel.js b/web/src/pages/Channel/EditChannel.js index bfc611fe..f3024d9b 100644 --- a/web/src/pages/Channel/EditChannel.js +++ b/web/src/pages/Channel/EditChannel.js @@ -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: '不需要在末尾加/v1,New 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 && ( + <> +