feat: 邮件页面增加 上一封/下一封 按钮 (#712)

This commit is contained in:
Dream Hunter
2025-08-24 19:14:50 +08:00
committed by GitHub
parent 0565978930
commit ab2bfdd00f
2 changed files with 72 additions and 6 deletions
+1
View File
@@ -6,6 +6,7 @@
- feat: |UI| 优化极简模式主页, 增加全部邮件页面功能(删除/下载/附件/...), 可在 `外观` 中切换 - feat: |UI| 优化极简模式主页, 增加全部邮件页面功能(删除/下载/附件/...), 可在 `外观` 中切换
- feat: admin 账号设置页面增加 `邮件转发规则` 配置 - feat: admin 账号设置页面增加 `邮件转发规则` 配置
- feat: admin 账号设置页面增加 `禁止接收未知地址邮件` 配置 - feat: admin 账号设置页面增加 `禁止接收未知地址邮件` 配置
- feat: 邮件页面增加 上一封/下一封 按钮
## v1.0.3 ## v1.0.3
+71 -6
View File
@@ -1,9 +1,9 @@
<script setup> <script setup>
import { watch, onMounted, ref, onBeforeUnmount } from "vue"; import { watch, onMounted, ref, onBeforeUnmount, computed } from "vue";
import { useMessage } from 'naive-ui' import { useMessage } from 'naive-ui'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { useGlobalState } from '../store' import { useGlobalState } from '../store'
import { CloudDownloadRound } from '@vicons/material' import { CloudDownloadRound, ArrowBackIosNewFilled, ArrowForwardIosFilled } from '@vicons/material'
import { useIsMobile } from '../utils/composables' import { useIsMobile } from '../utils/composables'
import { processItem } from '../utils/email-parser' import { processItem } from '../utils/email-parser'
import { utcToLocalDate } from '../utils'; import { utcToLocalDate } from '../utils';
@@ -62,6 +62,48 @@ const count = ref(0)
const page = ref(1) const page = ref(1)
const pageSize = ref(20) const pageSize = ref(20)
const canGoPrevMail = computed(() => {
if (!curMail.value) return false
const currentIndex = data.value.findIndex(mail => mail.id === curMail.value.id)
return currentIndex > 0 || page.value > 1
})
const canGoNextMail = computed(() => {
if (!curMail.value) return false
const currentIndex = data.value.findIndex(mail => mail.id === curMail.value.id)
return currentIndex < data.value.length - 1 || count.value > page.value * pageSize.value
})
const prevMail = async () => {
if (!canGoPrevMail.value) return
const currentIndex = data.value.findIndex(mail => mail.id === curMail.value.id)
if (currentIndex > 0) {
curMail.value = data.value[currentIndex - 1]
} else if (page.value > 1) {
page.value--
await refresh()
if (data.value.length > 0) {
curMail.value = data.value[data.value.length - 1]
}
}
}
const nextMail = async () => {
if (!canGoNextMail.value) return
const currentIndex = data.value.findIndex(mail => mail.id === curMail.value.id)
if (currentIndex < data.value.length - 1) {
curMail.value = data.value[currentIndex + 1]
} else if (count.value > page.value * pageSize.value) {
page.value++
await refresh()
if (data.value.length > 0) {
curMail.value = data.value[0]
}
}
}
const curMail = ref(null); const curMail = ref(null);
const multiActionMode = ref(false) const multiActionMode = ref(false)
@@ -91,6 +133,8 @@ const { t } = useI18n({
cancelMultiAction: 'Cancel Multi Action', cancelMultiAction: 'Cancel Multi Action',
selectAll: 'Select All of This Page', selectAll: 'Select All of This Page',
unselectAll: 'Unselect All', unselectAll: 'Unselect All',
prevMail: 'Previous',
nextMail: 'Next',
}, },
zh: { zh: {
success: '成功', success: '成功',
@@ -111,6 +155,8 @@ const { t } = useI18n({
cancelMultiAction: '取消多选', cancelMultiAction: '取消多选',
selectAll: '全选本页', selectAll: '全选本页',
unselectAll: '取消全选', unselectAll: '取消全选',
prevMail: '上一封',
nextMail: '下一封',
} }
} }
}); });
@@ -400,12 +446,31 @@ onBeforeUnmount(() => {
</div> </div>
</template> </template>
<template #2> <template #2>
<div v-if="curMail" style="margin: 8px;">
<n-flex justify="space-between">
<n-button @click="prevMail" :disabled="!canGoPrevMail" text size="small">
<template #icon>
<n-icon>
<ArrowBackIosNewFilled />
</n-icon>
</template>
{{ t('prevMail') }}
</n-button>
<n-button @click="nextMail" :disabled="!canGoNextMail" text size="small" icon-placement="right">
<template #icon>
<n-icon>
<ArrowForwardIosFilled />
</n-icon>
</template>
{{ t('nextMail') }}
</n-button>
</n-flex>
</div>
<n-card :bordered="false" embedded v-if="curMail" class="mail-item" :title="curMail.subject" <n-card :bordered="false" embedded v-if="curMail" class="mail-item" :title="curMail.subject"
style="overflow: auto; max-height: 100vh;"> style="overflow: auto; max-height: 100vh;">
<MailContentRenderer :mail="curMail" :showEMailTo="showEMailTo" <MailContentRenderer :mail="curMail" :showEMailTo="showEMailTo"
:enableUserDeleteEmail="enableUserDeleteEmail" :showReply="showReply" :showSaveS3="showSaveS3" :enableUserDeleteEmail="enableUserDeleteEmail" :showReply="showReply" :showSaveS3="showSaveS3"
:onDelete="deleteMail" :onReply="replyMail" :onForward="forwardMail" :onDelete="deleteMail" :onReply="replyMail" :onForward="forwardMail" :onSaveToS3="saveToS3Proxy" />
:onSaveToS3="saveToS3Proxy" />
</n-card> </n-card>
<n-card :bordered="false" embedded class="mail-item" v-else> <n-card :bordered="false" embedded class="mail-item" v-else>
<n-result status="info" :title="t('pleaseSelectMail')"> <n-result status="info" :title="t('pleaseSelectMail')">
@@ -459,8 +524,8 @@ onBeforeUnmount(() => {
<n-card :bordered="false" embedded style="overflow: auto;"> <n-card :bordered="false" embedded style="overflow: auto;">
<MailContentRenderer :mail="curMail" :showEMailTo="showEMailTo" <MailContentRenderer :mail="curMail" :showEMailTo="showEMailTo"
:enableUserDeleteEmail="enableUserDeleteEmail" :showReply="showReply" :showSaveS3="showSaveS3" :enableUserDeleteEmail="enableUserDeleteEmail" :showReply="showReply" :showSaveS3="showSaveS3"
:useUTCDate="useUTCDate" :onDelete="deleteMail" :onReply="replyMail" :useUTCDate="useUTCDate" :onDelete="deleteMail" :onReply="replyMail" :onForward="forwardMail"
:onForward="forwardMail" :onSaveToS3="saveToS3Proxy" /> :onSaveToS3="saveToS3Proxy" />
</n-card> </n-card>
</n-drawer-content> </n-drawer-content>
</n-drawer> </n-drawer>