fengsilin
a406c94b93
feat(user-migration): add root migration dashboard
1 неделю назад
fengsilin
87a0f94975
refactor: remove user-channel-ratio feature
删除用户渠道倍率(UserChannelRatio)功能,清理全链路相关代码:
后端删除 model/controller/router 层实现,前端删除 UI 组件和计费展示逻辑。
同时恢复 Token 分组选择和价格侧边栏分组过滤器的注释代码。
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 неделю назад
fengsilin
6ad0524172
test: add comprehensive pricing and channel selection tests
Add unit tests for group ratio, cross-group retry, and price calculation:
- Group ratio CRUD and special ratio override (12 tests)
- HandleGroupRatio with auto-group and special ratios (5 tests)
- ModelPriceHelper with group ratio in price/ratio modes (3 tests)
- Channel selection priority, groups, weighted LB (6 tests)
- RetryParam and AutoGroup service logic (7 tests)
Also restore the group pricing card in model detail SideSheet.
1 неделю назад
fengsilin
052b41562a
fix(pricing): restore group info on model cards
Uncomment the group ratio display that was hidden in a95331a8 .
1 неделю назад
fengsilin
0c2ea777f2
fix: remove channel-pricing API calls from frontend
Backend endpoints were removed but frontend still called them causing
404s. ChannelPricingCard no longer fetches, channelPricingApi and
pricingTagApi return empty stubs to keep dependent components stable.
1 неделю назад
fengsilin
8150993caf
fix(admin): improve channel form inputs
Expose channel public_name in the edit modal and load a larger channel page when building model settings views.
Co-Authored-By: Codex <noreply@anthropic.com>
1 неделю назад
fengsilin
3aa4cdf2ec
feat(models): add structured endpoint editor
Replace freeform endpoint JSON editing with a structured editor, keep advanced JSON mode, and make backend pricing parsing tolerate legacy array-form endpoint configs.
Co-Authored-By: Codex <noreply@anthropic.com>
1 неделю назад
fengsilin
3cf84775f2
feat: add channel metrics collector, fix search pagination and vendor sort order
- Register Prometheus ChannelCollector in GetMetrics() sync.Once block
- Add MetricsMiddleware to /v1 and /v1beta relay router groups when metrics enabled
- Remove public_name field from channel creation form and validation
- Restore InvitationCard in topup page
- Extract fetchSearchPage helper in useModelsData to eliminate ~50 lines of duplication; fix setSearching with finally block; use Axios params for URL encoding; fix missing vendor_counts update during paginated search
- Fix vendor ordering in HomePricingFilters to follow vendorsMap sort_order; fix O(n²) Array.includes to use Set
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2 недель назад
fengsilin
6434a523a1
feat: passthrough model mapping
2 недель назад
fengsilin
1c5e6d03d9
fix: 禁止修改同步用户余额
同步用户余额由主节点管理,从节点不应允许管理员修改其余额。
前端禁用额度输入和添加额度按钮,后端增加校验拦截。
3 недель назад
fengsilin
5afa4c48fc
feat: 用户表新增注册时间字段 + 用户列表显示邮箱和注册时间
- model/user.go: 新增 CreatedAt 字段,Insert 时自动填充
- UsersColumnDefs.jsx: 用户列表新增邮箱、注册时间列
- makefile: 新增 build-widget target
3 недель назад
fengsilin
84eb6d6a88
feat: 端点格式限制功能 + 完善测试
当开启端点格式限制后,不同协议的渠道只能通过对应的端点访问:
- Anthropic 渠道只能用 /v1/messages
- Gemini 渠道只能用 /v1beta/models/*
- OpenAI 系渠道只能用 /v1/chat/completions 等
- VertexAI/阿里云等支持多协议的渠道不受限
核心实现:EndpointFormatGuard 中间件从请求路径推导协议家族,
不依赖 gin context 中的 relay_format(因 group middleware 执行
时 context 中尚无此值)。
修复了 /v1/models/*path 和 /v1/engines/ 路径被错误归类为
openai 家族的 bug(实际是 Gemini 格式)。
单元测试 58 个,E2E 测试 15 个,覆盖:
- 路径分类边界(含 Gemini relay 路径修复验证)
- 渠道类型覆盖(含非 LLM 渠道透传)
- 并发安全、运行时开关切换
- 错误消息 JSON 结构和内容验证
3 недель назад
fengsilin
ea0d4e5cde
refactor: 完整删除前端渠道选择和默认通道 UI
4 недель назад
fengsilin
155aa12014
perf(docker): BuildKit 缓存加速构建 + fix: 模型列表改用 enabled 接口
Dockerfile 添加 --mount=type=cache 持久化 bun/go 缓存,
前端改代码时跳过后端构建(~10s),后端改代码时跳过前端(~30s)。
模型限流下拉改用 /api/channel/models_enabled 只返回已启用模型。
1 месяц назад
fengsilin
f07f2c25f4
feat(rate-limit): 用户模型限流配置改用下拉选择模型
将添加模型限流时的文本输入改为从渠道模型列表中选择,
并自动过滤已配置的模型,提升配置体验和准确性。
1 месяц назад
fengsilin
714d8239d1
feat: Relay 请求抓包日志 + 用户模型 RPM 限流
两个独立功能:
1. Relay Capture:对开启 capture_relay 的用户记录完整请求/响应到本地文件
- 单 writer goroutine + 128 槽 channel 架构,无 OOM 风险
- 支持流式 SSE 和非流式请求
- 30s 超时保护
2. User-Model RPM Rate Limiting:按 用户+模型 维度的 RPM 限流
- Redis 令牌桶 + 内存滑动窗口双路径,Redis 故障自动降级
- 请求失败时退还令牌/配额(Redis Refund Lua 脚本 + 内存 Refund)
- Redis pipeline 错误处理:失败时清理缓存 key
- 前端用户编辑弹窗新增模型限流配置面板
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 месяц назад
fengsilin
69ed7d85d7
feat(sidebar): 添加监控外部链接菜单项
在管理员菜单区域新增「监控」入口,仅 root 用户可见,
点击后在新窗口打开外部监控面板。支持在侧边栏模块管理中切换显示/隐藏。
同时在 renderWrapper 中添加外部链接的通用支持。
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 месяц назад
fengsilin
bae5c1faa5
feat(pricing): 隐藏模型广场标签和端点类型筛选器
注释掉模型广场侧边栏和筛选弹窗中的 PricingTags 和 PricingEndpointTypes 组件,
添加 EndpointType 常量及相关组件的文档注释。
Co-Authored-By: Claude <noreply@anthropic.com>
1 месяц назад
fengsilin
e6b4a06557
feat(logs): 隐藏使用日志中的分组信息展示
使用注释方式隐藏分组列和分组倍率标签,便于后续恢复:
1. 注释 UsageLogsColumnDefs.jsx 中的分组列定义
2. 注释 useUsageLogsData.jsx 中的 COLUMN_KEYS.GROUP 和默认可见性配置
3. 将计费详情中的"分组倍率"改为"倍率"
后端计费逻辑不变,仍正常应用分组倍率。
Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
1 месяц назад
fengsilin
f7ff684d0d
feat(pricing): 渠道定价展示用户折扣价格
登录用户查看渠道定价时,按用户分组倍率和渠道个人倍率计算实际折扣价
并在价格列展示划线原价与折扣价,新增 /pricing/user/*model 接口。
Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
1 месяц назад
fengsilin
e1b6aff7e1
fix(log): 对普通用户隐藏 Chat ID 和 Upstream ID
后端 GetUserLogs 返回前清空 chat_id/upstream_id(omitempty 不输出),
前端搜索框和展开行详情加 isAdminUser 守卫。
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 месяц назад
fengsilin
3e86f523db
feat(playground): temperature/top_p 参数互斥设置
部分上游模型不允许同时设置 temperature 和 top_p,新增管理员可配置的
模型前缀列表,匹配的模型在 Playground 中自动互斥切换两个参数。
- 后端新增 PlaygroundSetting 配置 + GET /api/playground/config 公开端点
- 运营设置页面新增 Playground 互斥模型前缀编辑 textarea
- Playground 自动检测模型名匹配,启用一个参数自动禁用另一个
- 默认包含 deepseek-v4-flash/pro、deepseek-reasoner、o1-/o3-/o4-、gpt-5
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 месяц назад
fengsilin
d26ad9e635
feat: 渠道-模型级联选择 + 隐藏首页统计卡片
- UserRatioSection 模型输入改为级联下拉,选渠道后自动加载模型列表
- models 信息嵌入 channelOptions 消除冗余 channelMap 状态
- 注释掉首页 HeroSection 统计数据卡片
Co-Authored-By: Claude <noreply@anthropic.com>
1 месяц назад
fengsilin
b026f6bc04
feat: 用户倍率前端展示 + 渠道下拉选择 + 上游调试日志
- UserRatioSection 渠道 ID 输入改为带搜索的下拉选择器
- 使用日志详情、计费过程、展开行均显示用户倍率
- renderLogContent suffix 统一追加,消除 4 处重复
- 提取 dumpUpstreamRequest 辅助函数,debug 日志走 SysLog
Co-Authored-By: Claude <noreply@anthropic.com>
1 месяц назад
fengsilin
9dbf3365fe
feat(pricing): 添加用户-模型-渠道倍率功能
为每个用户添加独立于全局定价的倍率乘数,支持按 (userId, model, channel) 三维
精确控制用户级别定价。倍率以乘法叠加在现有 modelRatio × groupRatio 之上。
- 新增 user_channel_ratios 表,写入内存缓存(写穿透模式)
- 新增 /api/user_channel_ratio/ CRUD API(AdminAuth)
- 计费路径集成:compatible_handler、PostClaudeConsumeQuota、
PostWssConsumeQuota、PostAudioConsumeQuota、calculateAudioQuota
- 前端:EditUserModal 内嵌 UserRatioSection 组件
- 修复 Update() 缓存 key 零值 bug(先加载再更新)
- 修复 PreWssConsumeQuota 缺少 UserChannelRatio 导致归零
- 修复 ModelPriceHelperPerCall 缺少默认值 1.0
Co-Authored-By: Claude <noreply@anthropic.com>
1 месяц назад
fengsilin
17a0c2c26a
refactor(playground): 隐藏对话页面的分组选择框
Co-Authored-By: Claude <noreply@anthropic.com>
1 месяц назад
fengsilin
8945f8c39e
fix: synced 用户剩余额度取 synced_quota + 记录 chat ID
- 前端用户列表:synced 用户显式取 synced_quota 字段作为剩余额度
- 各 OpenAI handler 中记录 relayChatID 用于日志追踪
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 месяц назад
fengsilin
b2cb7bcf60
feat: record chat and upstream ids in usage logs
1 месяц назад
fengsilin
575f84064e
feat: codex API key 模式 + 前端凭证回显修复
- codex adaptor 支持 API key 和 OAuth 两种认证模式
- 提取 setupOAuthHeader 和 shouldUseChatCompletionsViaResponses
- 修复编辑页 codex_credential_mode 切换/回显不同步问题
- ResponsesStreamResponse 添加 Error 字段支持独立错误事件
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 месяц назад
fengsilin
332d5a62f2
feat: support codex api key credentials
1 месяц назад
fengsilin
1c0898257c
feat: add redemption remarks
1 месяц назад
fengsilin
d8272e7707
feat(channel): 添加渠道"对外名称"(public_name)字段
为 Channel 模型新增 public_name 字段,让管理员可以为每个渠道
设置用户可见的友好名称(如"标准通道"、"高速通道"),替代前端
硬编码的"通道一/二/三"。Playground 通道选择器展示对外名称,
"渠道"统一改为"通道"。新建渠道时对外名称必填,编辑时可选。
Co-Authored-By: Claude <noreply@anthropic.com>
1 месяц назад
fengsilin
5b8303ae81
fix: 登录后跳转来源页,充值金额校验优化
- LoginForm: 登录成功后跳转回登录前的页面,而非固定 /console
- RechargeCard: 输入金额低于最低值时显示警告提示
- .dockerignore: 排除 .claude、.plans、脚本等非项目文件
Co-Authored-By: Claude <noreply@anthropic.com>
1 месяц назад
fengsilin
8bb2883d7e
feat(home): 首页定价卡片添加"去体验"按钮,跳转 Playground
- PricingCardView 新增 showTryButton 属性,点击跳转 Playground 并预选模型
- 移除 PricingCardView 中未使用的 props (selectedGroup, currency 等)
- 首页页脚路由重命名: terms→user-agreement, usage-policy→privacy-policy
- i18n: "操练场"更名为"对话"
Co-Authored-By: Claude <noreply@anthropic.com>
1 месяц назад
fengsilin
74cc8c0d56
feat(playground): 添加渠道选择功能,支持指定渠道体验模型
- 新增 /api/user/model_channels 接口,返回模型可用渠道及默认渠道
- Playground 设置面板添加渠道选择下拉框
- Distribute 中间件支持从请求体读取 channel_id 指定渠道
- 支持 URL 参数 ?model=xxx 直接选择模型
Co-Authored-By: Claude <noreply@anthropic.com>
1 месяц назад
fengsilin
d24d68a916
fix(i18n): 修复令牌和充值页面货币显示不一致问题
- 令牌创建:快捷选项标签根据系统货币设置动态生成,替换硬编码美元
- 充值页面:输入框显示值与预设卡片统一换算为本地货币,内部值仍为原始单位
- 使用 getQuotaPerUnit() 替代魔数 500000
- 消除 RechargeCard 中 getCurrencyConfig() 的 N+1 重复调用
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 месяц назад
fengsilin
1912dd3b72
feat: 添加图片验证码功能,防止脚本批量注册
- 后端:新增 GET /api/captcha 接口,使用 base64Captcha 生成图片验证码
- 后端:发送邮箱验证码时校验图片验证码(CaptchaEnabled 开关控制)
- 前端:注册表单邮箱验证码前增加图片验证码输入,支持点击刷新
- 管理后台:系统设置新增「图片验证码」开关
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 месяц назад
fengsilin
56e8d14485
fix: 语言切换后 TextArea 内容丢失
添加 useEffect 在 editingLang 变化时同步 form values,
确保重新挂载的 TextArea 能从 React state 中读取正确内容。
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 месяц назад
fengsilin
65bd1dabb8
fix: 法律文档编辑器切换语言时 TextArea 内容未刷新
给每个 TextArea 添加 key={editingLang} 强制组件在语言切换时重新挂载。
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 месяц назад
fengsilin
934b4b10a7
feat: 法律文档双语配置(中/英)+ 精简语言支持至中英双语
- LegalSettings 字段拆分为 _zh/_en 双语对
- API 支持 ?lang= 参数返回对应语言内容
- 后台设置页每个文档配语言切换按钮(中文/English)
- 前端页面根据 UI 语言自动请求对应内容
- 移除 fr/ru/ja/vi/zh-TW 语言支持
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 месяц назад
fengsilin
1cc75aa9a2
feat: 服务条款和使用政策页面,支持后台 Markdown 配置
复用现有 LegalSettings 模式,新增 TermsOfService 和 UsagePolicy 字段,
添加 /terms 和 /usage-policy 前端页面及 API 端点。
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 месяц назад
fengsilin
ed195cada5
fix(frontend): sort_order 默认值显示为"未设置",编辑弹窗增加提示
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 месяц назад
fengsilin
54e53108ec
fix(sort): sort_order 默认值改为 999999,简化排序逻辑
未设置排序的记录 sort_order=999999 自然排在后面,无需 CASE WHEN。
- GORM 默认值 default:0 → default:999999
- 数据库迁移:将现有 sort_order=0 的记录更新为 999999
- 回退 CASE WHEN 排序逻辑,恢复简单的 sort_order ASC, id ASC
- 前端编辑弹窗默认值同步改为 999999
- 表格列中 999999 显示为空(表示未设置)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 месяц назад
fengsilin
518f1ab87f
refactor(frontend): 移除拖拽排序,改为 sort_order 数值输入
回退 @dnd-kit 拖拽实现,改为在编辑弹窗中直接设置 sort_order 数值:
- 模型编辑弹窗新增「排序」InputNumber 字段
- 供应商编辑弹窗新增「排序」InputNumber 字段
- 模型表格新增 sort_order 显示列
- 移除 @dnd-kit 依赖及所有 DnD 相关代码
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 месяц назад
fengsilin
65880fc69b
feat(frontend): Vendor Tab 和 Model 表格支持拖拽排序,移除定价页字母排序
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 месяц назад
fengsilin
3a29f3772f
feat(channel): 添加模型默认通道功能,支持优先路由和卡片标识
- 新增 is_default 字段和缓存层,支持管理员为模型指定默认通道
- Distribute 中间件优先级调整:Token 指定 → 默认通道 → 亲和性 → 随机
- 模型定价卡片和详情弹窗展示默认通道 amber 标识
- 管理后台定价页面新增星标切换默认通道
- 新增 set_default / clear_default API 和 6 个单元测试
- 简化卡片价格显示(移除内联缓存价格,改为详情弹窗展示)
Co-Authored-By: Claude <noreply@anthropic.com>
1 месяц назад
fengsilin
93e331b624
feat: 支持 LOGO_FILE_PATH 环境变量指定本地 Logo,优化定价与语言设置
- 新增 LOGO_FILE_PATH 环境变量,优先级高于数据库配置,支持本地文件服务
- 渠道定价高级字段(缓存/图片/音频)不再回退全局默认值,未设置直接返回 0
- 缓存价格单位从表头移到具体价格值,新增渠道 ID 复制功能
- 修复默认语言在用户已有偏好时仍被覆盖的问题
- img 标签统一添加 referrerPolicy/crossOrigin 防止跨域问题
- 新增缓存倍率和最小余额阈值的详细说明文本
Co-Authored-By: Claude <noreply@anthropic.com>
1 месяц назад
fengsilin
387f6c1ae0
feat(pricing): 定价数据源切换到渠道表,新增缓存价格展示
- 后端 pricing API 从 channel_pricings 表获取实际定价,选取最便宜渠道
- 提取 applyGlobalDefault 辅助函数消除全局回退逻辑重复
- price.go 重构扩展比率为局部变量,简化回退逻辑
- 定价卡片新增缓存读取/创建价格,改为两行布局防止溢出
- ChannelPricingCard 缓存列显示实际价格而非倍率
- 修复移动端 hero 区域 padding 过大
- 默认标签页标题改为 Loading...
- 新增缓存读取/创建 i18n 翻译(7 语言)
Co-Authored-By: Claude <noreply@anthropic.com>
1 месяц назад
fengsilin
42082311d3
fix: 修复默认语言不生效的问题
移除 PageLayout useEffect 中多余的 localStorage 语言恢复逻辑。
i18next-browser-languagedetector 在初始化时已自动处理 localStorage,
同步的 changeLanguage 调用会覆盖异步 loadStatus 设置的管理员默认语言。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 месяц назад
fengsilin
9eb58c684e
feat: 后台设置默认语言
管理员可在系统设置页面配置全局默认语言,未登录用户和未设置
语言偏好的已登录用户将强制使用该语言,忽略浏览器语言检测。
- common/constants.go: 新增 DefaultLanguage 变量
- model/option.go: 新增 DefaultLanguage option handler
- controller/misc.go: /api/status 暴露 default_language
- SystemSetting.jsx: 添加语言下拉框到通用设置
- PageLayout.jsx: 未登录用户应用默认语言
- UserContext.jsx: 无偏好用户回退到默认语言
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 месяц назад