mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-31 00:24:38 +00:00
feat(frontend): 标明 OpenAI 认证模式
This commit is contained in:
@@ -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')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user