sync: 同步 monkey-ai@weiyuan(ddc5b9443) 的 web/ 到 ui-optimization

- 合入 weiyuan 新功能前端:分佣 V2 / 伙伴工作台、智能路由、企业资金与分析、官网设置与预约演示等,
  semi-ui 已全部迁移到 antd 6 / @/components/ui,不重新引入 Semi
- 分佣二级菜单与页头去重、伙伴入口探测(企业伙伴走企业中心「企业分佣」)、超管侧栏入口恢复
- 适配层 DatePicker / TimePicker 统一 onChange(Date|Date[]|null, 文本) 契约;生产构建剔除调试日志
- 图片链接刷新:同任务请求复用、后台刷新不弹全局错误、离页停止批量请求
- 恢复 bun.lock(与 package-lock.json 共存);docs 规范与 CHANGELOG 更新
- 停止跟踪 .env.playwright.local(本地登录凭据,已加入 .gitignore)
This commit is contained in:
qiubaishen
2026-11-18 10:22:02 +08:00
parent 737c353d84
commit db3dba1e96
157 changed files with 29960 additions and 1197 deletions
@@ -390,7 +390,7 @@ export const getChannelsColumns = ({
size='small'
type='primary'
theme='outline'
onClick={(e) => {
onClick={async (e) => {
e.stopPropagation();
writeClipboardText(record.remark)
.then(() => {
@@ -180,6 +180,7 @@ const originInputs = {
chat_image_to_images_enabled: false,
system_prompt: '',
system_prompt_override: false,
responses_system_prompt_mode: 'native',
client_only: false, // 只接受 Claude Code 客户端请求
bound_user_ids: '', // 绑定用户ID列表
os_restriction: [], // 操作系统白名单,仅 Claude 原生渠道(type=14)生效,空数组=无限制
@@ -190,6 +191,7 @@ const originInputs = {
sticky_user_id_mode: 'native', // 注入形态:native(仿 Claude Code 原生)/ opaque
cache_breakpoint_fill: false, // 给完全没有 cache_control 的大上下文请求补一个缓存断点
cache_breakpoint_min_tokens: 0, // 注入门限(估算 prompt token),0=用后端默认 10000
cache_creation_default_ttl: '', // 未分档缓存创建按哪档计费,''=跟随全局,可选 5m/1h
settings: '',
// 仅 Vertex: 密钥格式(存入 settings.vertex_key_type)
vertex_key_type: 'json',
@@ -423,6 +425,8 @@ const EditChannelModal = (props) => {
pass_through_body_enabled: false,
chat_image_to_images_enabled: false,
system_prompt: '',
system_prompt_override: false,
responses_system_prompt_mode: 'native',
client_only: false,
bound_user_ids: '',
os_restriction: [],
@@ -433,6 +437,7 @@ const EditChannelModal = (props) => {
sticky_user_id_mode: 'native',
cache_breakpoint_fill: false,
cache_breakpoint_min_tokens: 0,
cache_creation_default_ttl: '',
});
const showApiConfigCard = true; // 控制是否显示 API 配置卡片
const getInitValues = () => ({
@@ -626,6 +631,10 @@ const EditChannelModal = (props) => {
data.system_prompt = parsedSettings.system_prompt || '';
data.system_prompt_override =
parsedSettings.system_prompt_override || false;
data.responses_system_prompt_mode =
parsedSettings.responses_system_prompt_mode === 'input_user_message'
? 'input_user_message'
: 'native';
data.client_only = parsedSettings.client_only || false;
data.bound_user_ids = parsedSettings.bound_user_ids || '';
data.os_restriction = Array.isArray(parsedSettings.os_restriction)
@@ -646,6 +655,11 @@ const EditChannelModal = (props) => {
parsedSettings.cache_breakpoint_fill || false;
data.cache_breakpoint_min_tokens =
parsedSettings.cache_breakpoint_min_tokens || 0;
data.cache_creation_default_ttl = ['5m', '1h'].includes(
parsedSettings.cache_creation_default_ttl,
)
? parsedSettings.cache_creation_default_ttl
: '';
} catch (error) {
console.error('解析渠道设置失败:', error);
data.force_format = false;
@@ -656,6 +670,7 @@ const EditChannelModal = (props) => {
data.chat_image_to_images_enabled = false;
data.system_prompt = '';
data.system_prompt_override = false;
data.responses_system_prompt_mode = 'native';
data.client_only = false;
data.bound_user_ids = '';
data.os_restriction = [];
@@ -666,6 +681,7 @@ const EditChannelModal = (props) => {
data.sticky_user_id_mode = 'native';
data.cache_breakpoint_fill = false;
data.cache_breakpoint_min_tokens = 0;
data.cache_creation_default_ttl = '';
}
} else {
data.force_format = false;
@@ -676,6 +692,7 @@ const EditChannelModal = (props) => {
data.chat_image_to_images_enabled = false;
data.system_prompt = '';
data.system_prompt_override = false;
data.responses_system_prompt_mode = 'native';
data.client_only = false;
data.bound_user_ids = '';
data.os_restriction = [];
@@ -686,6 +703,7 @@ const EditChannelModal = (props) => {
data.sticky_user_id_mode = 'native';
data.cache_breakpoint_fill = false;
data.cache_breakpoint_min_tokens = 0;
data.cache_creation_default_ttl = '';
}
if (data.settings) {
@@ -792,6 +810,8 @@ const EditChannelModal = (props) => {
data.chat_image_to_images_enabled || false,
system_prompt: data.system_prompt,
system_prompt_override: data.system_prompt_override || false,
responses_system_prompt_mode:
data.responses_system_prompt_mode || 'native',
client_only: data.client_only || false,
bound_user_ids: data.bound_user_ids || '',
os_restriction: Array.isArray(data.os_restriction)
@@ -806,6 +826,7 @@ const EditChannelModal = (props) => {
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,
cache_creation_default_ttl: data.cache_creation_default_ttl || '',
});
initialModelsRef.current = (data.models || [])
.map((model) => (model || '').trim())
@@ -1075,6 +1096,7 @@ const EditChannelModal = (props) => {
chat_image_to_images_enabled: false,
system_prompt: '',
system_prompt_override: false,
responses_system_prompt_mode: 'native',
client_only: false,
bound_user_ids: '',
os_restriction: [],
@@ -1085,6 +1107,7 @@ const EditChannelModal = (props) => {
sticky_user_id_mode: 'native',
cache_breakpoint_fill: false,
cache_breakpoint_min_tokens: 0,
cache_creation_default_ttl: '',
});
// 重置密钥模式状态
setKeyMode('append');
@@ -1403,6 +1426,11 @@ const EditChannelModal = (props) => {
localInputs.chat_image_to_images_enabled || false,
system_prompt: localInputs.system_prompt || '',
system_prompt_override: localInputs.system_prompt_override || false,
responses_system_prompt_mode: ['native', 'input_user_message'].includes(
localInputs.responses_system_prompt_mode,
)
? localInputs.responses_system_prompt_mode
: 'native',
client_only: localInputs.client_only || false,
bound_user_ids: localInputs.bound_user_ids || '',
os_restriction: Array.isArray(localInputs.os_restriction)
@@ -1432,6 +1460,13 @@ const EditChannelModal = (props) => {
0,
parseInt(localInputs.cache_breakpoint_min_tokens, 10) || 0,
),
// '' = 跟随全局「Claude设置」里的未分档缓存创建默认档位。
// 枚举外的值一律落回 '',后端 ValidateSettings 也会拒绝脏值。
cache_creation_default_ttl: ['5m', '1h'].includes(
localInputs.cache_creation_default_ttl,
)
? localInputs.cache_creation_default_ttl
: '',
};
try {
localInputs.setting = mergeChannelSettings(
@@ -1502,8 +1537,10 @@ const EditChannelModal = (props) => {
delete localInputs.sticky_user_id_mode;
delete localInputs.cache_breakpoint_fill;
delete localInputs.cache_breakpoint_min_tokens;
delete localInputs.cache_creation_default_ttl;
delete localInputs.system_prompt;
delete localInputs.system_prompt_override;
delete localInputs.responses_system_prompt_mode;
delete localInputs.is_enterprise_account;
// 顶层的 vertex_key_type 不应发送给后端
delete localInputs.vertex_key_type;
@@ -2753,12 +2790,10 @@ const EditChannelModal = (props) => {
showInfo(t('没有模型可以复制'));
return;
}
try {
if (!(await copy(inputs.models.join(',')))) {
throw new Error('Clipboard copy failed');
}
// copy 失败返回 false 而不抛错,以返回值为准
if (await copy(inputs.models.join(','))) {
showSuccess(t('模型列表已复制到剪贴板'));
} catch (error) {
} else {
showError(t('复制失败'));
}
}}
@@ -3756,6 +3791,26 @@ const EditChannelModal = (props) => {
)}
/>
<Form.Select
field='cache_creation_default_ttl'
label={t('未分档缓存创建默认档位')}
style={{ width: '100%' }}
optionList={[
{ label: t('跟随全局'), value: '' },
{ label: t('按 5 分钟档计费'), value: '5m' },
{ label: t('按 1 小时档计费'), value: '1h' },
]}
onChange={(value) =>
handleChannelSettingsChange(
'cache_creation_default_ttl',
value,
)
}
extraText={t(
'本渠道上游只返回缓存创建总量、未给出 5m/1h 拆分时,这部分按哪一档倍率计费,优先级高于「模型设置 → Claude设置」里的全局默认档位。上游已明确分档的 token 永远按实际返回结算,与此项无关。号池确定「不带 ttl 参数即落 5 分钟」的渠道才需要改成 5m。',
)}
/>
<Form.Input
field='proxy'
label={t('代理地址')}
@@ -3797,6 +3852,29 @@ const EditChannelModal = (props) => {
'如果用户请求中包含系统提示词,则使用此设置拼接到用户的系统提示词前面',
)}
/>
<Form.Select
field='responses_system_prompt_mode'
label={t('Responses 系统提示词兼容模式')}
optionList={[
{
label: t('原生模式(默认)'),
value: 'native',
},
{
label: t('号池兼容:放入 input 用户消息'),
value: 'input_user_message',
},
]}
onChange={(value) =>
handleChannelSettingsChange(
'responses_system_prompt_mode',
value,
)
}
extraText={t(
'仅对命中 ForceResponsesModels 的 Chat→Responses 桥接请求生效;直接 Responses 请求和图片接口不转换。',
)}
/>
</Card>
</div>
</div>
@@ -20,6 +20,7 @@ For commercial licensing, please contact support@quantumnous.com
import React from 'react';
import { Tag as AntTag } from 'antd';
import { Progress, Tooltip, Typography } from '@/components/ui';
import { fundAccountDisplay } from '../../../pages/Organization/fund/fundFormat';
import {
Music,
FileText,
@@ -570,6 +571,33 @@ export const getTaskLogsColumns = ({
);
},
},
...(COLUMN_KEYS.FUND_DEPT
? [
{
key: COLUMN_KEYS.FUND_DEPT,
title: t('归属部门'),
dataIndex: 'fund_dept_name',
render: (v) => (
<span className='block max-w-[140px] truncate' title={v || ''}>
{v === undefined || v === null ? '—' : v || t('未归属部门')}
</span>
),
},
{
key: COLUMN_KEYS.FUND_ACCOUNT,
title: t('扣费账户'),
dataIndex: 'fund_account_type',
render: (v, record) =>
v === undefined || v === null ? (
'—'
) : (
<span className='block max-w-[180px] truncate'>
{fundAccountDisplay(t, v, record.fund_dept_name)}
</span>
),
},
]
: []),
{
key: COLUMN_KEYS.FAIL_REASON,
title: t('详情'),
@@ -72,6 +72,7 @@ const ContentModal = ({
setIsLoading(false);
};
// 走公共 copy:HTTP 部署下 navigator.clipboard 为 undefined,裸调会同步抛错、点了无反应
const handleCopyUrl = () => {
writeClipboardText(shareUrl)
.then(() => showSuccess(t('链接已复制')))
@@ -844,6 +844,10 @@ export const getLogsColumns = ({
other.cache_creation_ratio_1h ||
other.cache_creation_ratio ||
1.0,
other.cache_creation_tokens_unlabeled || 0,
other.cache_creation_ratio_unlabeled ||
other.cache_creation_ratio ||
1.0,
false,
1.0,
other?.is_system_prompt_overwritten,
@@ -862,6 +866,8 @@ export const getLogsColumns = ({
1.0,
0,
1.0,
0,
1.0,
false,
1.0,
other?.is_system_prompt_overwritten,
@@ -116,15 +116,18 @@ const UsageBillingDetail = ({
const other = getLogOther(record.other) || {};
const inputTokens = Number(record.prompt_tokens || 0);
const outputTokens = Number(record.completion_tokens || 0);
const cacheTokens =
Number(other.cache_tokens || 0) +
Number(other.cache_creation_tokens || 0) +
Number(other.cache_creation_tokens_5m || 0) +
Number(other.cache_creation_tokens_1h || 0);
const textTokens = inputTokens + outputTokens;
// 有 5m/1h 分档时只展示分档,不再重复展示未分档的总量与倍率
// 缓存创建按上游实际返回分三桶:明确的 5m / 1h,以及上游只给了总量没给分档的「未分档」。
// 三桶按各自倍率结算,所以三桶都得露出来——少露一桶,用户拿界面上的 token × 倍率就加不出账单金额。
const hasSplitCacheCreation =
other.cache_creation_tokens_5m > 0 || other.cache_creation_tokens_1h > 0;
// 未分档桶只在与分档并存时单独成行;没有分档时,下面的「缓存创建 / 缓存创建倍率」
// 本身说的就是这一桶,再列一遍是重复
const unlabeledCacheCreation = Number(
other.cache_creation_tokens_unlabeled || 0,
);
const showUnlabeledCacheCreation =
hasSplitCacheCreation && unlabeledCacheCreation > 0;
const effectiveGroupRatio =
Number.isFinite(Number(other.user_group_ratio)) &&
Number(other.user_group_ratio) !== -1
@@ -151,6 +154,10 @@ const UsageBillingDetail = ({
label: t('1h 缓存创建'),
value: formatCount(other.cache_creation_tokens_1h),
},
showUnlabeledCacheCreation && {
label: t('未分档缓存创建'),
value: formatCount(unlabeledCacheCreation),
},
other.model_ratio != null && {
label: t('模型倍率'),
value: formatRatio(other.model_ratio),
@@ -160,7 +167,10 @@ const UsageBillingDetail = ({
value: formatRatio(other.completion_ratio),
},
other.cache_ratio != null &&
cacheTokens > 0 && {
other.cache_tokens > 0 && {
// cache_ratio 是缓存命中(读)的倍率,与缓存创建(写)无关。
// 过去这里的闸门把写入 token 也算进来,于是只写不读的请求也会挂一个
// 没有对应 token 的「缓存倍率 0.1x」,看着像漏算了一笔钱。
label: t('缓存倍率'),
value: formatRatio(other.cache_ratio),
},
@@ -180,6 +190,11 @@ const UsageBillingDetail = ({
label: t('1h 缓存倍率'),
value: formatRatio(other.cache_creation_ratio_1h),
},
showUnlabeledCacheCreation &&
other.cache_creation_ratio_unlabeled != null && {
label: t('未分档缓存倍率'),
value: formatRatio(other.cache_creation_ratio_unlabeled),
},
effectiveGroupRatio != null && {
label: t('分组倍率'),
value: formatRatio(effectiveGroupRatio),
@@ -246,8 +246,10 @@ const renderOperations = (
const currentRole = Number(getUserData()?.role || 0);
const recordRole = Number(record.role || 0);
const canManage = isAdmin() && (currentRole >= 100 || recordRole < 100);
const canChangeRole = canManage && recordRole < 100;
// 与后端 canManageUserOfRole 一致:非超级管理员只能管理角色低于自己的用户;提升/降级仅超级管理员
const canManage =
isAdmin() && (currentRole >= 100 || recordRole < currentRole);
const canChangeRole = canManage && currentRole >= 100 && recordRole < 100;
// 低频动作全部收进「更多」下拉,操作列稳定为一行三个控件,避免跨行撑高行高
const moreMenu = [];