sync: 同步总仓库 luoguang/monkey-ai weiyuan@bfdfb339 的 web/ 改动
同步基准:总仓库 a2ca13cb(= 本仓库初始导入 d8f3aee2) 范围:a2ca13cb..bfdfb339 中触及 web/ 的提交(不含 web/.claude/settings.local.json) - 8490ac02 feat(aliyun): integrate Wan 3 and Qwen Image models - 2aff08ec perf(analytics): 运营看板概览改读汇总表,首屏从 19s 降到 0.4s - dc69335e feat(experience): 体验中心图像/视频创作升级(能力 schema、估价、新创作台) - b059c657 fix(org): 下线 /org/create 自助加入企业页与 POST /api/org/join - 4fcf47e6 fix(i18n): 修复中/英/韩/繁体多语言错乱,补齐日/越/泰译文 - e4c301d5 fix: merge enterprise task record date filters - c9369b95 feat: expose enterprise image and video task records - a410fee5 feat(claude): 无断点请求自动注入 cache_control 断点(方案 2) - 521b3376 feat(claude): 缓存命中率优化——上游粘性路由 + 缓存时长强制改写 - 73b615dd feat(pricing): 企业成员不论登录身份均按所属企业等级计价与扣费 - f73f55c3 feat(client): 新增 WeyAi 版本说明管理与公开读取接口 - 8cdf1994 fix(topup): reset amount when switching from PayPal - 93a4ac34 feat(baidu): configure Seedance liveness header by channel - cb1818c5 fix(weyai): 按评审修正内容清理竞态、默认适用端与中文退回(M21) - 04214d83 feat(weyai): WeyAi 内容管理与客户端内容接口(M21 第二部分) - e3c4a57c feat(weyai): 设置页新增 WeyAi 页签与内容专用 COS 桶(M21 第一部分) - b5ee8e70 fix(auth): 会话角色/状态以 DB 为准,修复提升管理员后管理接口报权限不足 - e4618fc2 fix: 修复企业看板日志聚合死循环导致 CPU 打满,并降低看板查询开销 - 584aad52 style(web): 个人中心侧边栏按 prettier 换行 - b8d87064 fix: 小程序教程隐藏充值后保留原步骤编号,企业充值判断直接用 isMiniProgramWebView - eee7f5b2 fix: 小程序里企业首页不落到充值页,隐藏钱包入口与教程充值步骤 - 8b254d49 fix: 小程序里隐藏企业充值入口与页面 - a67661b4 fix(web): 小程序里个人中心默认页跳过充值和发票,避免来回跳转 - cff6c543 feat(web): WeyAi 小程序里打开个人中心时不出现充值和开票 - c6c99eb6 feat(billing): Claude 全部缓存写入统一按 1h 倍率计费 - 0699d1bf fix(web): 小程序 web-view 里注册页同样只显示站内方式 - 04853331 feat(web): WeyAi 小程序 web-view 里登录页只显示站内登录方式
This commit is contained in:
@@ -195,7 +195,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'>
|
||||
@@ -435,9 +435,10 @@ export const getChannelsColumns = ({
|
||||
return (
|
||||
<div>
|
||||
<Tooltip
|
||||
content={
|
||||
t('原因:') + reason + t(',时间:') + timestamp2string(time)
|
||||
}
|
||||
content={t('原因:{{reason}},时间:{{time}}', {
|
||||
reason,
|
||||
time: timestamp2string(time),
|
||||
})}
|
||||
>
|
||||
{renderStatus(text, record.channel_info, t)}
|
||||
</Tooltip>
|
||||
@@ -490,8 +491,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
|
||||
@@ -559,10 +562,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;
|
||||
@@ -620,10 +622,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;
|
||||
|
||||
@@ -54,6 +54,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';
|
||||
@@ -171,6 +172,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: '',
|
||||
@@ -184,6 +187,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',
|
||||
@@ -464,6 +471,7 @@ const EditChannelModal = (props) => {
|
||||
|
||||
// 渠道额外设置状态
|
||||
const [channelSettings, setChannelSettings] = useState({
|
||||
ali_data_inspection_disabled: false,
|
||||
force_format: false,
|
||||
thinking_to_content: false,
|
||||
proxy: '',
|
||||
@@ -476,6 +484,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 = () => ({
|
||||
@@ -539,9 +551,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 }));
|
||||
},
|
||||
@@ -649,9 +662,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;
|
||||
@@ -675,9 +693,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;
|
||||
@@ -690,9 +717,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;
|
||||
@@ -705,6 +737,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) {
|
||||
@@ -801,6 +837,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,
|
||||
@@ -819,6 +857,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())
|
||||
@@ -1077,6 +1119,7 @@ const EditChannelModal = (props) => {
|
||||
formApiRef.current?.reset();
|
||||
// 重置渠道设置状态
|
||||
setChannelSettings({
|
||||
ali_data_inspection_disabled: false,
|
||||
force_format: false,
|
||||
thinking_to_content: false,
|
||||
proxy: '',
|
||||
@@ -1090,6 +1133,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');
|
||||
@@ -1398,6 +1445,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 || '',
|
||||
@@ -1422,8 +1471,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 = {};
|
||||
@@ -1468,6 +1540,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;
|
||||
@@ -1477,6 +1550,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;
|
||||
@@ -1540,11 +1617,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,
|
||||
@@ -1758,7 +1842,8 @@ const EditChannelModal = (props) => {
|
||||
// 保持 label 为纯文本以支持搜索
|
||||
label: opt.label,
|
||||
})),
|
||||
[],
|
||||
// label 是按当前语言取值的 getter,切换语言后需重建
|
||||
[t],
|
||||
);
|
||||
|
||||
const renderChannelOption = (renderProps) => {
|
||||
@@ -2373,9 +2458,9 @@ const EditChannelModal = (props) => {
|
||||
<Form.Input
|
||||
field='other'
|
||||
label={t('模型版本')}
|
||||
placeholder={
|
||||
'请输入星火大模型版本,注意是接口地址中的版本号,例如:v2.1'
|
||||
}
|
||||
placeholder={t(
|
||||
'请输入星火大模型版本,注意是接口地址中的版本号,例如:v2.1',
|
||||
)}
|
||||
onChange={(value) => handleInputChange('other', value)}
|
||||
showClear
|
||||
/>
|
||||
@@ -2406,7 +2491,7 @@ const EditChannelModal = (props) => {
|
||||
<Form.Input
|
||||
field='other'
|
||||
label={t('知识库 ID')}
|
||||
placeholder={'请输入知识库 ID,例如:123456'}
|
||||
placeholder={t('请输入知识库 ID,例如:123456')}
|
||||
onChange={(value) => handleInputChange('other', value)}
|
||||
showClear
|
||||
/>
|
||||
@@ -2416,9 +2501,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
|
||||
/>
|
||||
@@ -2428,7 +2513,7 @@ const EditChannelModal = (props) => {
|
||||
<Form.Input
|
||||
field='other'
|
||||
label={t('智能体ID')}
|
||||
placeholder={'请输入智能体ID,例如:7342866812345'}
|
||||
placeholder={t('请输入智能体ID,例如:7342866812345')}
|
||||
onChange={(value) => handleInputChange('other', value)}
|
||||
showClear
|
||||
/>
|
||||
@@ -3454,6 +3539,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'
|
||||
@@ -3681,6 +3810,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;
|
||||
}
|
||||
|
||||
@@ -86,12 +86,7 @@ const ModelTestModal = ({
|
||||
}
|
||||
copy(selectedModelKeys.join(',')).then((ok) => {
|
||||
if (ok) {
|
||||
showSuccess(
|
||||
t('已复制 ${count} 个模型').replace(
|
||||
'${count}',
|
||||
selectedModelKeys.length,
|
||||
),
|
||||
);
|
||||
showSuccess(t('已复制 {{n}} 个模型', { n: selectedModelKeys.length, count: selectedModelKeys.length }));
|
||||
} else {
|
||||
showError(t('复制失败,请手动复制'));
|
||||
}
|
||||
@@ -154,10 +149,9 @@ const ModelTestModal = ({
|
||||
</Tag>
|
||||
{testResult.success && (
|
||||
<Typography.Text type='tertiary'>
|
||||
{t('请求时长: ${time}s').replace(
|
||||
'${time}',
|
||||
testResult.time.toFixed(2),
|
||||
)}
|
||||
{t('请求时长: {{time}}s', {
|
||||
time: testResult.time.toFixed(2),
|
||||
})}
|
||||
</Typography.Text>
|
||||
)}
|
||||
</div>
|
||||
@@ -240,10 +234,7 @@ const ModelTestModal = ({
|
||||
>
|
||||
{isBatchTesting
|
||||
? t('测试中...')
|
||||
: t('批量测试${count}个模型').replace(
|
||||
'${count}',
|
||||
filteredModels.length,
|
||||
)}
|
||||
: t('批量测试 {{n}} 个模型', { n: filteredModels.length, count: filteredModels.length })}
|
||||
</Button>
|
||||
</div>
|
||||
) : null
|
||||
|
||||
@@ -155,7 +155,7 @@ const PricingBentoPage = () => {
|
||||
allModels={models}
|
||||
/>
|
||||
|
||||
{/* 企业作用域计价口径提示:标价含企业等级折扣,个人密钥/体验中心调用仍按个人等级计费 */}
|
||||
{/* 企业等级计价提示:用户属于企业时,不论以何身份登录,标价与扣费都按企业等级折扣 */}
|
||||
{discountScope === 'enterprise' && !hidePrice && (
|
||||
<div className='container mx-auto px-6 pt-3'>
|
||||
<div
|
||||
@@ -164,7 +164,7 @@ const PricingBentoPage = () => {
|
||||
text-amber-800 dark:text-amber-300'
|
||||
>
|
||||
{t(
|
||||
'当前为企业作用域:以下价格已按企业等级折扣展示;使用个人密钥或体验中心调用时按个人等级计费。',
|
||||
'以下价格已按所属企业的等级折扣展示;企业成员使用个人密钥或体验中心调用时同样按企业等级计费。',
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -103,7 +103,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}
|
||||
@@ -317,7 +318,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 = (
|
||||
|
||||
@@ -81,7 +81,6 @@ const TaskLogsActions = ({
|
||||
{ key: 'channel_name', title: t('渠道名称') },
|
||||
]
|
||||
: []),
|
||||
{ key: 'platform', title: t('平台') },
|
||||
{ key: 'action', title: t('类型') },
|
||||
{
|
||||
key: 'model',
|
||||
|
||||
@@ -34,7 +34,6 @@ import {
|
||||
Video,
|
||||
Sparkles,
|
||||
Timer,
|
||||
Image as ImageIcon,
|
||||
ImagePlus,
|
||||
Coins,
|
||||
Cpu,
|
||||
@@ -47,7 +46,6 @@ import {
|
||||
IMAGE_ACTION_GENERATE,
|
||||
IMAGE_ACTION_EDIT,
|
||||
} from '../../../constants/common.constant';
|
||||
import { CHANNEL_OPTIONS } from '../../../constants/channel.constants';
|
||||
import { renderQuota } from '../../../helpers';
|
||||
|
||||
// 仅保留与下方 COLOR_CONFIG 一一对应的色值,避免 amber/lime/violet/teal/indigo/light-blue
|
||||
@@ -170,13 +168,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}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -230,34 +232,6 @@ const renderType = (type, t) => {
|
||||
);
|
||||
};
|
||||
|
||||
const renderPlatform = (platform, t) => {
|
||||
let option = CHANNEL_OPTIONS.find(
|
||||
(opt) => String(opt.value) === String(platform),
|
||||
);
|
||||
if (option) {
|
||||
return (
|
||||
<CustomTag
|
||||
icon={Video}
|
||||
label={option.label}
|
||||
colorKey={option.color || 'cyan'}
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (platform === 'suno') {
|
||||
return <CustomTag icon={Music} label='Suno' colorKey='green' />;
|
||||
}
|
||||
if (platform === 'image') {
|
||||
return <CustomTag icon={ImageIcon} label={t('图片')} colorKey='cyan' />;
|
||||
}
|
||||
if (platform === 'video') {
|
||||
return <CustomTag icon={Video} label={t('视频')} colorKey='blue' />;
|
||||
}
|
||||
if (platform === 'mj') {
|
||||
return <CustomTag icon={Sparkles} label='Midjourney' colorKey='purple' />;
|
||||
}
|
||||
return <CustomTag icon={HelpCircle} label={t('未知')} colorKey='grey' />;
|
||||
};
|
||||
|
||||
const renderStatus = (type, t) => {
|
||||
const statusConfig = {
|
||||
SUCCESS: { icon: CheckCircle, label: t('成功'), color: 'green' },
|
||||
@@ -292,6 +266,7 @@ export const getTaskLogsColumns = ({
|
||||
copyText,
|
||||
openContentModal,
|
||||
isAdminUser,
|
||||
isRootUser = false,
|
||||
openVideoModal,
|
||||
}) => {
|
||||
return [
|
||||
@@ -316,7 +291,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) : '-'}</>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -344,14 +321,6 @@ export const getTaskLogsColumns = ({
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
key: COLUMN_KEYS.PLATFORM,
|
||||
title: t('平台'),
|
||||
dataIndex: 'platform',
|
||||
render: (text, record, index) => {
|
||||
return <div>{renderPlatform(text, t)}</div>;
|
||||
},
|
||||
},
|
||||
{
|
||||
key: COLUMN_KEYS.TYPE,
|
||||
title: t('类型'),
|
||||
@@ -394,10 +363,16 @@ export const getTaskLogsColumns = ({
|
||||
return (
|
||||
<Typography.Text
|
||||
ellipsis={{ showTooltip: true }}
|
||||
onClick={() => {
|
||||
openContentModal(JSON.stringify(record, null, 2));
|
||||
}}
|
||||
className='cursor-pointer hover:text-blue-500 dark:hover:text-blue-400 transition-colors font-mono text-xs'
|
||||
onClick={
|
||||
isRootUser
|
||||
? () => openContentModal(JSON.stringify(record, null, 2))
|
||||
: undefined
|
||||
}
|
||||
className={
|
||||
isRootUser
|
||||
? 'cursor-pointer hover:text-blue-500 dark:hover:text-blue-400 transition-colors font-mono text-xs'
|
||||
: 'font-mono text-xs'
|
||||
}
|
||||
>
|
||||
{text}
|
||||
</Typography.Text>
|
||||
|
||||
@@ -54,6 +54,7 @@ const TaskLogsFilters = ({
|
||||
isAdminUser,
|
||||
getFreshInitValues,
|
||||
usageRecordMode = false,
|
||||
hideDateRange = false,
|
||||
t,
|
||||
}) => {
|
||||
const SearchIcon = usageRecordMode ? SearchCheck : Search;
|
||||
@@ -98,29 +99,31 @@ const TaskLogsFilters = ({
|
||||
|
||||
{/* 搜索字段网格 */}
|
||||
<div className='grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3'>
|
||||
{/* 时间选择器 */}
|
||||
<div className='col-span-1 lg:col-span-2'>
|
||||
<div className='relative group'>
|
||||
<div className='absolute -inset-0.5 bg-gradient-to-r from-cyan-500/20 to-blue-500/20 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-300 blur-sm' />
|
||||
<div className='relative'>
|
||||
<Form.DatePicker
|
||||
field='dateRange'
|
||||
className='w-full'
|
||||
type='dateTimeRange'
|
||||
placeholder={[t('开始时间'), t('结束时间')]}
|
||||
showClear
|
||||
pure
|
||||
size='small'
|
||||
prefix={<InputPrefix icon={Calendar} />}
|
||||
presets={DATE_RANGE_PRESETS.map((preset) => ({
|
||||
text: t(preset.text),
|
||||
start: preset.start(),
|
||||
end: preset.end(),
|
||||
}))}
|
||||
/>
|
||||
{/* 时间选择器:企业页复用上方消费记录的已提交时间范围 */}
|
||||
{!hideDateRange && (
|
||||
<div className='col-span-1 lg:col-span-2'>
|
||||
<div className='relative group'>
|
||||
<div className='absolute -inset-0.5 bg-gradient-to-r from-cyan-500/20 to-blue-500/20 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-300 blur-sm' />
|
||||
<div className='relative'>
|
||||
<Form.DatePicker
|
||||
field='dateRange'
|
||||
className='w-full'
|
||||
type='dateTimeRange'
|
||||
placeholder={[t('开始时间'), t('结束时间')]}
|
||||
showClear
|
||||
pure
|
||||
size='small'
|
||||
prefix={<InputPrefix icon={Calendar} />}
|
||||
presets={DATE_RANGE_PRESETS.map((preset) => ({
|
||||
text: t(preset.text),
|
||||
start: preset.start(),
|
||||
end: preset.end(),
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 任务 ID */}
|
||||
<div className='relative group'>
|
||||
|
||||
@@ -41,6 +41,7 @@ const TaskLogsTable = (taskLogsData) => {
|
||||
openContentModal,
|
||||
openVideoModal,
|
||||
isAdminUser,
|
||||
isRootUser,
|
||||
t,
|
||||
COLUMN_KEYS,
|
||||
} = taskLogsData;
|
||||
@@ -54,8 +55,17 @@ const TaskLogsTable = (taskLogsData) => {
|
||||
openContentModal,
|
||||
openVideoModal,
|
||||
isAdminUser,
|
||||
isRootUser,
|
||||
});
|
||||
}, [t, COLUMN_KEYS, copyText, openContentModal, openVideoModal, isAdminUser]);
|
||||
}, [
|
||||
t,
|
||||
COLUMN_KEYS,
|
||||
copyText,
|
||||
openContentModal,
|
||||
openVideoModal,
|
||||
isAdminUser,
|
||||
isRootUser,
|
||||
]);
|
||||
|
||||
// Filter columns based on visibility settings
|
||||
const getVisibleColumns = () => {
|
||||
|
||||
@@ -28,8 +28,19 @@ import { useTaskLogsData } from '../../../hooks/task-logs/useTaskLogsData';
|
||||
import { useIsMobile } from '../../../hooks/common/useIsMobile';
|
||||
import { createCardProPagination } from '../../../helpers/utils';
|
||||
|
||||
const TaskLogsPage = ({ usageRecordMode = false }) => {
|
||||
const taskLogsData = useTaskLogsData();
|
||||
const TaskLogsPage = ({
|
||||
usageRecordMode = false,
|
||||
organizationMode = false,
|
||||
sharedStartTimestamp,
|
||||
sharedEndTimestamp,
|
||||
sharedFilterRevision = 0,
|
||||
}) => {
|
||||
const taskLogsData = useTaskLogsData({
|
||||
organizationMode,
|
||||
sharedStartTimestamp,
|
||||
sharedEndTimestamp,
|
||||
sharedFilterRevision,
|
||||
});
|
||||
const isMobile = useIsMobile();
|
||||
|
||||
return (
|
||||
@@ -81,6 +92,7 @@ const TaskLogsPage = ({ usageRecordMode = false }) => {
|
||||
<TaskLogsFilters
|
||||
{...taskLogsData}
|
||||
usageRecordMode={usageRecordMode}
|
||||
hideDateRange={taskLogsData.usesSharedDateRange}
|
||||
/>
|
||||
}
|
||||
paginationArea={createCardProPagination({
|
||||
|
||||
@@ -31,6 +31,7 @@ const ColumnSelectorModal = ({
|
||||
initDefaultColumns,
|
||||
COLUMN_KEYS,
|
||||
isAdminUser,
|
||||
isRootUser,
|
||||
copyText,
|
||||
openContentModal,
|
||||
usageRecordMode = false,
|
||||
@@ -43,6 +44,7 @@ const ColumnSelectorModal = ({
|
||||
copyText,
|
||||
openContentModal,
|
||||
isAdminUser,
|
||||
isRootUser,
|
||||
});
|
||||
|
||||
// 计算"全选"状态时应忽略的 key:当前角色下不可见的管理员专属列
|
||||
|
||||
@@ -393,6 +393,7 @@ const EditTokenModal = (props) => {
|
||||
}
|
||||
if (successCount > 0) {
|
||||
showSuccess(t('令牌创建成功,请在列表页面点击复制获取令牌!'));
|
||||
props.onCreated?.(successCount);
|
||||
props.refresh();
|
||||
props.handleClose();
|
||||
}
|
||||
|
||||
@@ -547,7 +547,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) {
|
||||
@@ -561,7 +561,7 @@ export const getLogsColumns = ({
|
||||
) {
|
||||
let useChannel = other.admin_info.use_channel;
|
||||
let useChannelStr = useChannel.join('->');
|
||||
content = t('渠道') + `:${useChannelStr}`;
|
||||
content = t('渠道:{{channel}}', { channel: useChannelStr });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,6 +104,9 @@ const UsageBillingDetail = ({ record, expandItems, isAdminUser, t }) => {
|
||||
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
|
||||
@@ -117,10 +120,11 @@ const UsageBillingDetail = ({ record, expandItems, isAdminUser, t }) => {
|
||||
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),
|
||||
@@ -142,7 +146,8 @@ const UsageBillingDetail = ({ record, expandItems, isAdminUser, t }) => {
|
||||
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),
|
||||
@@ -190,11 +195,17 @@ const UsageBillingDetail = ({ record, expandItems, isAdminUser, t }) => {
|
||||
},
|
||||
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('图片生成'),
|
||||
@@ -383,13 +394,7 @@ const LogsTable = (logsData) => {
|
||||
},
|
||||
},
|
||||
];
|
||||
}, [
|
||||
compactMode,
|
||||
visibleColumnsList,
|
||||
expandData,
|
||||
hasExpandableRows,
|
||||
t,
|
||||
]);
|
||||
}, [compactMode, visibleColumnsList, expandData, hasExpandableRows, t]);
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -352,8 +352,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