From 82dc9f23effd533036f31420c165d419daffa9eb Mon Sep 17 00:00:00 2001 From: a Date: Tue, 3 Mar 2026 20:10:53 -0800 Subject: [PATCH 1/3] fix: team accounts misidentified as free, blocking Opus model access The account type fallthrough defaulted to 'free' when neither has_claude_max nor has_claude_pro was true, causing team accounts to be filtered out for Opus requests. Changed default to 'claude_max' so unrecognized subscription types are not incorrectly restricted. Co-Authored-By: Claude Opus 4.6 --- CLAUDE.md | 39 +++++++++++++++----- src/services/account/claudeAccountService.js | 2 +- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 8681d1d2..e567752d 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,6 +1,6 @@ -# CLAUDE.md <260209.0> +# CLAUDE.md -This file provides guidance to Claude Code when working with this repository. +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. ## 项目概述 @@ -83,11 +83,13 @@ data/init.json # 管理员凭据 ## 开发规范 -### 代码格式化 +### 代码风格 +- **无分号**、**单引号**、**100字符行宽**、**尾逗号 none**、**箭头函数始终加括号** +- 强制 `const`(`no-var`、`prefer-const`),严格相等(`eqeqeq`) +- 下划线前缀变量 `_var` 可豁免 unused 检查 - **必须使用 Prettier**: `npx prettier --write ` - 前端额外安装了 `prettier-plugin-tailwindcss` -- 提交前检查:`npx prettier --check ` ### 开发工作流 @@ -98,8 +100,15 @@ data/init.json # 管理员凭据 5. **测试** → `npm test` 6. **验证** → `npm run cli status` 确认服务正常 +### 测试规范 + +- 测试文件在 `tests/` 目录,命名 `*.test.js` 或 `*.spec.js` +- 使用 `jest.mock()` 模拟依赖(logger、redis、services) +- `beforeEach` 中 `jest.resetModules()`,`afterEach` 中 `jest.clearAllMocks()` + ### 前端要求 +- 技术栈:Vue 3 Composition API + Pinia + Element Plus + Tailwind CSS - 响应式设计:Tailwind CSS 响应式前缀(sm:、md:、lg:、xl:) - 暗黑模式:所有组件必须兼容,使用 `dark:` 前缀 - 主题切换:`web/admin-spa/src/stores/theme.js` 的 `useThemeStore()` @@ -124,16 +133,28 @@ data/init.json # 管理员凭据 ```bash npm install && npm run setup # 初始化 -npm run dev # 开发模式(热重载) -npm start # 生产模式 -npm run lint # ESLint 检查 -npm test # Jest + SuperTest -docker-compose up -d # Docker 部署 +npm run dev # 开发模式(nodemon 热重载,自动 lint) +npm start # 生产模式(先 lint 再启动) +npm run lint # ESLint 检查并自动修复 +npm run lint:check # ESLint 仅检查不修复 +npm run format # Prettier 格式化所有后端文件 +npm run format:check # Prettier 仅检查格式 +npm test # Jest 运行所有测试(tests/ 目录) +npm test -- <文件名> # 运行单个测试,如: npm test -- pricingService +npm test -- --coverage # 运行测试并生成覆盖率报告 npm run cli status # 系统状态 npm run data:export # 导出 Redis 数据 npm run data:debug # 调试 Redis 键 ``` +### 前端命令 + +```bash +npm run install:web # 安装前端依赖 +npm run build:web # 构建前端(生成 dist) +cd web/admin-spa && npm run dev # 前端开发模式(Vite HMR) +``` + ## 环境变量(必须) - `JWT_SECRET` — JWT 密钥(32字符+) diff --git a/src/services/account/claudeAccountService.js b/src/services/account/claudeAccountService.js index 16952951..10a878ce 100644 --- a/src/services/account/claudeAccountService.js +++ b/src/services/account/claudeAccountService.js @@ -2287,7 +2287,7 @@ class ClaudeAccountService { organizationType: profileData.organization?.organization_type, // 账号类型:Enterprise 组织按 Max 能力处理,确保可调度 Opus - accountType: hasClaudeMax ? 'claude_max' : hasClaudePro ? 'claude_pro' : 'free', + accountType: hasClaudeMax ? 'claude_max' : hasClaudePro ? 'claude_pro' : 'claude_max', // 更新时间 profileFetchedAt: new Date().toISOString() From 0cf4eac0bed5840860321f9ce3ec712afa095eb2 Mon Sep 17 00:00:00 2001 From: a Date: Tue, 3 Mar 2026 20:18:19 -0800 Subject: [PATCH 2/3] chore: change default service port from 3000 to 3001 Co-Authored-By: Claude Opus 4.6 --- Dockerfile | 4 ++-- docker-compose.yml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 932506a0..df61eb86 100644 --- a/Dockerfile +++ b/Dockerfile @@ -73,11 +73,11 @@ RUN if [ ! -f "/app/config/config.js" ] && [ -f "/app/config/config.example.js" fi # 🌐 暴露端口 -EXPOSE 3000 +EXPOSE 3001 # 🏥 健康检查 HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ - CMD curl -f http://localhost:3000/health || exit 1 + CMD curl -f http://localhost:3001/health || exit 1 # 🚀 启动应用 ENTRYPOINT ["dumb-init", "--", "/usr/local/bin/docker-entrypoint.sh"] diff --git a/docker-compose.yml b/docker-compose.yml index d8f78a24..a9befb1f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,14 +11,14 @@ services: restart: unless-stopped ports: # 绑定地址:生产环境建议使用反向代理,设置 BIND_HOST=127.0.0.1 - - "${BIND_HOST:-0.0.0.0}:${PORT:-3000}:3000" + - "${BIND_HOST:-0.0.0.0}:${PORT:-3001}:3001" volumes: - ./logs:/app/logs - ./data:/app/data environment: # 🌐 服务器配置 - NODE_ENV=production - - PORT=3000 + - PORT=3001 - HOST=0.0.0.0 # 🔧 请求体大小配置 @@ -82,7 +82,7 @@ services: networks: - claude-relay-network healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:3000/health"] + test: ["CMD", "curl", "-f", "http://localhost:3001/health"] interval: 30s timeout: 10s retries: 3 From 78649cad3b2fa03657a08d69a9e1d814ef47b326 Mon Sep 17 00:00:00 2001 From: bill Date: Wed, 4 Mar 2026 21:21:33 -0800 Subject: [PATCH 3/3] Revert "chore: change default service port from 3000 to 3001" This reverts commit 0cf4eac0bed5840860321f9ce3ec712afa095eb2. --- Dockerfile | 4 ++-- docker-compose.yml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index df61eb86..932506a0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -73,11 +73,11 @@ RUN if [ ! -f "/app/config/config.js" ] && [ -f "/app/config/config.example.js" fi # 🌐 暴露端口 -EXPOSE 3001 +EXPOSE 3000 # 🏥 健康检查 HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ - CMD curl -f http://localhost:3001/health || exit 1 + CMD curl -f http://localhost:3000/health || exit 1 # 🚀 启动应用 ENTRYPOINT ["dumb-init", "--", "/usr/local/bin/docker-entrypoint.sh"] diff --git a/docker-compose.yml b/docker-compose.yml index a9befb1f..d8f78a24 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,14 +11,14 @@ services: restart: unless-stopped ports: # 绑定地址:生产环境建议使用反向代理,设置 BIND_HOST=127.0.0.1 - - "${BIND_HOST:-0.0.0.0}:${PORT:-3001}:3001" + - "${BIND_HOST:-0.0.0.0}:${PORT:-3000}:3000" volumes: - ./logs:/app/logs - ./data:/app/data environment: # 🌐 服务器配置 - NODE_ENV=production - - PORT=3001 + - PORT=3000 - HOST=0.0.0.0 # 🔧 请求体大小配置 @@ -82,7 +82,7 @@ services: networks: - claude-relay-network healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:3001/health"] + test: ["CMD", "curl", "-f", "http://localhost:3000/health"] interval: 30s timeout: 10s retries: 3