mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-22 16:43:35 +00:00
refactor(backend): 统一账户平台标识字段
WHAT: 统一 Claude 账户的平台标识,从 claude-oauth 改为 claude WHY: 简化平台标识命名规范,提高前后端数据一致性,为多平台支持奠定基础 HOW: 在账户创建和查询接口中添加 platform 字段支持;更新 claudeAccountService 默认平台标识;保持向后兼容性,旧数据自动使用默认值
This commit is contained in:
@@ -79,7 +79,7 @@ async function testApiResponse() {
|
|||||||
console.log('\n\n📊 验证结果:')
|
console.log('\n\n📊 验证结果:')
|
||||||
|
|
||||||
// 检查 platform 字段
|
// 检查 platform 字段
|
||||||
const claudeWithPlatform = claudeAccounts.filter((a) => a.platform === 'claude-oauth')
|
const claudeWithPlatform = claudeAccounts.filter((a) => a.platform === 'claude')
|
||||||
const consoleWithPlatform = consoleAccounts.filter((a) => a.platform === 'claude-console')
|
const consoleWithPlatform = consoleAccounts.filter((a) => a.platform === 'claude-console')
|
||||||
|
|
||||||
if (claudeWithPlatform.length === claudeAccounts.length) {
|
if (claudeWithPlatform.length === claudeAccounts.length) {
|
||||||
|
|||||||
@@ -1242,6 +1242,7 @@ router.post('/claude-accounts', authenticateAdmin, async (req, res) => {
|
|||||||
claudeAiOauth,
|
claudeAiOauth,
|
||||||
proxy,
|
proxy,
|
||||||
accountType,
|
accountType,
|
||||||
|
platform = 'claude',
|
||||||
priority,
|
priority,
|
||||||
groupId
|
groupId
|
||||||
} = req.body
|
} = req.body
|
||||||
@@ -1279,6 +1280,7 @@ router.post('/claude-accounts', authenticateAdmin, async (req, res) => {
|
|||||||
claudeAiOauth,
|
claudeAiOauth,
|
||||||
proxy,
|
proxy,
|
||||||
accountType: accountType || 'shared', // 默认为共享类型
|
accountType: accountType || 'shared', // 默认为共享类型
|
||||||
|
platform,
|
||||||
priority: priority || 50 // 默认优先级为50
|
priority: priority || 50 // 默认优先级为50
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ class ClaudeAccountService {
|
|||||||
proxy = null, // { type: 'socks5', host: 'localhost', port: 1080, username: '', password: '' }
|
proxy = null, // { type: 'socks5', host: 'localhost', port: 1080, username: '', password: '' }
|
||||||
isActive = true,
|
isActive = true,
|
||||||
accountType = 'shared', // 'dedicated' or 'shared'
|
accountType = 'shared', // 'dedicated' or 'shared'
|
||||||
|
platform = 'claude',
|
||||||
priority = 50, // 调度优先级 (1-100,数字越小优先级越高)
|
priority = 50, // 调度优先级 (1-100,数字越小优先级越高)
|
||||||
schedulable = true, // 是否可被调度
|
schedulable = true, // 是否可被调度
|
||||||
subscriptionInfo = null // 手动设置的订阅信息
|
subscriptionInfo = null // 手动设置的订阅信息
|
||||||
@@ -79,7 +80,8 @@ class ClaudeAccountService {
|
|||||||
scopes: claudeAiOauth.scopes.join(' '),
|
scopes: claudeAiOauth.scopes.join(' '),
|
||||||
proxy: proxy ? JSON.stringify(proxy) : '',
|
proxy: proxy ? JSON.stringify(proxy) : '',
|
||||||
isActive: isActive.toString(),
|
isActive: isActive.toString(),
|
||||||
accountType, // 账号类型:'dedicated' 或 'shared'
|
accountType, // 账号类型:'dedicated' 或 'shared' 或 'group'
|
||||||
|
platform,
|
||||||
priority: priority.toString(), // 调度优先级
|
priority: priority.toString(), // 调度优先级
|
||||||
createdAt: new Date().toISOString(),
|
createdAt: new Date().toISOString(),
|
||||||
lastUsedAt: '',
|
lastUsedAt: '',
|
||||||
@@ -108,7 +110,8 @@ class ClaudeAccountService {
|
|||||||
scopes: '',
|
scopes: '',
|
||||||
proxy: proxy ? JSON.stringify(proxy) : '',
|
proxy: proxy ? JSON.stringify(proxy) : '',
|
||||||
isActive: isActive.toString(),
|
isActive: isActive.toString(),
|
||||||
accountType, // 账号类型:'dedicated' 或 'shared'
|
accountType, // 账号类型:'dedicated' 或 'shared' 或 'group'
|
||||||
|
platform,
|
||||||
priority: priority.toString(), // 调度优先级
|
priority: priority.toString(), // 调度优先级
|
||||||
createdAt: new Date().toISOString(),
|
createdAt: new Date().toISOString(),
|
||||||
lastUsedAt: '',
|
lastUsedAt: '',
|
||||||
@@ -151,6 +154,7 @@ class ClaudeAccountService {
|
|||||||
isActive,
|
isActive,
|
||||||
proxy,
|
proxy,
|
||||||
accountType,
|
accountType,
|
||||||
|
platform,
|
||||||
priority,
|
priority,
|
||||||
status: accountData.status,
|
status: accountData.status,
|
||||||
createdAt: accountData.createdAt,
|
createdAt: accountData.createdAt,
|
||||||
@@ -444,7 +448,7 @@ class ClaudeAccountService {
|
|||||||
errorMessage: account.errorMessage,
|
errorMessage: account.errorMessage,
|
||||||
accountType: account.accountType || 'shared', // 兼容旧数据,默认为共享
|
accountType: account.accountType || 'shared', // 兼容旧数据,默认为共享
|
||||||
priority: parseInt(account.priority) || 50, // 兼容旧数据,默认优先级50
|
priority: parseInt(account.priority) || 50, // 兼容旧数据,默认优先级50
|
||||||
platform: 'claude-oauth', // 添加平台标识,用于前端区分
|
platform: account.platform || 'claude', // 添加平台标识,用于前端区分
|
||||||
createdAt: account.createdAt,
|
createdAt: account.createdAt,
|
||||||
lastUsedAt: account.lastUsedAt,
|
lastUsedAt: account.lastUsedAt,
|
||||||
lastRefreshAt: account.lastRefreshAt,
|
lastRefreshAt: account.lastRefreshAt,
|
||||||
|
|||||||
Reference in New Issue
Block a user