界面优化

This commit is contained in:
stardrophere
2026-03-12 19:38:14 +08:00
parent 19a61e6567
commit 6fbcf2c81b
5 changed files with 244 additions and 22 deletions
+8 -8
View File
@@ -5,7 +5,7 @@ from typing import Tuple
from fastapi import APIRouter, Depends, HTTPException, status
from sqlalchemy.orm import Session
import random
from app.api.dependencies import get_db
from app.core.security import (
create_access_token,
@@ -52,10 +52,10 @@ def _normalize_email(email: str) -> str:
def _build_verification_email(code: str, purpose_text: str, expire_minutes: int) -> str:
return f"""
<div style="font-family: Arial, sans-serif; line-height: 1.6; color: #222;">
<h2 style="margin-bottom: 12px;">InsightRadar Email Verification</h2>
<p>Your {purpose_text} verification code is:</p>
<h2 style="margin-bottom: 12px;">InsightRadar 邮箱验证</h2>
<p>您的{purpose_text}验证码是:</p>
<p style="font-size: 28px; font-weight: bold; letter-spacing: 4px; color: #0b57d0;">{code}</p>
<p>The code is valid for {expire_minutes} minutes. Do not share it with others.</p>
<p>该验证码在 {expire_minutes} 分钟内有效。请勿泄露给他人。</p>
</div>
"""
@@ -152,8 +152,8 @@ async def send_register_code(payload: RegisterCodeSendRequest, db: Session = Dep
email_sent = await send_html_email(
to_email=email,
subject="InsightRadar Registration Code",
html_content=_build_verification_email(code, "registration", REGISTER_CODE_EXPIRE_MINUTES),
subject=f"{code}InsightRadar 注册验证码",
html_content=_build_verification_email(code, "注册", REGISTER_CODE_EXPIRE_MINUTES),
)
if not email_sent:
code_record.is_used = True
@@ -186,8 +186,8 @@ async def send_login_code(payload: LoginCodeSendRequest, db: Session = Depends(g
email_sent = await send_html_email(
to_email=email,
subject="InsightRadar Login Code",
html_content=_build_verification_email(code, "login", LOGIN_CODE_EXPIRE_MINUTES),
subject=f"{code}InsightRadar 登录验证码",
html_content=_build_verification_email(code, "登录", LOGIN_CODE_EXPIRE_MINUTES),
)
if not email_sent:
code_record.is_used = True