feat: 引入 status_snapshot 统一 provider key 状态管理

- 新增 StatusSnapshot 模型,聚合 OAuth / 账号 / 配额三维状态
- 新增 StatusSnapshotStore 负责快照的持久化与查询
- 重构 response_builder / endpoint_models,基于 snapshot 输出状态字段
- 前端抽取 providerKeyStatus / oauthRefreshFeedback 工具函数,
  统一 PoolManagement、ProviderDetailDrawer、BatchDialog 的状态展示
- errorParser 增加已知 OAuth 错误的友好提示
- refresher 适配 snapshot 写入,account_state 扩展状态分类
- 新增 alembic 迁移及存量数据回填脚本
- 补充前后端单元测试
This commit is contained in:
fawney19
2026-03-20 19:16:52 +08:00
parent 25d38ae632
commit 46737d32f8
39 changed files with 2326 additions and 470 deletions

View File

@@ -174,15 +174,18 @@ export function getOAuthExpiresCountdown(
invalidReason?: string | null
): OAuthStatusInfo | null {
void _tick
const normalizedInvalidReason = typeof invalidReason === 'string'
? invalidReason.trim()
: ''
// 优先检查失效状态(失效比过期更严重)
if (invalidAt != null) {
if (invalidAt != null || normalizedInvalidReason) {
return {
text: '已失效',
isExpired: false,
isExpiringSoon: false,
isInvalid: true,
invalidReason: invalidReason || undefined
invalidReason: normalizedInvalidReason || undefined
}
}