IanShaw027
|
ecfad788d9
|
feat(全栈): 实现简易模式核心功能
**功能概述**:
实现简易模式(Simple Mode),为个人用户和小团队提供简化的使用体验,隐藏复杂的分组、订阅、配额等概念。
**后端改动**:
1. 配置系统
- 新增 run_mode 配置项(standard/simple)
- 支持环境变量 RUN_MODE
- 默认值为 standard
2. 数据库初始化
- 自动创建3个默认分组:anthropic-default、openai-default、gemini-default
- 默认分组配置:无并发限制、active状态、非独占
- 幂等性保证:重复启动不会重复创建
3. 账号管理
- 创建账号时自动绑定对应平台的默认分组
- 如果未指定分组,自动查找并绑定默认分组
**前端改动**:
1. 状态管理
- authStore 新增 isSimpleMode 计算属性
- 从后端API获取并同步运行模式
2. UI隐藏
- 侧边栏:隐藏分组管理、订阅管理、兑换码菜单
- 账号管理页面:隐藏分组列
- 创建/编辑账号对话框:隐藏分组选择器
3. 路由守卫
- 限制访问分组、订阅、兑换码相关页面
- 访问受限页面时自动重定向到仪表板
**配置示例**:
```yaml
run_mode: simple
run_mode: standard
```
**影响范围**:
- 后端:配置、数据库迁移、账号服务
- 前端:认证状态、路由、UI组件
- 部署:配置文件示例
**兼容性**:
- 简易模式和标准模式可无缝切换
- 不需要数据迁移
- 现有数据不受影响
|
2025-12-29 03:24:15 +08:00 |
|
noreply
|
cbfce49aa1
|
feat: Schedule batch update for account last_used_at
Implement deferred batch update mechanism to reduce database load:
- Add DeferredService for batching account last_used_at updates
- Add TimingWheelService for efficient recurring task scheduling
- Integrate with GatewayService and OpenAIGatewayService
- Implement BatchUpdateLastUsed repository method using CASE...WHEN SQL
- Fix golangci-lint error: Replace interface{} with any
Benefits:
- Reduces database writes by batching updates (10-second intervals)
- Improves request throughput by deferring non-critical updates
- Maintains accurate account usage tracking for scheduling
|
2025-12-28 09:49:54 +08:00 |
|
daodao97
|
95583fce83
|
feat: cc/codex support account retry
|
2025-12-27 12:05:38 +08:00 |
|
IanShaw027
|
bfcd9501c2
|
merge: 合并 upstream/main 解决 PR #37 冲突
- 删除 backend/internal/model/account.go 符合重构方向
- 合并最新的项目结构重构
- 包含 SSE 格式解析修复
- 更新依赖和配置文件
|
2025-12-26 21:56:08 +08:00 |
|
shaw
|
2d89f36687
|
Merge PR #42: fix(sse): 修复非标准 SSE 格式解析问题
|
2025-12-26 21:31:34 +08:00 |
|
ianshaw
|
16eec4eb41
|
fix(sse): 修复非标准 SSE 格式解析问题
部分上游 API 返回的 SSE 格式不符合标准规范:
- 标准格式: `data: {...}`(冒号后有空格)
- 非标准格式: `data:{...}`(冒号后无空格)
使用预编译正则 `^data:\s*` 统一处理两种格式。
|
2025-12-26 03:49:55 -08:00 |
|
Forest
|
e5a77853b0
|
refactor: 调整项目结构为单向依赖
|
2025-12-26 16:45:40 +08:00 |
|
ianshaw
|
b2d71da2a2
|
feat(backend): 实现 Gemini AI Studio OAuth 和消息兼容服务
- gemini_oauth_service.go: 新增 AI Studio OAuth 类型支持
- gemini_token_provider.go: Token 提供器增强
- gemini_messages_compat_service.go: 支持 AI Studio 端点
- account_test_service.go: Gemini 账户可用性检测
- gateway_service.go: 网关服务适配
- openai_gateway_service.go: OpenAI 兼容层调整
|
2025-12-26 00:11:03 -08:00 |
|
Forest
|
f51ad2e126
|
refactor: 删除 ports 目录
|
2025-12-25 17:15:01 +08:00 |
|
hi_yueban
|
f57f12c6cc
|
fix: 修复 OpenAI 账号 5h/7d 使用限制显示错误的问题 (#30)
* fix: 修复 OpenAI 账号 5h/7d 使用限制显示错误的问题
问题描述:
- 账号管理页面中,OpenAI OAuth 账号的 5h 列显示 7 天的剩余时间
- 7d 列却显示几小时的剩余时间
- 根本原因: OpenAI 响应头中 primary/secondary 的实际含义与代码假设相反
修复方案:
1. 后端归一化 (openai_gateway_service.go):
- 根据 window_minutes 动态判断哪个是 5h/7d 限制
- 新增规范字段 codex_5h_* 和 codex_7d_*
- 保留旧字段以兼容性
2. 前端适配 (AccountUsageCell.vue):
- 优先使用新的规范字段
- Fallback 到旧字段时基于 window_minutes 动态判断
- 更新 computed 属性命名
3. 类型定义更新 (types/index.ts):
- 添加新的规范字段定义
- 更新注释说明实际语义由 window_minutes 决定
🤖 Generated with Claude Code and Codex collaboration
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: OpenAI Codex <noreply@openai.com>
* fix: 改进窗口判断逻辑,修复两个窗口都小于阈值时的bug
问题:
当两个窗口都小于360分钟时(如 primary=180分钟,secondary=300分钟),
之前的逻辑会导致:
- primary5h = true, secondary5h = true
- 5h 字段会使用 primary(错误)
- 7d 字段没有数据(bug)
修复方案:
改用比较策略:
1. 当两个窗口都存在时:较小的分配给5h,较大的分配给7d
2. 当只有一个窗口时:根据大小(<=360分钟)判断是5h还是7d
3. 确保数据不会丢失,逻辑更健壮
示例:
- Primary: 180分钟, Secondary: 300分钟
→ 5h 使用 Primary(180分钟), 7d 使用 Secondary(300分钟) ✓
🤖 Generated with Claude Code
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* fix: 修正窗口大小判断逻辑 - 不能用剩余时间判断窗口类型
**严重bug修复:**
之前的 fallback 逻辑错误地使用 reset_after_seconds 来判断窗口大小。
问题示例:
- 周限制(7d)剩余 2h → reset_after_seconds = 7200秒
- 5h限制 剩余 4h → reset_after_seconds = 14400秒
- 错误逻辑:7200/60 < 14400/60,把周限制当成5h ❌
根本问题:
- window_minutes = 窗口的总大小(300 or 10080)
- reset_after_seconds = 距离重置的剩余时间(变化的)
- 不能用剩余时间来判断窗口类型!
修复方案:
1. **只使用 window_minutes** 来判断窗口大小
2. 移除错误的 reset_after_seconds fallback
3. 如果 window_minutes 都不存在,使用传统假设
4. 添加详细注释说明这个陷阱
🤖 Generated with Claude Code
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* fix: 修复 lint 问题 - 改进 fallback 逻辑的变量赋值
问题:
第882-883行的简单布尔赋值可能触发 ineffassign 或 staticcheck 警告:
use5hFromSecondary = snapshot.SecondaryUsedPercent != nil
use7dFromPrimary = snapshot.PrimaryUsedPercent != nil
修复:
改用明确的 if 语句检查任意字段是否存在,更符合代码意图:
- 如果 secondary 的任意字段存在,将其视为 5h
- 如果 primary 的任意字段存在,将其视为 7d
这样逻辑更清晰,也避免了 lint 警告。
---------
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-authored-by: OpenAI Codex <noreply@openai.com>
|
2025-12-25 17:00:02 +08:00 |
|
Forest
|
836c4dda2b
|
refactor: 重命名 go module
|
2025-12-24 21:07:21 +08:00 |
|
shaw
|
f25ac3aff5
|
feat: OpenAI OAuth账号显示Codex使用量
从响应头提取x-codex-*使用量信息并保存到账号Extra字段,
前端账号列表展示5h/7d窗口的使用进度条。
|
2025-12-23 16:26:07 +08:00 |
|
shaw
|
eb55947ec4
|
fix: 修复golangci-lint检查问题
- 移除OpenAIGatewayHandler中未使用的userService字段
- 将账号类型判断的if-else链改为switch语句
|
2025-12-23 10:25:32 +08:00 |
|
shaw
|
fda753278c
|
feat: 平台图标与计费修复
- fix(billing): 修复 OpenAI 兼容 API 缓存 token 重复计费问题
- fix(auth): 隐藏数据库错误详情,返回通用服务不可用错误
- feat(ui): 新增 PlatformIcon 组件,GroupBadge 支持平台颜色区分
- feat(ui): 账号管理新增重置状态按钮,重授权后自动清除错误
- feat(ui): 分组管理新增计费类型列,显示订阅限额信息
- ui: 首页 GPT 状态改为已支持
|
2025-12-23 10:01:58 +08:00 |
|
shaw
|
6c469b42ed
|
feat: 新增支持codex转发
|
2025-12-22 22:58:31 +08:00 |
|