From 929f31020213157532ae0c40cfe1dad876277723 Mon Sep 17 00:00:00 2001 From: beilunyang <786220806@qq.com> Date: Sat, 21 Dec 2024 01:36:35 +0800 Subject: [PATCH] feat: Enhance email expiration options and update README --- README.md | 2 +- app/api/emails/generate/route.ts | 4 +++- app/components/emails/email-list.tsx | 6 +++++- app/types/email.ts | 5 +++-- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b99366e..a1ae7d0 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ - 🔒 **隐私保护**:保护您的真实邮箱地址,远离垃圾邮件和不必要的订阅 - ⚡ **实时收件**:自动轮询,即时接收邮件通知 -- ⏱️ **灵活过期**:支持 1 小时、24 小时或 3 天的过期时间选择 +- ⏱️ **灵活有效期**:支持 1 小时、24 小时、3 天或永久有效 - 🎨 **主题切换**:支持亮色和暗色模式 - 📱 **响应式设计**:完美适配桌面和移动设备 - 🔄 **自动清理**:自动清理过期的邮箱和邮件 diff --git a/app/api/emails/generate/route.ts b/app/api/emails/generate/route.ts index 2d91531..036696f 100644 --- a/app/api/emails/generate/route.ts +++ b/app/api/emails/generate/route.ts @@ -58,7 +58,9 @@ export async function POST(request: Request) { } const now = new Date() - const expires = new Date(now.getTime() + expiryTime) + const expires = expiryTime === 0 + ? new Date('9999-01-01T00:00:00.000Z') + : new Date(now.getTime() + expiryTime) const emailData: typeof emails.$inferInsert = { address, diff --git a/app/components/emails/email-list.tsx b/app/components/emails/email-list.tsx index 5126b12..a384980 100644 --- a/app/components/emails/email-list.tsx +++ b/app/components/emails/email-list.tsx @@ -140,7 +140,11 @@ export function EmailList({ onEmailSelect, selectedEmailId }: EmailListProps) {