From 0fd8c060dfe3d6f8ee8b1d16a29babad967d6d19 Mon Sep 17 00:00:00 2001 From: benjamin Date: Wed, 20 May 2026 13:26:19 +0800 Subject: [PATCH] =?UTF-8?q?fix(frontend):=20=E6=8C=89=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E8=AF=AD=E8=A8=80=E5=88=9D=E5=A7=8B=E5=8C=96=E9=82=AE=E4=BB=B6?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- .../admin/settings/EmailTemplateEditor.vue | 55 +++++++++++++++++-- 1 file changed, 50 insertions(+), 5 deletions(-) diff --git a/frontend/src/views/admin/settings/EmailTemplateEditor.vue b/frontend/src/views/admin/settings/EmailTemplateEditor.vue index 30a5e4f6..6643f799 100644 --- a/frontend/src/views/admin/settings/EmailTemplateEditor.vue +++ b/frontend/src/views/admin/settings/EmailTemplateEditor.vue @@ -208,14 +208,18 @@ import type { import { useAppStore } from "@/stores"; import { extractApiErrorMessage } from "@/utils/apiError"; -const { t } = useI18n(); +const { t, locale } = useI18n(); const appStore = useAppStore(); const fallbackPlaceholders = [ "{{site_name}}", "{{recipient_name}}", "{{recipient_email}}", + "{{verification_code}}", + "{{expires_in_minutes}}", + "{{reset_url}}", "{{subscription_group}}", + "{{subscription_days}}", "{{expiry_time}}", "{{days_remaining}}", "{{current_balance}}", @@ -224,6 +228,33 @@ const fallbackPlaceholders = [ "{{recharge_amount}}", "{{order_id}}", "{{unsubscribe_url}}", + "{{account_id}}", + "{{account_name}}", + "{{platform}}", + "{{quota_dimension}}", + "{{quota_used}}", + "{{quota_limit}}", + "{{quota_remaining}}", + "{{quota_threshold}}", + "{{triggered_at}}", + "{{group_name}}", + "{{moderation_category}}", + "{{moderation_score}}", + "{{violation_count}}", + "{{ban_threshold}}", + "{{rule_name}}", + "{{severity}}", + "{{alert_status}}", + "{{metric_type}}", + "{{operator}}", + "{{metric_value}}", + "{{threshold_value}}", + "{{alert_description}}", + "{{report_name}}", + "{{report_type}}", + "{{report_start_time}}", + "{{report_end_time}}", + "{{report_html}}", ]; const loadingList = ref(true); @@ -297,6 +328,22 @@ function formatLocale(locale: string): string { return locale; } +function selectInitialLocale(locales: string[]): string { + const currentLocale = locale.value.toLowerCase(); + const exactMatch = locales.find( + (availableLocale) => availableLocale.toLowerCase() === currentLocale, + ); + if (exactMatch) return exactMatch; + + const currentLanguage = currentLocale.split("-")[0]; + const languageMatch = locales.find( + (availableLocale) => availableLocale.toLowerCase().split("-")[0] === currentLanguage, + ); + if (languageMatch) return languageMatch; + + return locales[0] || ""; +} + function applyTemplate(template: { subject: string; html: string; @@ -306,9 +353,7 @@ function applyTemplate(template: { subject.value = template.subject; html.value = template.html; isCustomTemplate.value = template.is_custom === true; - if (template.placeholders?.length) { - placeholders.value = template.placeholders; - } + placeholders.value = template.placeholders || []; } async function loadTemplate() { @@ -337,7 +382,7 @@ async function loadTemplateList() { placeholders.value = response.placeholders || []; initializingSelection.value = true; selectedEvent.value = eventOptions.value[0]?.value || ""; - selectedLocale.value = response.locales[0] || ""; + selectedLocale.value = selectInitialLocale(response.locales); await loadTemplate(); initializingSelection.value = false; } catch (err: unknown) {