fix: add warning for pass through body

This commit is contained in:
Seefs
2025-12-24 15:35:36 +08:00
parent 12555a37d3
commit 09f3957362
9 changed files with 113 additions and 4 deletions

View File

@@ -39,7 +39,11 @@ import {
showError,
} from '../../../helpers';
import { CHANNEL_OPTIONS } from '../../../constants';
import { IconTreeTriangleDown, IconMore } from '@douyinfe/semi-icons';
import {
IconTreeTriangleDown,
IconMore,
IconAlertTriangle,
} from '@douyinfe/semi-icons';
import { FaRandom } from 'react-icons/fa';
// Render functions
@@ -187,6 +191,28 @@ const renderResponseTime = (responseTime, t) => {
}
};
const isRequestPassThroughEnabled = (record) => {
if (!record || record.children !== undefined) {
return false;
}
const settingValue = record.setting;
if (!settingValue) {
return false;
}
if (typeof settingValue === 'object') {
return settingValue.pass_through_body_enabled === true;
}
if (typeof settingValue !== 'string') {
return false;
}
try {
const parsed = JSON.parse(settingValue);
return parsed?.pass_through_body_enabled === true;
} catch (error) {
return false;
}
};
export const getChannelsColumns = ({
t,
COLUMN_KEYS,
@@ -219,8 +245,9 @@ export const getChannelsColumns = ({
title: t('名称'),
dataIndex: 'name',
render: (text, record, index) => {
if (record.remark && record.remark.trim() !== '') {
return (
const passThroughEnabled = isRequestPassThroughEnabled(record);
const nameNode =
record.remark && record.remark.trim() !== '' ? (
<Tooltip
content={
<div className='flex flex-col gap-2 max-w-xs'>
@@ -250,9 +277,32 @@ export const getChannelsColumns = ({
>
<span>{text}</span>
</Tooltip>
) : (
<span>{text}</span>
);
if (!passThroughEnabled) {
return nameNode;
}
return text;
return (
<Space spacing={6} align='center'>
{nameNode}
<Tooltip
content={t(
'该渠道已开启请求透传:参数覆写、模型重定向、渠道适配等 NewAPI 内置功能将失效,非最佳实践;如因此产生问题,请勿提交 issue 反馈。',
)}
trigger='hover'
position='topLeft'
>
<span className='inline-flex items-center'>
<IconAlertTriangle
style={{ color: 'var(--semi-color-warning)' }}
/>
</span>
</Tooltip>
</Space>
);
},
},
{