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>
3 недель назад
fengsilin
235f7c6e5f
refactor(channel-pricing): 提取 ParseTagIds 辅助函数 + 移除调试 console.log
- 将 tag ID 解析逻辑提取为 model.ParseTagIds,消除 model 层和 controller 层重复代码
- 统一 TrimSpace 处理(之前 controller 版本漏了)
- 移除 ChannelPricingView 残留的 console.log('Expanded keys:')
- 删除多余空行
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
3 недель назад
fengsilin
646f37dd4b
feat(channel-pricing): Controller 扩展 API 支持新字段 + 输入校验 + 操作日志
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
3 недель назад
fengsilin
b514a0798b
refactor(payment): 合并微信/支付宝支付重复代码,删除冗余文件
- 提取通用 calcPayMoney/calcMinTopup 函数,消除微信和支付宝控制器中的重复计费逻辑
- 合并 RechargeAlipay/RechargeWechat 为 rechargeByQRCodePayment 内部函数,删除 model/topup_alipay.go
- 复用已有的 wrapAsPEM 替换支付宝专用的 wrapAlipayPublicKey
- 删除被 QRCodePayModal 替代的 WechatPayQRCodeModal.jsx
- 修复 controller/topup.go 中支付宝代码块的缩进错误
净减 264 行代码。
Co-Authored-By: Claude <noreply@anthropic.com>
3 недель назад
fengsilin
e8ade3abae
feat(payment): 集成支付宝当面付扫码支付 + 补全前端 i18n 硬编码中文
支付宝支付:
- 后端:新增 topup_alipay.go、payment_alipay.go,实现当面付(扫码支付)下单、
回调验签、订单状态查询完整流程,支持 RSA2 签名
- 前端:新增 QRCodePayModal 通用二维码支付弹窗(泛化微信支付弹窗)、
SettingsPaymentGatewayAlipay 管理配置页面、充值流程接入支付宝
- 充值历史:管理员视图新增用户邮箱列,后端 fillTopUpEmails 批量填充
i18n 补全:
- 54 个缺失翻译 key 添加到全部 7 个 locale 文件(zh-CN/zh-TW/en/fr/ja/ru/vi)
- 涵盖渠道名称、仪表盘标签、兑换码状态、控制台时间筛选、Playground 错误消息、
Dashboard 设置页面提示等
- 14 个源码文件中约 31 处 showError/showSuccess/showWarning 硬编码中文改用 t()
- ChannelsColumnDefs、helpers、services 中散落的硬编码中文统一国际化
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
3 недель назад
fengsilin
cf2a0a7992
fix(payment): 修复微信支付集成多项问题
- 修复订单号超 32 字符限制(微信支付要求),改用时间戳+随机字符格式
- 修复密钥解析:添加 wrapAsPEM 兼容 PEM/Base64/DER 多种输入格式
- 修复前端:RechargeCard 未识别 enableWechatTopUp 导致充值表单不显示
- 修复前端:支付按钮禁用逻辑未区分 epay/wechat_pay
- 移除状态轮询接口的 CriticalRateLimit 防止 429
- 过滤未启用易支付的旧支付方法避免混淆
- 修复 SiLinkedin 图标不存在导致构建失败
- 简化 webhook 冗余条件判断
- 添加密钥解析相关测试
Co-Authored-By: Claude <noreply@anthropic.com>
3 недель назад
fengsilin
00e266cd77
feat(payment): 集成微信支付 Native(扫码支付)V3 API
完整实现微信支付充值和订阅购买功能,支持配置热更新、二维码扫码支付、
回调验签、订单状态轮询,以及管理后台支付网关设置。
后端:
- 新增微信支付 V3 客户端(支持 Base64/文件路径两种密钥加载)
- Native 下单、回调处理、订单状态查询 API
- 充值订单幂等完成(事务+行锁)
- 订阅购买支持微信支付
- 配置变更自动重置客户端
- 提取 createWechatNativeOrder 消除重复下单逻辑
前端:
- 二维码扫码弹窗(含倒计时、自动轮询状态)
- 微信支付设置页面(AppID、商户号、密钥等 12 项配置)
- 充值页集成微信支付流程
依赖:go-pay/gopay v1.5.117
Co-Authored-By: Claude <noreply@anthropic.com>
3 недель назад
fengsilin
b693a733ba
feat(region-sync): 批量查询用户余额接口,优化同步性能
RunQuotaSync 从逐个查询改为批量查询(每批500个),
减少 Master 节点 API 调用次数,提升同步效率。
新增:
- BatchQueryUserQuota 控制器接口
- BatchQueryQuota 客户端方法
- QuotaEntry/BatchQueryQuotaRequest/Response 类型
附带 update-image.sh 部署脚本。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
4 недель назад
fengsilin
296edf0f71
fix: 移植上游关键 bug 修复
从 QuantumNous/new-api 上游移植以下修复:
- fix(ssrf): 加固视频代理和 MJ 图片代理的 SSRF 防护,FetchModels 提权至 RootAuth
- fix(claude): 流式断流时不再整份覆盖 usage,保留 cache 计费字段
- fix(pricing): 定价接口增加用户可用分组过滤
- fix(ratio): compact 模型优先匹配精确定价再回退通配符
- fix(ali): 接受 task polling 返回的字符串类型 usage 值
- fix(gemini): 从 URL 路径 :streamGenerateContent 检测流式请求
- fix(zhipu_4v): coding plan 图片生成使用正确的 OpenAI endpoint
- fix(openai): MessageImageUrl.Detail 字段添加 omitempty
- fix(channel-affinity): skip_retry_on_failure 配置项为 false 时不再丢失
- fix(document-renderer): 使用 useMemo 替代 useState 处理 HTML payload
- fix(fetch-setting): ApplyIPFilterForDomain 默认值改为 true
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
4 недель назад
fengsilin
9d4a595465
feat(region-sync): Master→Slave 配置同步、热更新与前端修复
- 新增 GET /api/internal/sync/config 接口,Master 下发 MinBalanceThreshold、MaxRetryCount、SyncBatchSize、SyncIntervalSeconds
- Slave 每 5 分钟从 Master 拉取配置并持久化到本地数据库,确保重启不丢失
- 统一 startWorker 支持动态间隔,同步间隔前端修改后无需重启立即生效
- 主节点地址从 TagInput 改为 Form.Input,修复 JSON 数组格式问题
- stringToArray 兼容 JSON 数组和换行分隔两种格式
- 清理根目录测试脚本(已迁移到 test-scripts/)
Co-Authored-By: Claude <noreply@anthropic.com>
4 недель назад
fengsilin
dc20782918
fix(region-sync): 修复 Settle/SyncManager 竞争条件并优化并发安全
- 新增 settled 状态,防止 SyncManager 在 PreConsume/Settle 之间同步未结算记录
- Settle 使用 AdjustSyncedQuota(增量 gorm.Expr)替代 UpdateSyncedQuota(绝对值),修复并发覆写
- 网络失败时标记所有记录为 failed 并增加 retry_count,避免无限重试
- 新增 ArchiveStalePendingRecords 定时清理崩溃请求的 pending 记录
- 简化 IsSyncedUser/IsLocalUser 移除冗余 id 参数
- Dockerfile 切换华为云 Go 镜像,移除不兼容的 GOEXPERIMENT=greenteagc
Co-Authored-By: Claude <noreply@anthropic.com>
4 недель назад
fengsilin
1cecd5349d
feat: 跨区域配额同步(Master-Slave Region Sync)
实现 Master-Slave 架构的跨区域用户和配额同步功能,支持国内主节点与
海外从节点之间的用户创建推送、余额同步、预扣费批量回传。
主要变更:
- 新增 region_sync 服务层(SyncManager/SyncClient/推送逻辑)
- User 模型扩展 Source/RemoteUserId/SyncedQuota/LastSyncAt 字段
- BillingSession 支持 SyncedUserFunding 资金来源
- 新增 SyncAuth 中间件(X-Sync-API-Key + 常量时间比较)
- 新增 PendingSyncRecord/QuotaSyncLog 数据模型
- 前端新增区域同步配置面板
- 支持 SESSION_NAME 环境变量避免多节点 cookie 冲突
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
4 недель назад
fengsilin
62737d3f8c
feat: 添加模型详情页渠道价格展示 & 优化筛选行布局
- 新增 API 端点获取模型在各渠道的定价信息,支持全局价格回退
- 在模型详情侧边栏添加渠道价格卡片,显示所有支持该模型的渠道
- 优化 HorizontalFilterRow 组件,改用 flex-wrap 自动换行布局
- 隐藏数量为 0 的模型类型筛选项
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 месяц назад
fengsilin
bfa7cc7b97
feat(token): support dynamic channel specification via colon separator
- Add support for sk-{key}:{channelId} format to specify channel dynamically
- Remove BoundChannelId field and related code
- All users can now specify channels, not just admins
- Add model validation when channel is specified
- Remove bound channel UI from token management
Breaking change: tokens can no longer be bound to channels at creation time.
Use sk-{key}:{channelId} format instead.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 месяц назад
fengsilin
15a99da48e
fix: channel pricing not working correctly
This PR fixes three issues:
1. Token bound_channel_id not updating: Add bound field to Update() method
2. Channel pricing quota_type detection: Use QuotaTypeByCall constant instead of magic number 1
3. Log display for ratio-based pricing: Set ModelPrice=-1 for ratio-based pricing
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 месяц назад
fengsilin
352806c099
feat: add dedicated API for user channel binding selection
Add a new /api/user/channels endpoint that returns only enabled channels
with non-sensitive fields (id, name, type, remark) for token channel binding.
Update EditTokenModal to use this endpoint and display remark instead of ID
in the channel dropdown.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 месяц назад
fengsilin
ffddf58e78
feat: support bound_channel_id in token CRUD
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 месяц назад
fengsilin
ab66594d9e
feat: add PricingTag CRUD controller
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 месяц назад
fengsilin
447ccd09b2
feat: add ChannelPricing CRUD controller
- GetAllChannelPricing: get all channel pricings with pagination
- GetChannelPricingByModel: get pricings for a specific model
- CreateChannelPricing: create or update channel pricing
- BatchCreateChannelPricing: batch create/update pricings
- DeleteChannelPricing: delete channel pricing
- CopyGlobalPricing: copy global pricing from ratio_setting to channel
- GetChannelPricingWithTags: get pricings with tag details
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 месяц назад
winter
08164cd0ae
fix
2 месяцев назад