4 Commits

Author SHA1 Message Date
beilunyang
0f5aaab26b Revert "chore: Update wrangler-cli"
This reverts commit 166d28405b.
2025-06-22 22:29:14 +08:00
beilunyang
70c1f2e902 fix: ts type error 2025-06-22 21:54:35 +08:00
beilunyang
166d28405b chore: Update wrangler-cli 2025-06-22 21:05:19 +08:00
beilunyang
408f97f98d docs: Update readme 2025-06-22 20:57:06 +08:00
2 changed files with 71 additions and 2 deletions

View File

@@ -16,6 +16,7 @@
<a href="#邮箱域名配置">邮箱域名配置</a>
<a href="#权限系统">权限系统</a>
<a href="#系统设置">系统设置</a>
<a href="#发件功能">发件功能</a>
<a href="#Webhook 集成">Webhook 集成</a>
<a href="#OpenAPI">OpenAPI</a>
<a href="#环境变量">环境变量</a>
@@ -47,6 +48,7 @@
- 📱 **PWA 支持**:支持 PWA 安装
- 💸 **免费自部署**:基于 Cloudflare 构建, 可实现免费自部署,无需任何费用
- 🎉 **可爱的 UI**:简洁可爱萌萌哒 UI 界面
- 📤 **发件功能**:支持使用临时邮箱发送邮件,基于 Resend 服务
- 🔔 **Webhook 通知**:支持通过 webhook 接收新邮件通知
- 🛡️ **权限系统**:支持基于角色的权限控制系统
- 🔑 **OpenAPI**:支持通过 API Key 访问 OpenAPI
@@ -284,6 +286,73 @@ pnpm dlx tsx ./scripts/deploy/index.ts
**皇帝**角色可以在个人中心页面设置
## 发件功能
MoeMail 支持使用临时邮箱发送邮件,基于 [Resend](https://resend.com/) 服务。
### 功能特性
- 📨 **临时邮箱发件**:可以使用创建的临时邮箱作为发件人发送邮件
- 🎯 **角色权限控制**:不同角色有不同的每日发件限制
- 💌 **支持 HTML**:支持发送富文本格式邮件
### 角色发件权限
| 角色 | 每日发件限制 | 说明 |
|------|-------------|------|
| 皇帝 (Emperor) | 无限制 | 网站管理员,无发件限制 |
| 公爵 (Duke) | 5封/天 | 默认每日可发送5封邮件 |
| 骑士 (Knight) | 2封/天 | 默认每日可发送2封邮件 |
| 平民 (Civilian) | 禁止发件 | 无发件权限 |
> 💡 **提示**:皇帝可以在个人中心的邮件服务配置中自定义公爵和骑士的每日发件限制。
### 配置发件服务
1. **获取 Resend API Key**
- 访问 [Resend 官网](https://resend.com/) 注册账号
- 在控制台中创建 API Key
- 复制 API Key 供后续配置使用
2. **配置发件服务**
- 皇帝角色登录 MoeMail
- 进入个人中心页面
- 在"Resend 发件服务配置"部分:
- 启用发件服务开关
- 填入 Resend API Key
- 设置公爵和骑士的每日发件限制(可选)
- 点击保存配置
3. **验证配置**
- 配置保存后,有权限的用户在邮箱列表页面会看到"发送邮件"按钮
- 点击按钮可以打开发件对话框进行测试
### 使用发件功能
1. **创建临时邮箱**
- 在邮箱页面创建一个新的临时邮箱
2. **发送邮件**
- 在邮箱列表中找到要使用的邮箱
- 点击邮箱旁边的"发送邮件"按钮
- 在弹出的对话框中填写:
- 收件人邮箱地址
- 邮件主题
- 邮件内容(支持 HTML 格式)
- 点击"发送"按钮
3. **查看发送记录**
- 发送的邮件会自动保存到对应邮箱的消息列表中
- 可以在邮箱详情页面查看所有发送和接收的邮件
### 注意事项
- 📋 **Resend 限制**:请注意 Resend 服务的发送限制和定价政策
- 🔐 **域名验证**:使用自定义域名发件需要在 Resend 中验证域名
- 🚫 **反垃圾邮件**:请遵守邮件发送规范,避免发送垃圾邮件
- 📊 **配额监控**:系统会自动统计每日发件数量,达到限额后将无法继续发送
- 🔄 **配额重置**:每日发件配额在每天 00:00 自动重置
## Webhook 集成
当收到新邮件时,系统会向用户配置并且已启用的 Webhook URL 发送 POST 请求。

View File

@@ -52,7 +52,7 @@ export function MessageList({ email, messageType, onMessageSelect, selectedMessa
const [refreshing, setRefreshing] = useState(false)
const [nextCursor, setNextCursor] = useState<string | null>(null)
const [loadingMore, setLoadingMore] = useState(false)
const pollTimeoutRef = useRef<Timer>()
const pollTimeoutRef = useRef<Timer>(null)
const messagesRef = useRef<Message[]>([]) // 添加 ref 来追踪最新的消息列表
const [total, setTotal] = useState(0)
const [messageToDelete, setMessageToDelete] = useState<Message | null>(null)
@@ -118,7 +118,7 @@ export function MessageList({ email, messageType, onMessageSelect, selectedMessa
const stopPolling = () => {
if (pollTimeoutRef.current) {
clearInterval(pollTimeoutRef.current)
pollTimeoutRef.current = undefined
pollTimeoutRef.current = null
}
}