merge: 合入总仓库 weiyuan(bfdfb339) web/ 新功能,保留 ui-optimization 的 UI 重构
来源:luoguang/monkey-ai weiyuan@bfdfb339 的 web/(经 sync/main-weiyuan-web-bfdfb339 同步)
同步基准:总仓库 a2ca13cb = 本仓库初始导入 d8f3aee2
冲突处理原则:保留 ui-optimization 的 UI(样式/结构/组件),嫁接 weiyuan 的功能逻辑。
- i18n:按键三方合并;ours 的「令牌→密钥」改名键上移植 theirs 的术语修订
- task-logs / OrgLogs:ours 已手工移植同一功能(6ad95e2),保留 ours
- 删除:OrgCreate(theirs 下线 /org/create)、旧 image 组件与 VideoRegenerateModal(theirs 体验中心重写)、
OrgAvatarSection / PricingBentoPage / CommissionConsole(ours 重构中已移除)
- 测试:users-pagination 的 i18next mock 补 t();theirs 新增文件补 license header
This commit is contained in:
@@ -225,7 +225,7 @@ const renderMultiKeyStatus = (status, keySize, enabledKeySize, t) => {
|
||||
|
||||
const renderResponseTime = (responseTime, t) => {
|
||||
let time = responseTime / 1000;
|
||||
time = time.toFixed(2) + t(' 秒');
|
||||
time = t('{{value}} 秒', { value: time.toFixed(2) });
|
||||
if (responseTime === 0) {
|
||||
return (
|
||||
<Tag color='grey' shape='circle'>
|
||||
@@ -497,9 +497,10 @@ export const getChannelsColumns = ({
|
||||
return (
|
||||
<div>
|
||||
<Tooltip
|
||||
content={
|
||||
t('原因:') + reason + t(',时间:') + timestamp2string(time)
|
||||
}
|
||||
content={t('原因:{{reason}},时间:{{time}}', {
|
||||
reason,
|
||||
time: timestamp2string(time),
|
||||
})}
|
||||
>
|
||||
{statusControl}
|
||||
</Tooltip>
|
||||
@@ -552,8 +553,10 @@ export const getChannelsColumns = ({
|
||||
<Tooltip
|
||||
content={
|
||||
isRoot()
|
||||
? t('剩余额度$') + record.balance + t(',点击更新')
|
||||
: t('剩余额度$') + record.balance
|
||||
? t('剩余额度${{balance}},点击更新', {
|
||||
balance: record.balance,
|
||||
})
|
||||
: t('剩余额度${{balance}}', { balance: record.balance })
|
||||
}
|
||||
>
|
||||
<Tag
|
||||
@@ -621,10 +624,9 @@ export const getChannelsColumns = ({
|
||||
onBlur={(e) => {
|
||||
Modal.warning({
|
||||
title: t('修改子渠道优先级'),
|
||||
content:
|
||||
t('确定要修改所有子渠道优先级为 ') +
|
||||
e.target.value +
|
||||
t(' 吗?'),
|
||||
content: t('确定要修改所有子渠道优先级为 {{value}} 吗?', {
|
||||
value: e.target.value,
|
||||
}),
|
||||
onOk: () => {
|
||||
if (e.target.value === '') {
|
||||
return;
|
||||
@@ -682,10 +684,9 @@ export const getChannelsColumns = ({
|
||||
onBlur={(e) => {
|
||||
Modal.warning({
|
||||
title: t('修改子渠道权重'),
|
||||
content:
|
||||
t('确定要修改所有子渠道权重为 ') +
|
||||
e.target.value +
|
||||
t(' 吗?'),
|
||||
content: t('确定要修改所有子渠道权重为 {{value}} 吗?', {
|
||||
value: e.target.value,
|
||||
}),
|
||||
onOk: () => {
|
||||
if (e.target.value === '') {
|
||||
return;
|
||||
|
||||
@@ -55,6 +55,7 @@ import {
|
||||
selectFilter,
|
||||
} from '../../../../helpers';
|
||||
import ModelSelectModal from './ModelSelectModal';
|
||||
import { mergeChannelSettings } from '../../../../helpers/baiduChannelSettings';
|
||||
import JSONEditor from '../../../common/ui/JSONEditor';
|
||||
import SecureVerificationModal from '../../../common/modals/SecureVerificationModal';
|
||||
import ChannelKeyDisplay from '../../../common/ui/ChannelKeyDisplay';
|
||||
@@ -168,6 +169,8 @@ const originInputs = {
|
||||
tag: '',
|
||||
multi_key_mode: 'random',
|
||||
// 渠道额外设置的默认值
|
||||
ali_data_inspection_disabled: false,
|
||||
baidu_liveness_header_mode: 'legacy',
|
||||
force_format: false,
|
||||
thinking_to_content: false,
|
||||
proxy: '',
|
||||
@@ -181,6 +184,10 @@ const originInputs = {
|
||||
client_type_restriction: [], // 客户端类型白名单(cli/vscode),仅 type=14 生效
|
||||
client_version_min: '', // 客户端版本下界(x.y.z),空=从最早
|
||||
client_version_max: '', // 客户端版本上界(x.y.z),空=至最新
|
||||
sticky_user_id_fill: false, // 为缺失的 metadata.user_id 补会话内稳定值,让上游按 user_id 哈希粘号
|
||||
sticky_user_id_mode: 'native', // 注入形态:native(仿 Claude Code 原生)/ opaque
|
||||
cache_breakpoint_fill: false, // 给完全没有 cache_control 的大上下文请求补一个缓存断点
|
||||
cache_breakpoint_min_tokens: 0, // 注入门限(估算 prompt token),0=用后端默认 10000
|
||||
settings: '',
|
||||
// 仅 Vertex: 密钥格式(存入 settings.vertex_key_type)
|
||||
vertex_key_type: 'json',
|
||||
@@ -407,6 +414,7 @@ const EditChannelModal = (props) => {
|
||||
|
||||
// 渠道额外设置状态
|
||||
const [channelSettings, setChannelSettings] = useState({
|
||||
ali_data_inspection_disabled: false,
|
||||
force_format: false,
|
||||
thinking_to_content: false,
|
||||
proxy: '',
|
||||
@@ -419,6 +427,10 @@ const EditChannelModal = (props) => {
|
||||
client_type_restriction: [],
|
||||
client_version_min: '',
|
||||
client_version_max: '',
|
||||
sticky_user_id_fill: false,
|
||||
sticky_user_id_mode: 'native',
|
||||
cache_breakpoint_fill: false,
|
||||
cache_breakpoint_min_tokens: 0,
|
||||
});
|
||||
const showApiConfigCard = true; // 控制是否显示 API 配置卡片
|
||||
const getInitValues = () => ({
|
||||
@@ -482,9 +494,10 @@ const EditChannelModal = (props) => {
|
||||
|
||||
if (name === 'base_url' && value.endsWith('/v1')) {
|
||||
Modal.confirm({
|
||||
title: '警告',
|
||||
content:
|
||||
title: t('警告'),
|
||||
content: t(
|
||||
'不需要在末尾加/v1,New API会自动处理,添加后可能导致请求失败,是否继续?',
|
||||
),
|
||||
onOk: () => {
|
||||
setInputs((inputs) => ({ ...inputs, [name]: value }));
|
||||
},
|
||||
@@ -592,9 +605,14 @@ const EditChannelModal = (props) => {
|
||||
setMultiToSingle(false);
|
||||
}
|
||||
// 解析渠道额外设置并合并到data中
|
||||
data.baidu_liveness_header_mode = 'legacy';
|
||||
if (data.setting) {
|
||||
try {
|
||||
const parsedSettings = JSON.parse(data.setting);
|
||||
data.baidu_liveness_header_mode =
|
||||
parsedSettings.baidu_liveness_header_mode ?? 'legacy';
|
||||
data.ali_data_inspection_disabled =
|
||||
parsedSettings.ali_data_inspection_disabled === true;
|
||||
data.force_format = parsedSettings.force_format || false;
|
||||
data.thinking_to_content =
|
||||
parsedSettings.thinking_to_content || false;
|
||||
@@ -618,9 +636,18 @@ const EditChannelModal = (props) => {
|
||||
: [];
|
||||
data.client_version_min = parsedSettings.client_version_min || '';
|
||||
data.client_version_max = parsedSettings.client_version_max || '';
|
||||
data.sticky_user_id_fill =
|
||||
parsedSettings.sticky_user_id_fill || false;
|
||||
data.sticky_user_id_mode =
|
||||
parsedSettings.sticky_user_id_mode || 'native';
|
||||
data.cache_breakpoint_fill =
|
||||
parsedSettings.cache_breakpoint_fill || false;
|
||||
data.cache_breakpoint_min_tokens =
|
||||
parsedSettings.cache_breakpoint_min_tokens || 0;
|
||||
} catch (error) {
|
||||
console.error('解析渠道设置失败:', error);
|
||||
data.force_format = false;
|
||||
data.ali_data_inspection_disabled = false;
|
||||
data.thinking_to_content = false;
|
||||
data.proxy = '';
|
||||
data.pass_through_body_enabled = false;
|
||||
@@ -633,9 +660,14 @@ const EditChannelModal = (props) => {
|
||||
data.client_type_restriction = [];
|
||||
data.client_version_min = '';
|
||||
data.client_version_max = '';
|
||||
data.sticky_user_id_fill = false;
|
||||
data.sticky_user_id_mode = 'native';
|
||||
data.cache_breakpoint_fill = false;
|
||||
data.cache_breakpoint_min_tokens = 0;
|
||||
}
|
||||
} else {
|
||||
data.force_format = false;
|
||||
data.ali_data_inspection_disabled = false;
|
||||
data.thinking_to_content = false;
|
||||
data.proxy = '';
|
||||
data.pass_through_body_enabled = false;
|
||||
@@ -648,6 +680,10 @@ const EditChannelModal = (props) => {
|
||||
data.client_type_restriction = [];
|
||||
data.client_version_min = '';
|
||||
data.client_version_max = '';
|
||||
data.sticky_user_id_fill = false;
|
||||
data.sticky_user_id_mode = 'native';
|
||||
data.cache_breakpoint_fill = false;
|
||||
data.cache_breakpoint_min_tokens = 0;
|
||||
}
|
||||
|
||||
if (data.settings) {
|
||||
@@ -744,6 +780,8 @@ const EditChannelModal = (props) => {
|
||||
setBasicModels(getChannelModels(data.type));
|
||||
// 同步更新channelSettings状态显示
|
||||
setChannelSettings({
|
||||
ali_data_inspection_disabled:
|
||||
data.ali_data_inspection_disabled === true,
|
||||
force_format: data.force_format,
|
||||
thinking_to_content: data.thinking_to_content,
|
||||
proxy: data.proxy,
|
||||
@@ -762,6 +800,10 @@ const EditChannelModal = (props) => {
|
||||
: [],
|
||||
client_version_min: data.client_version_min || '',
|
||||
client_version_max: data.client_version_max || '',
|
||||
sticky_user_id_fill: data.sticky_user_id_fill || false,
|
||||
sticky_user_id_mode: data.sticky_user_id_mode || 'native',
|
||||
cache_breakpoint_fill: data.cache_breakpoint_fill || false,
|
||||
cache_breakpoint_min_tokens: data.cache_breakpoint_min_tokens || 0,
|
||||
});
|
||||
initialModelsRef.current = (data.models || [])
|
||||
.map((model) => (model || '').trim())
|
||||
@@ -1018,6 +1060,7 @@ const EditChannelModal = (props) => {
|
||||
formApiRef.current?.reset();
|
||||
// 重置渠道设置状态
|
||||
setChannelSettings({
|
||||
ali_data_inspection_disabled: false,
|
||||
force_format: false,
|
||||
thinking_to_content: false,
|
||||
proxy: '',
|
||||
@@ -1031,6 +1074,10 @@ const EditChannelModal = (props) => {
|
||||
client_type_restriction: [],
|
||||
client_version_min: '',
|
||||
client_version_max: '',
|
||||
sticky_user_id_fill: false,
|
||||
sticky_user_id_mode: 'native',
|
||||
cache_breakpoint_fill: false,
|
||||
cache_breakpoint_min_tokens: 0,
|
||||
});
|
||||
// 重置密钥模式状态
|
||||
setKeyMode('append');
|
||||
@@ -1339,6 +1386,8 @@ const EditChannelModal = (props) => {
|
||||
|
||||
// 生成渠道额外设置JSON
|
||||
const channelExtraSettings = {
|
||||
ali_data_inspection_disabled:
|
||||
localInputs.ali_data_inspection_disabled === true,
|
||||
force_format: localInputs.force_format || false,
|
||||
thinking_to_content: localInputs.thinking_to_content || false,
|
||||
proxy: localInputs.proxy || '',
|
||||
@@ -1363,8 +1412,31 @@ const EditChannelModal = (props) => {
|
||||
: [],
|
||||
client_version_min: (localInputs.client_version_min || '').trim(),
|
||||
client_version_max: (localInputs.client_version_max || '').trim(),
|
||||
sticky_user_id_fill: localInputs.sticky_user_id_fill || false,
|
||||
sticky_user_id_mode: ['native', 'opaque'].includes(
|
||||
localInputs.sticky_user_id_mode,
|
||||
)
|
||||
? localInputs.sticky_user_id_mode
|
||||
: 'native',
|
||||
cache_breakpoint_fill: localInputs.cache_breakpoint_fill || false,
|
||||
// 0 = 用后端默认(10000)。负数按 0 处理,低于 1024 的值后端会自己抬到 1024
|
||||
// (1024 是 opus/sonnet 的最小可缓存前缀,再小注入了也产不出缓存)。
|
||||
cache_breakpoint_min_tokens: Math.max(
|
||||
0,
|
||||
parseInt(localInputs.cache_breakpoint_min_tokens, 10) || 0,
|
||||
),
|
||||
};
|
||||
localInputs.setting = JSON.stringify(channelExtraSettings);
|
||||
try {
|
||||
localInputs.setting = mergeChannelSettings(
|
||||
inputs.setting,
|
||||
channelExtraSettings,
|
||||
localInputs.type,
|
||||
localInputs.baidu_liveness_header_mode,
|
||||
);
|
||||
} catch (error) {
|
||||
showError(error.message);
|
||||
return;
|
||||
}
|
||||
|
||||
// 处理 settings 字段(包括企业账户设置和字段透传控制)
|
||||
let settings = {};
|
||||
@@ -1409,6 +1481,7 @@ const EditChannelModal = (props) => {
|
||||
|
||||
// 清理不需要发送到后端的字段
|
||||
delete localInputs.force_format;
|
||||
delete localInputs.ali_data_inspection_disabled;
|
||||
delete localInputs.thinking_to_content;
|
||||
delete localInputs.proxy;
|
||||
delete localInputs.pass_through_body_enabled;
|
||||
@@ -1418,6 +1491,10 @@ const EditChannelModal = (props) => {
|
||||
delete localInputs.client_type_restriction;
|
||||
delete localInputs.client_version_min;
|
||||
delete localInputs.client_version_max;
|
||||
delete localInputs.sticky_user_id_fill;
|
||||
delete localInputs.sticky_user_id_mode;
|
||||
delete localInputs.cache_breakpoint_fill;
|
||||
delete localInputs.cache_breakpoint_min_tokens;
|
||||
delete localInputs.system_prompt;
|
||||
delete localInputs.system_prompt_override;
|
||||
delete localInputs.is_enterprise_account;
|
||||
@@ -1481,11 +1558,18 @@ const EditChannelModal = (props) => {
|
||||
}
|
||||
|
||||
if (isEdit) {
|
||||
res = await API.put(`/api/channel/`, {
|
||||
...localInputs,
|
||||
id: parseInt(channelId),
|
||||
key_mode: isMultiKeyChannel ? keyMode : undefined, // 只在多key模式下传递
|
||||
});
|
||||
res = await API.put(
|
||||
`/api/channel/`,
|
||||
{
|
||||
...localInputs,
|
||||
id: parseInt(channelId),
|
||||
key_mode: isMultiKeyChannel ? keyMode : undefined, // 只在多key模式下传递
|
||||
},
|
||||
{
|
||||
validateStatus: (status) =>
|
||||
(status >= 200 && status < 300) || status === 409,
|
||||
},
|
||||
);
|
||||
} else {
|
||||
res = await API.post(`/api/channel/`, {
|
||||
mode: mode,
|
||||
@@ -1699,7 +1783,8 @@ const EditChannelModal = (props) => {
|
||||
// 保持 label 为纯文本以支持搜索
|
||||
label: opt.label,
|
||||
})),
|
||||
[],
|
||||
// label 是按当前语言取值的 getter,切换语言后需重建
|
||||
[t],
|
||||
);
|
||||
|
||||
const renderChannelOption = (renderProps) => {
|
||||
@@ -2259,9 +2344,9 @@ const EditChannelModal = (props) => {
|
||||
<Form.Input
|
||||
field='other'
|
||||
label={t('模型版本')}
|
||||
placeholder={
|
||||
'请输入星火大模型版本,注意是接口地址中的版本号,例如:v2.1'
|
||||
}
|
||||
placeholder={t(
|
||||
'请输入星火大模型版本,注意是接口地址中的版本号,例如:v2.1',
|
||||
)}
|
||||
onChange={(value) => handleInputChange('other', value)}
|
||||
showClear
|
||||
/>
|
||||
@@ -2292,7 +2377,7 @@ const EditChannelModal = (props) => {
|
||||
<Form.Input
|
||||
field='other'
|
||||
label={t('知识库 ID')}
|
||||
placeholder={'请输入知识库 ID,例如:123456'}
|
||||
placeholder={t('请输入知识库 ID,例如:123456')}
|
||||
onChange={(value) => handleInputChange('other', value)}
|
||||
showClear
|
||||
/>
|
||||
@@ -2302,9 +2387,9 @@ const EditChannelModal = (props) => {
|
||||
<Form.Input
|
||||
field='other'
|
||||
label='Account ID'
|
||||
placeholder={
|
||||
'请输入Account ID,例如:d6b5da8hk1awo8nap34ube6gh'
|
||||
}
|
||||
placeholder={t(
|
||||
'请输入Account ID,例如:d6b5da8hk1awo8nap34ube6gh',
|
||||
)}
|
||||
onChange={(value) => handleInputChange('other', value)}
|
||||
showClear
|
||||
/>
|
||||
@@ -2314,7 +2399,7 @@ const EditChannelModal = (props) => {
|
||||
<Form.Input
|
||||
field='other'
|
||||
label={t('智能体ID')}
|
||||
placeholder={'请输入智能体ID,例如:7342866812345'}
|
||||
placeholder={t('请输入智能体ID,例如:7342866812345')}
|
||||
onChange={(value) => handleInputChange('other', value)}
|
||||
showClear
|
||||
/>
|
||||
@@ -3319,6 +3404,50 @@ const EditChannelModal = (props) => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{inputs.type === 17 && (
|
||||
<Form.Switch
|
||||
field='ali_data_inspection_disabled'
|
||||
label={t('阿里云关闭输入/输出绿网(DataInspection)')}
|
||||
checkedText={t('开')}
|
||||
uncheckedText={t('关')}
|
||||
onChange={(value) =>
|
||||
handleChannelSettingsChange(
|
||||
'ali_data_inspection_disabled',
|
||||
value,
|
||||
)
|
||||
}
|
||||
extraText={t(
|
||||
'关闭阿里云输入和输出内容安全检测。需要上游权限,生产前请先使用测试 Key 验证;默认关闭。',
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{inputs.type === 62 && (
|
||||
<Form.Select
|
||||
field='baidu_liveness_header_mode'
|
||||
label={t('百度真人素材请求头模式')}
|
||||
optionList={[
|
||||
{
|
||||
label: t('兼容模式(默认,发送真人请求头)'),
|
||||
value: 'legacy',
|
||||
},
|
||||
{
|
||||
label: t('不发送(供应商明确要求时选择)'),
|
||||
value: 'omit',
|
||||
},
|
||||
]}
|
||||
onChange={(value) =>
|
||||
handleChannelSettingsChange(
|
||||
'baidu_liveness_header_mode',
|
||||
value,
|
||||
)
|
||||
}
|
||||
extraText={t(
|
||||
'根据供应商账号要求选择,与模型名称无关。已有认证、素材或未完成操作的渠道不能切换,请新建独立渠道。',
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{inputs.type === 1 && (
|
||||
<Form.Switch
|
||||
field='force_format'
|
||||
@@ -3546,6 +3675,85 @@ const EditChannelModal = (props) => {
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className='mt-4 mb-2 text-sm font-medium text-gray-700'>
|
||||
{t('上游缓存优化(仅 Claude 原生渠道生效)')}
|
||||
</div>
|
||||
|
||||
<Form.Switch
|
||||
field='sticky_user_id_fill'
|
||||
label={t('会话粘性 user_id 填充')}
|
||||
checkedText={t('开')}
|
||||
uncheckedText={t('关')}
|
||||
onChange={(value) =>
|
||||
handleChannelSettingsChange(
|
||||
'sticky_user_id_fill',
|
||||
value,
|
||||
)
|
||||
}
|
||||
extraText={t(
|
||||
'为缺失 metadata.user_id 的请求补一个「会话内稳定」的值,使按 user_id 哈希选号的上游把同一会话粘在同一账号上。仅对已确认按 user_id 粘号的上游开启。',
|
||||
)}
|
||||
/>
|
||||
|
||||
<Form.Select
|
||||
field='sticky_user_id_mode'
|
||||
label={t('粘性 user_id 形态')}
|
||||
style={{ width: '100%' }}
|
||||
optionList={[
|
||||
{
|
||||
label: t('native(仿 Claude Code 原生)'),
|
||||
value: 'native',
|
||||
},
|
||||
{
|
||||
label: t('opaque(wl_ 前缀不透明串)'),
|
||||
value: 'opaque',
|
||||
},
|
||||
]}
|
||||
onChange={(value) =>
|
||||
handleChannelSettingsChange(
|
||||
'sticky_user_id_mode',
|
||||
value,
|
||||
)
|
||||
}
|
||||
extraText={t(
|
||||
'上游只做哈希,形态不影响路由;native 可避免上游按形态做白名单校验时被判成异常客户端。',
|
||||
)}
|
||||
/>
|
||||
|
||||
<Form.Switch
|
||||
field='cache_breakpoint_fill'
|
||||
label={t('缓存断点注入')}
|
||||
checkedText={t('开')}
|
||||
uncheckedText={t('关')}
|
||||
onChange={(value) =>
|
||||
handleChannelSettingsChange(
|
||||
'cache_breakpoint_fill',
|
||||
value,
|
||||
)
|
||||
}
|
||||
extraText={t(
|
||||
'给「一个 cache_control 都没有」的大上下文请求补一个缓存断点。必须同时开启上面的会话粘性填充,否则注入后每轮哈希到不同账号、只写不读,按 1h 档成本直接翻倍(未开粘性时后端会拒绝注入并记 no_sticky)。',
|
||||
)}
|
||||
/>
|
||||
|
||||
<Form.InputNumber
|
||||
field='cache_breakpoint_min_tokens'
|
||||
label={t('缓存断点注入门限(prompt token)')}
|
||||
placeholder={t('0 = 用默认值 10000')}
|
||||
min={0}
|
||||
step={1000}
|
||||
style={{ width: '100%' }}
|
||||
onChange={(value) =>
|
||||
handleChannelSettingsChange(
|
||||
'cache_breakpoint_min_tokens',
|
||||
value,
|
||||
)
|
||||
}
|
||||
extraText={t(
|
||||
'低于该输入规模的请求不注入。门限越低覆盖越广但边际收益递减:≥50000 覆盖 2.7%、≥10000 覆盖 7.7%、≥2000 覆盖 21.4%。0 = 用后端默认 10000;小于 1024(最小可缓存前缀)时后端自动抬到 1024。',
|
||||
)}
|
||||
/>
|
||||
|
||||
<Form.Input
|
||||
field='proxy'
|
||||
label={t('代理地址')}
|
||||
|
||||
@@ -198,13 +198,13 @@ const EditTagModal = (props) => {
|
||||
formVals.param_override !== null
|
||||
) {
|
||||
if (typeof formVals.param_override !== 'string') {
|
||||
showInfo('参数覆盖必须是合法的 JSON 格式!');
|
||||
showInfo(t('参数覆盖必须是合法的 JSON 格式!'));
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
const trimmedParamOverride = formVals.param_override.trim();
|
||||
if (trimmedParamOverride !== '' && !verifyJSON(trimmedParamOverride)) {
|
||||
showInfo('参数覆盖必须是合法的 JSON 格式!');
|
||||
showInfo(t('参数覆盖必须是合法的 JSON 格式!'));
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
@@ -215,13 +215,13 @@ const EditTagModal = (props) => {
|
||||
formVals.header_override !== null
|
||||
) {
|
||||
if (typeof formVals.header_override !== 'string') {
|
||||
showInfo('请求头覆盖必须是合法的 JSON 格式!');
|
||||
showInfo(t('请求头覆盖必须是合法的 JSON 格式!'));
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
const trimmedHeaderOverride = formVals.header_override.trim();
|
||||
if (trimmedHeaderOverride !== '' && !verifyJSON(trimmedHeaderOverride)) {
|
||||
showInfo('请求头覆盖必须是合法的 JSON 格式!');
|
||||
showInfo(t('请求头覆盖必须是合法的 JSON 格式!'));
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -80,10 +80,10 @@ const ModelTestModal = ({
|
||||
copy(selectedModelKeys.join(',')).then((ok) => {
|
||||
if (ok) {
|
||||
showSuccess(
|
||||
t('已复制 ${count} 个模型').replace(
|
||||
'${count}',
|
||||
selectedModelKeys.length,
|
||||
),
|
||||
t('已复制 {{n}} 个模型', {
|
||||
n: selectedModelKeys.length,
|
||||
count: selectedModelKeys.length,
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
showError(t('复制失败,请手动复制'));
|
||||
@@ -139,10 +139,9 @@ const ModelTestModal = ({
|
||||
</Tag>
|
||||
{testResult.success && (
|
||||
<Typography.Text type='secondary'>
|
||||
{t('请求时长: ${time}s').replace(
|
||||
'${time}',
|
||||
testResult.time.toFixed(2),
|
||||
)}
|
||||
{t('请求时长: {{time}}s', {
|
||||
time: testResult.time.toFixed(2),
|
||||
})}
|
||||
</Typography.Text>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -232,14 +232,14 @@ const MarketCatalog = ({
|
||||
{filtersOpen ? t('收起筛选') : t('筛选')}
|
||||
</Button>
|
||||
</div>
|
||||
{/* 企业作用域计价口径提示:标价含企业等级折扣,个人密钥/体验中心调用仍按个人等级计费 */}
|
||||
{/* 企业等级计价提示:用户属于企业时,不论以何身份登录,标价与扣费都按企业等级折扣 */}
|
||||
{discountScope === 'enterprise' && !hidePrice && (
|
||||
<Alert
|
||||
className='mm-scope-alert'
|
||||
type='warning'
|
||||
showIcon
|
||||
message={t(
|
||||
'当前为企业作用域:以下价格已按企业等级折扣展示;使用个人密钥或体验中心调用时按个人等级计费。',
|
||||
'以下价格已按所属企业的等级折扣展示;企业成员使用个人密钥或体验中心调用时同样按企业等级计费。',
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -93,7 +93,8 @@ const renderCategories = (categories, t, categoryNames) => {
|
||||
return renderLimitedItems({
|
||||
items: categoriesArray,
|
||||
renderItem: (category, idx) => {
|
||||
const categoryName = categoryNames[category] || category;
|
||||
// 分类名按当前语言翻译;后端自定义分类名无对应键时原样展示
|
||||
const categoryName = t(categoryNames[category] || category);
|
||||
return (
|
||||
<Tag
|
||||
key={idx}
|
||||
@@ -312,7 +313,11 @@ const renderNameRule = (rule, record, t) => {
|
||||
|
||||
let label = cfg.label;
|
||||
if (rule !== 0 && record.matched_count) {
|
||||
label = `${cfg.label} ${record.matched_count}${t('个模型')}`;
|
||||
label = t('{{rule}} {{n}} 个模型', {
|
||||
rule: cfg.label,
|
||||
n: record.matched_count,
|
||||
count: record.matched_count,
|
||||
});
|
||||
}
|
||||
|
||||
const tagElement = (
|
||||
|
||||
@@ -169,13 +169,17 @@ const renderTimestamp = (timestampInSeconds) => {
|
||||
);
|
||||
};
|
||||
|
||||
function renderDuration(submit_time, finishTime) {
|
||||
function renderDuration(submit_time, finishTime, t) {
|
||||
if (!submit_time || !finishTime) return '-';
|
||||
const durationSec = finishTime - submit_time;
|
||||
const colorKey = durationSec > 60 ? 'red' : 'green';
|
||||
|
||||
return (
|
||||
<CustomTag icon={Timer} label={`${durationSec} 秒`} colorKey={colorKey} />
|
||||
<CustomTag
|
||||
icon={Timer}
|
||||
label={t('{{n}} 秒', { n: durationSec })}
|
||||
colorKey={colorKey}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -419,7 +423,9 @@ export const getTaskLogsColumns = ({
|
||||
title: t('花费时间'),
|
||||
dataIndex: 'finish_time',
|
||||
render: (finish, record) => {
|
||||
return <>{finish ? renderDuration(record.submit_time, finish) : '-'}</>;
|
||||
return (
|
||||
<>{finish ? renderDuration(record.submit_time, finish, t) : '-'}</>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -394,6 +394,7 @@ const EditTokenModal = (props) => {
|
||||
}
|
||||
if (successCount > 0) {
|
||||
showSuccess(t('密钥创建成功,请在列表页面点击复制获取密钥!'));
|
||||
props.onCreated?.(successCount);
|
||||
props.refresh();
|
||||
props.handleClose();
|
||||
}
|
||||
|
||||
@@ -782,7 +782,7 @@ export const getLogsColumns = ({
|
||||
if (!(record.type === 2 || record.type === 5)) {
|
||||
return <></>;
|
||||
}
|
||||
let content = t('渠道') + `:${record.channel}`;
|
||||
let content = t('渠道:{{channel}}', { channel: record.channel });
|
||||
if (record.other !== '') {
|
||||
let other = JSON.parse(record.other);
|
||||
if (other === null) {
|
||||
@@ -796,7 +796,7 @@ export const getLogsColumns = ({
|
||||
) {
|
||||
let useChannel = other.admin_info.use_channel;
|
||||
let useChannelStr = useChannel.join('->');
|
||||
content = t('渠道') + `:${useChannelStr}`;
|
||||
content = t('渠道:{{channel}}', { channel: useChannelStr });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,6 +121,9 @@ const UsageBillingDetail = ({
|
||||
Number(other.cache_creation_tokens_5m || 0) +
|
||||
Number(other.cache_creation_tokens_1h || 0);
|
||||
const textTokens = inputTokens + outputTokens;
|
||||
// 有 5m/1h 分档时只展示分档,不再重复展示未分档的总量与倍率
|
||||
const hasSplitCacheCreation =
|
||||
other.cache_creation_tokens_5m > 0 || other.cache_creation_tokens_1h > 0;
|
||||
const effectiveGroupRatio =
|
||||
Number.isFinite(Number(other.user_group_ratio)) &&
|
||||
Number(other.user_group_ratio) !== -1
|
||||
@@ -134,10 +137,11 @@ const UsageBillingDetail = ({
|
||||
label: t('缓存命中'),
|
||||
value: formatCount(other.cache_tokens),
|
||||
},
|
||||
other.cache_creation_tokens > 0 && {
|
||||
label: t('缓存创建'),
|
||||
value: formatCount(other.cache_creation_tokens),
|
||||
},
|
||||
!hasSplitCacheCreation &&
|
||||
other.cache_creation_tokens > 0 && {
|
||||
label: t('缓存创建'),
|
||||
value: formatCount(other.cache_creation_tokens),
|
||||
},
|
||||
other.cache_creation_tokens_5m > 0 && {
|
||||
label: t('5m 缓存创建'),
|
||||
value: formatCount(other.cache_creation_tokens_5m),
|
||||
@@ -159,7 +163,8 @@ const UsageBillingDetail = ({
|
||||
label: t('缓存倍率'),
|
||||
value: formatRatio(other.cache_ratio),
|
||||
},
|
||||
other.cache_creation_ratio != null &&
|
||||
!hasSplitCacheCreation &&
|
||||
other.cache_creation_ratio != null &&
|
||||
other.cache_creation_tokens > 0 && {
|
||||
label: t('缓存创建倍率'),
|
||||
value: formatRatio(other.cache_creation_ratio),
|
||||
@@ -207,11 +212,17 @@ const UsageBillingDetail = ({
|
||||
},
|
||||
other.web_search && {
|
||||
label: t('联网搜索'),
|
||||
value: `${formatCount(other.web_search_call_count || 0)} ${t('次')}`,
|
||||
value: t('{{n}} 次', {
|
||||
n: formatCount(other.web_search_call_count || 0),
|
||||
count: other.web_search_call_count || 0,
|
||||
}),
|
||||
},
|
||||
other.file_search && {
|
||||
label: t('文件搜索'),
|
||||
value: `${formatCount(other.file_search_call_count || 0)} ${t('次')}`,
|
||||
value: t('{{n}} 次', {
|
||||
n: formatCount(other.file_search_call_count || 0),
|
||||
count: other.file_search_call_count || 0,
|
||||
}),
|
||||
},
|
||||
other.image_generation_call && {
|
||||
label: t('图片生成'),
|
||||
|
||||
@@ -329,8 +329,8 @@ const UsageLogsExportModal = ({
|
||||
</RadioGroup>
|
||||
<div className='text-xs text-gray-500 dark:text-gray-400 mt-2'>
|
||||
{scope === 'page'
|
||||
? t('本次将导出当前页 {{n}} 条', { n: pageCount })
|
||||
: t('本次将导出约 {{n}} 条', { n: logCount })}
|
||||
? t('本次将导出当前页 {{n}} 条', { n: pageCount, count: pageCount })
|
||||
: t('本次将导出约 {{n}} 条', { n: logCount, count: logCount })}
|
||||
{scope === 'all' && logCount > EXPORT_LIMIT && (
|
||||
<span className='text-amber-600 dark:text-amber-400'>
|
||||
{' '}
|
||||
|
||||
Reference in New Issue
Block a user