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:
@@ -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('代理地址')}
|
||||
|
||||
Reference in New Issue
Block a user