feat: add comprehensive 401 error handling and account status management

- Add 401 error detection and automatic account suspension after 3 consecutive failures
- Implement account status reset functionality for clearing all error states
- Enhance admin interface with status reset controls and improved status display
- Upgrade service management script with backup protection and retry mechanisms
- Add mandatory code formatting requirements using Prettier
- Improve account selector with detailed status information and color coding

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
shaw
2025-08-08 00:35:26 +08:00
parent d8dd2faf72
commit 31bdb4aa8c
9 changed files with 456 additions and 31 deletions

View File

@@ -101,12 +101,14 @@
<span
class="ml-2 rounded-full px-2 py-0.5 text-xs"
:class="
account.status === 'active'
account.isActive
? 'bg-green-100 text-green-700'
: 'bg-red-100 text-red-700'
: account.status === 'unauthorized'
? 'bg-orange-100 text-orange-700'
: 'bg-red-100 text-red-700'
"
>
{{ account.status === 'active' ? '正常' : '异常' }}
{{ getAccountStatusText(account) }}
</span>
</div>
<span class="text-xs text-gray-400">
@@ -134,12 +136,14 @@
<span
class="ml-2 rounded-full px-2 py-0.5 text-xs"
:class="
account.status === 'active'
account.isActive
? 'bg-green-100 text-green-700'
: 'bg-red-100 text-red-700'
: account.status === 'unauthorized'
? 'bg-orange-100 text-orange-700'
: 'bg-red-100 text-red-700'
"
>
{{ account.status === 'active' ? '正常' : '异常' }}
{{ getAccountStatusText(account) }}
</span>
</div>
<span class="text-xs text-gray-400">
@@ -224,14 +228,38 @@ const selectedLabel = computed(() => {
const account = props.accounts.find(
(a) => a.id === accountId && a.platform === 'claude-console'
)
return account ? `${account.name} (${account.status === 'active' ? '正常' : '异常'})` : ''
return account ? `${account.name} (${getAccountStatusText(account)})` : ''
}
// OAuth 账号
const account = props.accounts.find((a) => a.id === props.modelValue)
return account ? `${account.name} (${account.status === 'active' ? '正常' : '异常'})` : ''
return account ? `${account.name} (${getAccountStatusText(account)})` : ''
})
// 获取账户状态文本
const getAccountStatusText = (account) => {
if (!account) return '未知'
// 优先使用 isActive 判断
if (account.isActive === false) {
// 根据 status 提供更详细的状态信息
switch (account.status) {
case 'unauthorized':
return '未授权'
case 'error':
return 'Token错误'
case 'created':
return '待验证'
case 'rate_limited':
return '限流中'
default:
return '异常'
}
}
return '正常'
}
// 按创建时间倒序排序账号
const sortedAccounts = computed(() => {
return [...props.accounts].sort((a, b) => {