feat: add complete MFA support

This commit is contained in:
Awuqing
2026-04-25 21:14:39 +08:00
parent 2997e971a6
commit 7dfd12254b
34 changed files with 4114 additions and 114 deletions

View File

@@ -5,15 +5,18 @@ describe('notification field config', () => {
it('returns readable type labels', () => {
expect(getNotificationTypeLabel('email')).toBe('Email')
expect(getNotificationTypeLabel('telegram')).toBe('Telegram')
expect(getNotificationTypeLabel('sms')).toBe('SMS Webhook')
})
it('returns required fields for each notification type', () => {
const emailFields = getNotificationFieldConfigs('email')
const webhookFields = getNotificationFieldConfigs('webhook')
const telegramFields = getNotificationFieldConfigs('telegram')
const smsFields = getNotificationFieldConfigs('sms')
expect(emailFields.some((field) => field.key === 'host' && field.required)).toBe(true)
expect(webhookFields.some((field) => field.key === 'url' && field.required)).toBe(true)
expect(telegramFields.some((field) => field.key === 'botToken' && field.required)).toBe(true)
expect(smsFields.some((field) => field.key === 'url' && field.required)).toBe(true)
})
})

View File

@@ -13,6 +13,10 @@ const FIELD_CONFIG_MAP: Record<NotificationType, NotificationFieldConfig[]> = {
{ key: 'url', label: 'Webhook URL', type: 'input', required: true, placeholder: 'https://hooks.example.com/backupx' },
{ key: 'secret', label: '共享密钥', type: 'password', placeholder: '可选', sensitive: true },
],
sms: [
{ key: 'url', label: 'SMS Webhook URL', type: 'input', required: true, placeholder: 'https://sms-gateway.example.com/send' },
{ key: 'secret', label: '共享密钥', type: 'password', placeholder: '可选', sensitive: true },
],
telegram: [
{ key: 'botToken', label: 'Bot Token', type: 'password', required: true, placeholder: '123456:ABC', sensitive: true },
{ key: 'chatId', label: 'Chat ID', type: 'input', required: true, placeholder: '-100xxxxxxxxxx' },
@@ -23,6 +27,7 @@ export const notificationTypeOptions = [
{ label: 'Email', value: 'email' },
{ label: 'Webhook', value: 'webhook' },
{ label: 'Telegram', value: 'telegram' },
{ label: 'SMS Webhook', value: 'sms' },
] as const
export function getNotificationTypeLabel(type: NotificationType) {
@@ -33,6 +38,8 @@ export function getNotificationTypeLabel(type: NotificationType) {
return 'Webhook'
case 'telegram':
return 'Telegram'
case 'sms':
return 'SMS Webhook'
default:
return type
}