refactor(email): 优化邮件模板的数据处理和展示逻辑

- 在 EmailTemplateUtil 中增加了对 email 和 newPassword 的非空校验
- 更新了 notification.html、password-reset.html 和 register-success.html 模板中的条件判断逻辑
- 优化了模板的 HTML 结构和样式,提高了邮件的可读性和美观性
This commit is contained in:
2025-08-28 21:11:33 +08:00
parent 22079719f0
commit c23302d9d3
4 changed files with 145 additions and 142 deletions

View File

@@ -37,7 +37,9 @@ public class EmailTemplateUtil {
data.put("username", username); data.put("username", username);
data.put("phone", phone); data.put("phone", phone);
data.put("password", password); data.put("password", password);
data.put("email", email); if (email != null && !email.trim().isEmpty()) {
data.put("email", email);
}
emailRecordService.sendHtmlEmail(title, "register-success.html", data, new String[]{email}); emailRecordService.sendHtmlEmail(title, "register-success.html", data, new String[]{email});
} catch (Exception e) { } catch (Exception e) {
@@ -62,8 +64,10 @@ public class EmailTemplateUtil {
Map<String, Object> data = new HashMap<>(); Map<String, Object> data = new HashMap<>();
data.put("username", username); data.put("username", username);
data.put("phone", phone); data.put("phone", phone);
data.put("newPassword", newPassword);
data.put("resetTime", DateUtil.now()); data.put("resetTime", DateUtil.now());
if (newPassword != null && !newPassword.trim().isEmpty()) {
data.put("newPassword", newPassword);
}
emailRecordService.sendHtmlEmail(title, "password-reset.html", data, new String[]{email}); emailRecordService.sendHtmlEmail(title, "password-reset.html", data, new String[]{email});
} catch (Exception e) { } catch (Exception e) {
@@ -93,16 +97,16 @@ public class EmailTemplateUtil {
data.put("content", content); data.put("content", content);
data.put("sendTime", DateUtil.now()); data.put("sendTime", DateUtil.now());
if (greeting != null) { if (greeting != null && !greeting.trim().isEmpty()) {
data.put("greeting", greeting); data.put("greeting", greeting);
} }
if (infoMessage != null) { if (infoMessage != null && !infoMessage.trim().isEmpty()) {
data.put("infoMessage", infoMessage); data.put("infoMessage", infoMessage);
} }
if (actionUrl != null) { if (actionUrl != null && !actionUrl.trim().isEmpty()) {
data.put("actionUrl", actionUrl); data.put("actionUrl", actionUrl);
} }
if (actionText != null) { if (actionText != null && !actionText.trim().isEmpty()) {
data.put("actionText", actionText); data.put("actionText", actionText);
} }

View File

@@ -218,14 +218,14 @@
</div> </div>
<!-- Info Box --> <!-- Info Box -->
<% if(infoMessage!) { %> <% if(has(infoMessage)) { %>
<div class="info-box"> <div class="info-box">
<strong> 温馨提示:</strong> ${infoMessage!} <strong> 温馨提示:</strong> ${infoMessage!}
</div> </div>
<% } %> <% } %>
<!-- CTA Button --> <!-- CTA Button -->
<% if(actionUrl!) { %> <% if(has(actionUrl)) { %>
<div class="cta-section"> <div class="cta-section">
<a href="${actionUrl!}" class="cta-button">${actionText!'查看详情'}</a> <a href="${actionUrl!}" class="cta-button">${actionText!'查看详情'}</a>
</div> </div>

View File

@@ -269,7 +269,7 @@
<span class="info-label">重置时间:</span> <span class="info-label">重置时间:</span>
<span class="info-value">${resetTime!}</span> <span class="info-value">${resetTime!}</span>
</div> </div>
<% if(newPassword!) { %> <% if(has(newPassword)) { %>
<div class="info-item"> <div class="info-item">
<span class="info-label">新密码:</span> <span class="info-label">新密码:</span>
<span class="info-value">${newPassword!}</span> <span class="info-value">${newPassword!}</span>
@@ -284,7 +284,7 @@
<!-- CTA Button --> <!-- CTA Button -->
<div class="cta-section"> <div class="cta-section">
<a href="https://www.gxwebsoft.com/login" class="cta-button">立即登录</a> <a href="https://websoft.top/login" class="cta-button">立即登录</a>
</div> </div>
<!-- Security Tips --> <!-- Security Tips -->
@@ -303,19 +303,18 @@
<!-- Footer --> <!-- Footer -->
<div class="footer"> <div class="footer">
<div class="footer-content"> <div class="footer-content">
<strong>南宁网宿信息科技有限公司</strong><br> <strong>网宿软件</strong><br>
专业的企业数字化转型服务商 专业的企业数字化转型服务商
</div> </div>
<div class="footer-links"> <div class="footer-links">
<a href="https://www.gxwebsoft.com">官方网站</a> <a href="https://websoft.top">官方网站</a>
<a href="https://www.gxwebsoft.com/help">帮助中心</a> <a href="https://websoft.top/help">帮助中心</a>
<a href="https://www.gxwebsoft.com/contact">联系我们</a> <a href="https://websoft.top/contact">联系我们</a>
</div> </div>
<div class="copyright"> <div class="copyright">
© 2024 南宁网宿信息科技有限公司 版权所有<br> © 2025 WebSoft Inc.
如有疑问请联系客服170083662@qq.com
</div> </div>
</div> </div>
</div> </div>

View File

@@ -282,7 +282,7 @@
<span class="info-label">登录密码:</span> <span class="info-label">登录密码:</span>
<span class="info-value">${password!}</span> <span class="info-value">${password!}</span>
</div> </div>
<% if(email!) { %> <% if(has(email)) { %>
<div class="info-item"> <div class="info-item">
<span class="info-label">邮箱:</span> <span class="info-label">邮箱:</span>
<span class="info-value">${email!}</span> <span class="info-value">${email!}</span>