|
|
@@ -164,6 +164,8 @@ const EditChannelModal = (props) => {
|
|
|
settings: '',
|
|
|
// 仅 Vertex: 密钥格式(存入 settings.vertex_key_type)
|
|
|
vertex_key_type: 'json',
|
|
|
+ // 企业账户设置
|
|
|
+ is_enterprise_account: false,
|
|
|
};
|
|
|
const [batch, setBatch] = useState(false);
|
|
|
const [multiToSingle, setMultiToSingle] = useState(false);
|
|
|
@@ -189,6 +191,7 @@ const EditChannelModal = (props) => {
|
|
|
const [channelSearchValue, setChannelSearchValue] = useState('');
|
|
|
const [useManualInput, setUseManualInput] = useState(false); // 是否使用手动输入模式
|
|
|
const [keyMode, setKeyMode] = useState('append'); // 密钥模式:replace(覆盖)或 append(追加)
|
|
|
+ const [isEnterpriseAccount, setIsEnterpriseAccount] = useState(false); // 是否为企业账户
|
|
|
|
|
|
// 2FA验证查看密钥相关状态
|
|
|
const [twoFAState, setTwoFAState] = useState({
|
|
|
@@ -437,15 +440,19 @@ const EditChannelModal = (props) => {
|
|
|
parsedSettings.azure_responses_version || '';
|
|
|
// 读取 Vertex 密钥格式
|
|
|
data.vertex_key_type = parsedSettings.vertex_key_type || 'json';
|
|
|
+ // 读取企业账户设置
|
|
|
+ data.is_enterprise_account = parsedSettings.openrouter_enterprise === true;
|
|
|
} catch (error) {
|
|
|
console.error('解析其他设置失败:', error);
|
|
|
data.azure_responses_version = '';
|
|
|
data.region = '';
|
|
|
data.vertex_key_type = 'json';
|
|
|
+ data.is_enterprise_account = false;
|
|
|
}
|
|
|
} else {
|
|
|
// 兼容历史数据:老渠道没有 settings 时,默认按 json 展示
|
|
|
data.vertex_key_type = 'json';
|
|
|
+ data.is_enterprise_account = false;
|
|
|
}
|
|
|
|
|
|
setInputs(data);
|
|
|
@@ -457,6 +464,8 @@ const EditChannelModal = (props) => {
|
|
|
} else {
|
|
|
setAutoBan(true);
|
|
|
}
|
|
|
+ // 同步企业账户状态
|
|
|
+ setIsEnterpriseAccount(data.is_enterprise_account || false);
|
|
|
setBasicModels(getChannelModels(data.type));
|
|
|
// 同步更新channelSettings状态显示
|
|
|
setChannelSettings({
|
|
|
@@ -716,6 +725,8 @@ const EditChannelModal = (props) => {
|
|
|
});
|
|
|
// 重置密钥模式状态
|
|
|
setKeyMode('append');
|
|
|
+ // 重置企业账户状态
|
|
|
+ setIsEnterpriseAccount(false);
|
|
|
// 清空表单中的key_mode字段
|
|
|
if (formApiRef.current) {
|
|
|
formApiRef.current.setValue('key_mode', undefined);
|
|
|
@@ -879,6 +890,21 @@ const EditChannelModal = (props) => {
|
|
|
};
|
|
|
localInputs.setting = JSON.stringify(channelExtraSettings);
|
|
|
|
|
|
+ // 处理type === 20的企业账户设置
|
|
|
+ if (localInputs.type === 20) {
|
|
|
+ let settings = {};
|
|
|
+ if (localInputs.settings) {
|
|
|
+ try {
|
|
|
+ settings = JSON.parse(localInputs.settings);
|
|
|
+ } catch (error) {
|
|
|
+ console.error('解析settings失败:', error);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 设置企业账户标识,无论是true还是false都要传到后端
|
|
|
+ settings.openrouter_enterprise = localInputs.is_enterprise_account === true;
|
|
|
+ localInputs.settings = JSON.stringify(settings);
|
|
|
+ }
|
|
|
+
|
|
|
// 清理不需要发送到后端的字段
|
|
|
delete localInputs.force_format;
|
|
|
delete localInputs.thinking_to_content;
|
|
|
@@ -886,6 +912,7 @@ const EditChannelModal = (props) => {
|
|
|
delete localInputs.pass_through_body_enabled;
|
|
|
delete localInputs.system_prompt;
|
|
|
delete localInputs.system_prompt_override;
|
|
|
+ delete localInputs.is_enterprise_account;
|
|
|
// 顶层的 vertex_key_type 不应发送给后端
|
|
|
delete localInputs.vertex_key_type;
|
|
|
|
|
|
@@ -1203,6 +1230,21 @@ const EditChannelModal = (props) => {
|
|
|
onChange={(value) => handleInputChange('type', value)}
|
|
|
/>
|
|
|
|
|
|
+ {inputs.type === 20 && (
|
|
|
+ <Form.Switch
|
|
|
+ field='is_enterprise_account'
|
|
|
+ label={t('是否为企业账户')}
|
|
|
+ checkedText={t('是')}
|
|
|
+ uncheckedText={t('否')}
|
|
|
+ onChange={(value) => {
|
|
|
+ setIsEnterpriseAccount(value);
|
|
|
+ handleInputChange('is_enterprise_account', value);
|
|
|
+ }}
|
|
|
+ extraText={t('企业账户为特殊返回格式,需要特殊处理,如果非企业账户,请勿勾选')}
|
|
|
+ initValue={inputs.is_enterprise_account}
|
|
|
+ />
|
|
|
+ )}
|
|
|
+
|
|
|
<Form.Input
|
|
|
field='name'
|
|
|
label={t('名称')}
|