mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 17:30:23 +08:00
fix(frontend): 为配额自动刷新加入 5 分钟冷却并优化 OAuth org 徽章显示
- 新增 quotaAutoRefreshCooldown 工具,按 provider 维度限制后台自动刷新频率,手动触发(刷新 token、变更 key)通过 ignoreCooldown 绕过 - OAuth org 徽章去除 org- 前缀后再缩略,避免 org:org-xx 的重复前缀,并缩小字号高度以适配紧凑布局
This commit is contained in:
@@ -15,7 +15,7 @@ describe('getOAuthOrgBadge', () => {
|
||||
|
||||
expect(badge).toEqual({
|
||||
id: 'org-personal-1234',
|
||||
label: 'org:org-pe...1234',
|
||||
label: 'org:person...1234',
|
||||
title: 'name: Workspace Alpha | account_id: acct-demo-001 | account_user_id: user-1__acct-demo-001 | org_id: org-personal-1234 | org_title: Personal',
|
||||
})
|
||||
})
|
||||
|
||||
@@ -22,6 +22,19 @@ function readStr(raw: unknown): string {
|
||||
return typeof raw === 'string' ? raw.trim() : ''
|
||||
}
|
||||
|
||||
function stripOAuthOrganizationPrefix(orgId: string): string {
|
||||
return orgId.replace(/^org[-_:]+/i, '').trim()
|
||||
}
|
||||
|
||||
function formatOAuthOrganizationBadge(orgId: string): string {
|
||||
const compactOrgId = stripOAuthOrganizationPrefix(orgId)
|
||||
const normalized = compactOrgId || orgId
|
||||
if (normalized.length <= 10) {
|
||||
return `org:${normalized}`
|
||||
}
|
||||
return `org:${normalized.slice(0, 6)}...${normalized.slice(-4)}`
|
||||
}
|
||||
|
||||
function formatOAuthAccountBadge(accountId: string): string {
|
||||
return accountId.slice(0, 8)
|
||||
}
|
||||
@@ -67,7 +80,7 @@ export function getOAuthOrgBadge(
|
||||
|
||||
const badgeId = org?.id || accountId || accountUserId || ''
|
||||
const label = org?.id
|
||||
? `org:${formatOAuthIdentityShort(org.id, 6, 4)}`
|
||||
? formatOAuthOrganizationBadge(org.id)
|
||||
: accountId
|
||||
? formatOAuthAccountBadge(accountId)
|
||||
: accountUserId
|
||||
|
||||
Reference in New Issue
Block a user