refactor(backend): 统一账户平台标识字段

WHAT: 统一 Claude 账户的平台标识,从 claude-oauth 改为 claude
WHY: 简化平台标识命名规范,提高前后端数据一致性,为多平台支持奠定基础
HOW: 在账户创建和查询接口中添加 platform 字段支持;更新 claudeAccountService 默认平台标识;保持向后兼容性,旧数据自动使用默认值
This commit is contained in:
mouyong
2025-08-20 21:40:24 +08:00
parent 54dca0f285
commit 5af8913954
3 changed files with 10 additions and 4 deletions

View File

@@ -1242,6 +1242,7 @@ router.post('/claude-accounts', authenticateAdmin, async (req, res) => {
claudeAiOauth,
proxy,
accountType,
platform = 'claude',
priority,
groupId
} = req.body
@@ -1279,6 +1280,7 @@ router.post('/claude-accounts', authenticateAdmin, async (req, res) => {
claudeAiOauth,
proxy,
accountType: accountType || 'shared', // 默认为共享类型
platform,
priority: priority || 50 // 默认优先级为50
})

View File

@@ -55,6 +55,7 @@ class ClaudeAccountService {
proxy = null, // { type: 'socks5', host: 'localhost', port: 1080, username: '', password: '' }
isActive = true,
accountType = 'shared', // 'dedicated' or 'shared'
platform = 'claude',
priority = 50, // 调度优先级 (1-100数字越小优先级越高)
schedulable = true, // 是否可被调度
subscriptionInfo = null // 手动设置的订阅信息
@@ -79,7 +80,8 @@ class ClaudeAccountService {
scopes: claudeAiOauth.scopes.join(' '),
proxy: proxy ? JSON.stringify(proxy) : '',
isActive: isActive.toString(),
accountType, // 账号类型:'dedicated' 或 'shared'
accountType, // 账号类型:'dedicated' 或 'shared' 或 'group'
platform,
priority: priority.toString(), // 调度优先级
createdAt: new Date().toISOString(),
lastUsedAt: '',
@@ -108,7 +110,8 @@ class ClaudeAccountService {
scopes: '',
proxy: proxy ? JSON.stringify(proxy) : '',
isActive: isActive.toString(),
accountType, // 账号类型:'dedicated' 或 'shared'
accountType, // 账号类型:'dedicated' 或 'shared' 或 'group'
platform,
priority: priority.toString(), // 调度优先级
createdAt: new Date().toISOString(),
lastUsedAt: '',
@@ -151,6 +154,7 @@ class ClaudeAccountService {
isActive,
proxy,
accountType,
platform,
priority,
status: accountData.status,
createdAt: accountData.createdAt,
@@ -444,7 +448,7 @@ class ClaudeAccountService {
errorMessage: account.errorMessage,
accountType: account.accountType || 'shared', // 兼容旧数据,默认为共享
priority: parseInt(account.priority) || 50, // 兼容旧数据默认优先级50
platform: 'claude-oauth', // 添加平台标识,用于前端区分
platform: account.platform || 'claude', // 添加平台标识,用于前端区分
createdAt: account.createdAt,
lastUsedAt: account.lastUsedAt,
lastRefreshAt: account.lastRefreshAt,