mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-22 16:43:35 +00:00
feat: 添加账户订阅到期时间管理功能
## 新增功能 - 支持为 Claude 账户设置订阅到期时间 - 前端提供到期时间选择器(快捷选项 + 自定义日期) - 账户列表显示到期状态(已过期/即将过期/永不过期) - 新增独立的到期时间编辑弹窗组件 ## 技术变更 - 后端新增 subscriptionExpiresAt 字段存储 - 前端使用 expiresAt 字段进行交互 - 支持创建、编辑、显示完整流程 ## 包含文件 - src/routes/admin.js: POST/PUT 端点支持 expiresAt 字段 - src/services/claudeAccountService.js: 存储和返回到期时间 - web/admin-spa/src/components/accounts/AccountForm.vue: 表单添加到期时间选择 - web/admin-spa/src/views/AccountsView.vue: 列表显示和编辑功能 - web/admin-spa/src/components/accounts/AccountExpiryEditModal.vue: 新增编辑弹窗 - account_expire_feature.md: 代码评审报告和优化建议 ## 注意事项 ⚠️ 本次提交包含初步实现,详细的优化建议请查看 account_expire_feature.md 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -2243,7 +2243,8 @@ router.post('/claude-accounts', authenticateAdmin, async (req, res) => {
|
||||
autoStopOnWarning,
|
||||
useUnifiedUserAgent,
|
||||
useUnifiedClientId,
|
||||
unifiedClientId
|
||||
unifiedClientId,
|
||||
expiresAt
|
||||
} = req.body
|
||||
|
||||
if (!name) {
|
||||
@@ -2286,7 +2287,8 @@ router.post('/claude-accounts', authenticateAdmin, async (req, res) => {
|
||||
autoStopOnWarning: autoStopOnWarning === true, // 默认为false
|
||||
useUnifiedUserAgent: useUnifiedUserAgent === true, // 默认为false
|
||||
useUnifiedClientId: useUnifiedClientId === true, // 默认为false
|
||||
unifiedClientId: unifiedClientId || '' // 统一的客户端标识
|
||||
unifiedClientId: unifiedClientId || '', // 统一的客户端标识
|
||||
expiresAt: expiresAt || null // 账户订阅到期时间
|
||||
})
|
||||
|
||||
// 如果是分组类型,将账户添加到分组
|
||||
@@ -2373,7 +2375,14 @@ router.put('/claude-accounts/:accountId', authenticateAdmin, async (req, res) =>
|
||||
}
|
||||
}
|
||||
|
||||
await claudeAccountService.updateAccount(accountId, updates)
|
||||
// 映射字段名:前端的expiresAt -> 后端的subscriptionExpiresAt
|
||||
const mappedUpdates = { ...updates }
|
||||
if ('expiresAt' in mappedUpdates) {
|
||||
mappedUpdates.subscriptionExpiresAt = mappedUpdates.expiresAt
|
||||
delete mappedUpdates.expiresAt
|
||||
}
|
||||
|
||||
await claudeAccountService.updateAccount(accountId, mappedUpdates)
|
||||
|
||||
logger.success(`📝 Admin updated Claude account: ${accountId}`)
|
||||
return res.json({ success: true, message: 'Claude account updated successfully' })
|
||||
|
||||
Reference in New Issue
Block a user