diff --git a/frontend/src/components/MailBox.vue b/frontend/src/components/MailBox.vue index dcb2fe7..97c9e7e 100644 --- a/frontend/src/components/MailBox.vue +++ b/frontend/src/components/MailBox.vue @@ -399,9 +399,14 @@ const multiActionDownload = async () => { onMounted(async () => { if (props.enableMailStates) { - const { results = [] } = await props.fetchMailStates() - mailStates.value = results - mailStateFilter.value = results.find(state => state.default)?.value ?? results[0]?.value ?? null + try { + const { results = [] } = await props.fetchMailStates() + mailStates.value = results + mailStateFilter.value = results.find(state => state.default)?.value ?? results[0]?.value ?? null + } catch (error) { + mailStates.value = [] + message.error(error.message || "error") + } } await refresh(); }); diff --git a/frontend/src/views/index/SimpleIndex.vue b/frontend/src/views/index/SimpleIndex.vue index 882335e..69efc67 100644 --- a/frontend/src/views/index/SimpleIndex.vue +++ b/frontend/src/views/index/SimpleIndex.vue @@ -141,8 +141,13 @@ watch(currentPage, () => { onMounted(async () => { await api.getSettings() if (openSettings.value.enableMailStates) { - const { results = [] } = await api.fetch(`/api/mail-states`) - mailStates.value = results + try { + const { results = [] } = await api.fetch(`/api/mail-states`) + mailStates.value = results + } catch (error) { + mailStates.value = [] + message.error(error.message || "error") + } } await fetchMails() diff --git a/vitepress-docs/docs/en/guide/feature/mail-api.md b/vitepress-docs/docs/en/guide/feature/mail-api.md index 94fd9c7..6a0bfb4 100644 --- a/vitepress-docs/docs/en/guide/feature/mail-api.md +++ b/vitepress-docs/docs/en/guide/feature/mail-api.md @@ -23,7 +23,7 @@ res = requests.get( After enabling `ENABLE_MAIL_FLAGS` and running the database migration, each mail response includes the boolean field `unread`. The backend owns storage, historical `NULL` compatibility, and state calculation. -With an Address JWT, use `GET /api/mail-states` to retrieve available states. The backend combines its system-state enum with address-specific custom states. The frontend uses each returned `value` directly for filtering and moving, and displays its `label_key` or `label`. +With an Address JWT, use `GET /api/mail-states` to retrieve the currently available system states. This endpoint is the extension point for future address-specific custom states. The frontend uses each returned `value` directly for filtering and moving, and displays its `label_key` or `label`. Use `PATCH /api/mails/state` to move the state of up to 100 mail IDs: diff --git a/vitepress-docs/docs/zh/guide/feature/mail-api.md b/vitepress-docs/docs/zh/guide/feature/mail-api.md index 3794aca..28aebb7 100644 --- a/vitepress-docs/docs/zh/guide/feature/mail-api.md +++ b/vitepress-docs/docs/zh/guide/feature/mail-api.md @@ -23,7 +23,7 @@ res = requests.get( 启用 `ENABLE_MAIL_FLAGS` 并完成数据库迁移后,邮件响应会包含布尔字段 `unread`。数据库存储、历史 `NULL` 兼容和状态计算全部由后端处理。 -地址 JWT 使用 `GET /api/mail-states` 获取状态列表。后端将系统状态枚举与地址自定义状态合并后返回;前端直接使用其中的 `value` 作为筛选和移动参数,并使用 `label_key` 或 `label` 显示名称。 +地址 JWT 使用 `GET /api/mail-states` 获取当前可用的系统状态;该接口也是未来扩展地址自定义状态的入口。前端直接使用其中的 `value` 作为筛选和移动参数,并使用 `label_key` 或 `label` 显示名称。 使用 `PATCH /api/mails/state` 批量移动邮件状态,每次最多传入 100 个邮件 ID: