diff --git a/packages/frontend/src/locales/en.json b/packages/frontend/src/locales/en.json index 473c7c7..576c0ba 100644 --- a/packages/frontend/src/locales/en.json +++ b/packages/frontend/src/locales/en.json @@ -571,6 +571,36 @@ "error": { "sidebarPersistentSaveFailed": "Failed to save sidebar setting." } + }, + "ipBlacklist": { + "title": "IP Blacklist Management", + "description": "Configure login attempt limits and automatic ban duration. Local addresses (127.0.0.1, ::1) will not be banned.", + "maxAttemptsLabel": "Max Failed Attempts:", + "banDurationLabel": "Ban Duration (seconds):", + "saveConfigButton": "Save Configuration", + "currentBannedTitle": "Currently Banned IP Addresses", + "loadingList": "Loading blacklist...", + "noBannedIps": "No IP addresses are currently in the blacklist.", + "confirmRemoveIp": "Are you sure you want to remove the IP address \"{ip}\" from the blacklist?", + "table": { + "ipAddress": "IP Address", + "attempts": "Attempts", + "lastAttempt": "Last Attempt", + "bannedUntil": "Banned Until", + "actions": "Actions", + "removeButton": "Remove", + "deleting": "Deleting..." + }, + "success": { + "configUpdated": "Blacklist configuration updated successfully." + }, + "error": { + "fetchFailed": "Failed to fetch blacklist", + "deleteFailed": "Failed to delete", + "invalidMaxAttempts": "Max failed attempts must be a positive integer.", + "invalidBanDuration": "Ban duration must be a positive integer (seconds).", + "updateConfigFailed": "Failed to update blacklist configuration" + } } }, "common": { diff --git a/packages/frontend/src/locales/zh.json b/packages/frontend/src/locales/zh.json index 1373c95..b714c63 100644 --- a/packages/frontend/src/locales/zh.json +++ b/packages/frontend/src/locales/zh.json @@ -571,6 +571,36 @@ "error": { "sidebarPersistentSaveFailed": "保存侧边栏设置失败。" } + }, + "ipBlacklist": { + "title": "IP 黑名单管理", + "description": "配置登录失败次数限制和自动封禁时长。本地地址 (127.0.0.1, ::1) 不会被封禁。", + "maxAttemptsLabel": "最大失败次数:", + "banDurationLabel": "封禁时长 (秒):", + "saveConfigButton": "保存配置", + "currentBannedTitle": "当前已封禁的 IP 地址", + "loadingList": "正在加载黑名单...", + "noBannedIps": "当前没有 IP 地址在黑名单中。", + "confirmRemoveIp": "确定要从黑名单中移除 IP 地址 \"{ip}\" 吗?", + "table": { + "ipAddress": "IP 地址", + "attempts": "失败次数", + "lastAttempt": "最后尝试时间", + "bannedUntil": "封禁截止时间", + "actions": "操作", + "removeButton": "移除", + "deleting": "删除中..." + }, + "success": { + "configUpdated": "黑名单配置已成功更新。" + }, + "error": { + "fetchFailed": "获取黑名单失败", + "deleteFailed": "删除失败", + "invalidMaxAttempts": "最大失败次数必须是正整数。", + "invalidBanDuration": "封禁时长必须是正整数(秒)。", + "updateConfigFailed": "更新黑名单配置失败" + } } }, "common": { diff --git a/packages/frontend/src/views/SettingsView.vue b/packages/frontend/src/views/SettingsView.vue index fd3641a..634a628 100644 --- a/packages/frontend/src/views/SettingsView.vue +++ b/packages/frontend/src/views/SettingsView.vue @@ -146,44 +146,44 @@
-

IP 黑名单管理

+

{{ $t('settings.ipBlacklist.title') }}

-

配置登录失败次数限制和自动封禁时长。本地地址 (127.0.0.1, ::1) 不会被封禁。

+

{{ $t('settings.ipBlacklist.description') }}

- +
- +

{{ blacklistSettingsMessage }}


-

当前已封禁的 IP 地址

-
正在加载黑名单...
+

{{ $t('settings.ipBlacklist.currentBannedTitle') }}

+
{{ $t('settings.ipBlacklist.loadingList') }}
{{ ipBlacklist.error }}
- - - - - + + + + + @@ -191,21 +191,21 @@ - +
IP 地址失败次数最后尝试时间封禁截止时间操作{{ $t('settings.ipBlacklist.table.ipAddress') }}{{ $t('settings.ipBlacklist.table.attempts') }}{{ $t('settings.ipBlacklist.table.lastAttempt') }}{{ $t('settings.ipBlacklist.table.bannedUntil') }}{{ $t('settings.ipBlacklist.table.actions') }}
{{ entry.ip }} {{ entry.attempts }} {{ new Date(entry.last_attempt_at * 1000).toLocaleString() }}{{ entry.blocked_until ? new Date(entry.blocked_until * 1000).toLocaleString() : 'N/A' }}{{ entry.blocked_until ? new Date(entry.blocked_until * 1000).toLocaleString() : $t('statusMonitor.notAvailable') }}
-

当前没有 IP 地址在黑名单中。

+

{{ $t('settings.ipBlacklist.noBannedIps') }}

{{ blacklistDeleteError }}

@@ -794,7 +794,7 @@ const fetchIpBlacklist = async (page = 1) => { ipBlacklist.total = data.total; ipBlacklist.currentPage = page; } catch (error: any) { - ipBlacklist.error = error.message || '获取黑名单失败'; + ipBlacklist.error = error.message || t('settings.ipBlacklist.error.fetchFailed'); } finally { ipBlacklist.loading = false; } @@ -802,7 +802,7 @@ const fetchIpBlacklist = async (page = 1) => { const handleDeleteIp = async (ip: string) => { blacklistToDeleteIp.value = ip; - if (confirm(`确定要从黑名单中移除 IP 地址 "${ip}" 吗?`)) { + if (confirm(t('settings.ipBlacklist.confirmRemoveIp', { ip }))) { blacklistDeleteLoading.value = true; blacklistDeleteError.value = null; try { @@ -810,7 +810,7 @@ const handleDeleteIp = async (ip: string) => { await authStore.deleteIpFromBlacklist(ip); await fetchIpBlacklist(ipBlacklist.currentPage); } catch (error: any) { - blacklistDeleteError.value = error.message || '删除失败'; + blacklistDeleteError.value = error.message || t('settings.ipBlacklist.error.deleteFailed'); } finally { blacklistDeleteLoading.value = false; blacklistToDeleteIp.value = null; @@ -829,20 +829,20 @@ const handleUpdateBlacklistSettings = async () => { const maxAttempts = parseInt(blacklistSettingsForm.maxLoginAttempts, 10); const banDuration = parseInt(blacklistSettingsForm.loginBanDuration, 10); if (isNaN(maxAttempts) || maxAttempts <= 0) { - throw new Error('最大失败次数必须是正整数。'); + throw new Error(t('settings.ipBlacklist.error.invalidMaxAttempts')); } if (isNaN(banDuration) || banDuration <= 0) { - throw new Error('封禁时长必须是正整数(秒)。'); + throw new Error(t('settings.ipBlacklist.error.invalidBanDuration')); } await settingsStore.updateMultipleSettings({ maxLoginAttempts: blacklistSettingsForm.maxLoginAttempts, loginBanDuration: blacklistSettingsForm.loginBanDuration, }); - blacklistSettingsMessage.value = '黑名单配置已成功更新。'; + blacklistSettingsMessage.value = t('settings.ipBlacklist.success.configUpdated'); blacklistSettingsSuccess.value = true; } catch (error: any) { console.error('更新黑名单配置失败:', error); - blacklistSettingsMessage.value = error.message || '更新黑名单配置失败'; + blacklistSettingsMessage.value = error.message || t('settings.ipBlacklist.error.updateConfigFailed'); blacklistSettingsSuccess.value = false; } finally { blacklistSettingsLoading.value = false;