feat: Enhance email expiration options and update README

This commit is contained in:
beilunyang
2024-12-21 01:36:35 +08:00
parent 3566a33c3b
commit 929f310202
4 changed files with 12 additions and 5 deletions

View File

@@ -33,7 +33,7 @@
- 🔒 **隐私保护**:保护您的真实邮箱地址,远离垃圾邮件和不必要的订阅
-**实时收件**:自动轮询,即时接收邮件通知
- ⏱️ **灵活**:支持 1 小时、24 小时3 天的过期时间选择
- ⏱️ **灵活有效**:支持 1 小时、24 小时3 天或永久有效
- 🎨 **主题切换**:支持亮色和暗色模式
- 📱 **响应式设计**:完美适配桌面和移动设备
- 🔄 **自动清理**:自动清理过期的邮箱和邮件

View File

@@ -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,

View File

@@ -140,7 +140,11 @@ export function EmailList({ onEmailSelect, selectedEmailId }: EmailListProps) {
<div className="truncate flex-1">
<div className="font-medium truncate">{email.address}</div>
<div className="text-xs text-gray-500">
: {new Date(email.expiresAt).toLocaleString()}
{new Date(email.expiresAt).getFullYear() === 9999 ? (
"永久有效"
) : (
`过期时间: ${new Date(email.expiresAt).toLocaleString()}`
)}
</div>
</div>
</div>

View File

@@ -1,10 +1,11 @@
export interface ExpiryOption {
label: string
value: number // 过期时间(毫秒)
value: number
}
export const EXPIRY_OPTIONS: ExpiryOption[] = [
{ label: '1小时', value: 1000 * 60 * 60 },
{ label: '24小时', value: 1000 * 60 * 60 * 24 },
{ label: '3天', value: 1000 * 60 * 60 * 24 * 3 }
{ label: '3天', value: 1000 * 60 * 60 * 24 * 3 },
{ label: '永久', value: 0 }
]