From 7e72a64cd09f7d00f7367a0f72eed5e78f5dffed Mon Sep 17 00:00:00 2001 From: xudaotutou <13435638964@163.com> Date: Thu, 27 Feb 2025 18:40:23 +0800 Subject: [PATCH] feat:update email for english --- frontend/desktop/src/services/backend/sms.ts | 128 +++++++++++-------- frontend/desktop/src/types/system.ts | 1 + 2 files changed, 74 insertions(+), 55 deletions(-) diff --git a/frontend/desktop/src/services/backend/sms.ts b/frontend/desktop/src/services/backend/sms.ts index ea5f9aa97fc..7cd5945889b 100644 --- a/frontend/desktop/src/services/backend/sms.ts +++ b/frontend/desktop/src/services/backend/sms.ts @@ -123,67 +123,85 @@ export const emailSmsReq = async (email: string) => { const code = Math.floor(Math.random() * 900000 + 100000).toString(); const transporter = getTransporter(); + const language = emailConfig.language === 'zh' ? 'zh' : 'en'; + + const getLocalizedContent = (content: string, subject: string, language: 'zh' | 'en') => { + return ` + + + + + + ${subject} + + + +
+ ${content} +
+ + + `; + }; + const subjectMap = { + zh: '【sealos】验证码', + en: '【sealos】Verification Code' + } as const; + const htmlMap = { + zh: getLocalizedContent( + ` +

尊敬的用户,您正在进行邮箱绑定操作。请输入以下验证码完成验证。

+

您的验证码是:

+

${code}

+ `, + subjectMap['zh'], + 'zh' + ), + en: getLocalizedContent( + ` +

Dear user, you are currently performing an email binding operation. Please enter the following verification code to complete the verification.

+

Your verification code is:

+

${code}

+ `, + subjectMap['en'], + 'en' + ) + } as const; await retrySerially( () => transporter.sendMail({ from: emailConfig.user, to: email, - subject: '【sealos】验证码', - html: ` - - - - - 【sealos】验证码 - - - -
-

尊敬的用户,您正在进行邮箱绑定操作。请输入以下验证码完成验证。

-

您的验证码是:

-

${code}

-
- - ` + subject: subjectMap[language], + html: htmlMap[language] }), 3 ); diff --git a/frontend/desktop/src/types/system.ts b/frontend/desktop/src/types/system.ts index 61b419dec5f..0e9a407adba 100644 --- a/frontend/desktop/src/types/system.ts +++ b/frontend/desktop/src/types/system.ts @@ -139,6 +139,7 @@ export type AuthConfigType = { port: number; user: string; password: string; + language?: string; }; }; captcha?: {