feat(frontend): 标明 OpenAI 认证模式

This commit is contained in:
cat
2026-07-14 19:25:13 +08:00
parent ec7c1b6f72
commit 6485081122
6 changed files with 50 additions and 13 deletions
@@ -77,6 +77,7 @@ const { t } = useI18n()
interface Props {
platform: AccountPlatform
type: AccountType
authMode?: string
planType?: string
privacyMode?: string
subscriptionExpiresAt?: string
@@ -92,7 +93,15 @@ const platformLabel = computed(() => {
return 'Gemini'
})
const normalizedAuthMode = computed(() =>
(props.authMode || '').trim().toLowerCase().replace(/[\s_-]+/g, '')
)
const typeLabel = computed(() => {
if (props.platform === 'openai' && props.type === 'oauth') {
if (normalizedAuthMode.value === 'agentidentity') return 'Agent Identity'
if (normalizedAuthMode.value === 'personalaccesstoken') return 'PAT'
}
switch (props.type) {
case 'oauth':
return 'OAuth'
@@ -62,3 +62,24 @@ describe('PlatformTypeBadge Grok plans', () => {
expect(wrapper.findAll('path')).toHaveLength(2)
})
})
describe('PlatformTypeBadge OpenAI authentication modes', () => {
it('distinguishes Agent Identity, PAT, and OAuth accounts', async () => {
const wrapper = mount(PlatformTypeBadge, {
props: {
platform: 'openai',
type: 'oauth',
authMode: 'agentIdentity',
},
})
expect(wrapper.text()).toContain('Agent Identity')
await wrapper.setProps({ authMode: 'personalAccessToken' })
expect(wrapper.text()).toContain('PAT')
expect(wrapper.text()).not.toContain('Agent Identity')
await wrapper.setProps({ authMode: undefined })
expect(wrapper.text()).toContain('OAuth')
})
})