@@ -3,11 +3,11 @@ import { watch, onMounted, ref, onBeforeUnmount } from "vue";
33import { useMessage } from ' naive-ui'
44import { useI18n } from ' vue-i18n'
55import { useGlobalState } from ' ../store'
6- import { CloudDownloadRound , ReplyFilled , ForwardFilled } from ' @vicons/material'
6+ import { CloudDownloadRound } from ' @vicons/material'
77import { useIsMobile } from ' ../utils/composables'
8- import { processItem , getDownloadEmlUrl } from ' ../utils/email-parser'
8+ import { processItem } from ' ../utils/email-parser'
99import { utcToLocalDate } from ' ../utils' ;
10- import ShadowHtmlComponent from " ./ShadowHtmlComponent .vue" ;
10+ import MailContentRenderer from " ./MailContentRenderer .vue" ;
1111
1212const message = useMessage ()
1313const isMobile = useIsMobile ()
@@ -51,8 +51,8 @@ const props = defineProps({
5151})
5252
5353const {
54- isDark , mailboxSplitSize , indexTab , loading , useUTCDate , autoRefresh , configAutoRefreshInterval ,
55- useIframeShowMail , sendMailModel , preferShowTextMail
54+ isDark , mailboxSplitSize , indexTab , loading , useUTCDate ,
55+ autoRefresh , configAutoRefreshInterval , sendMailModel
5656} = useGlobalState ()
5757const autoRefreshInterval = ref (configAutoRefreshInterval .value )
5858const data = ref ([])
@@ -62,10 +62,7 @@ const count = ref(0)
6262const page = ref (1 )
6363const pageSize = ref (20 )
6464
65- const showAttachments = ref (false )
66- const curAttachments = ref ([])
6765const curMail = ref (null );
68- const showTextMail = ref (preferShowTextMail .value )
6966
7067const multiActionMode = ref (false )
7168const showMultiActionDownload = ref (false )
@@ -185,10 +182,6 @@ const clickRow = async (row) => {
185182 curMail .value = row;
186183};
187184
188- const getAttachments = (attachments ) => {
189- curAttachments .value = attachments;
190- showAttachments .value = true ;
191- };
192185
193186const mailItemClass = (row ) => {
194187 return curMail .value && row .id == curMail .value .id ? (isDark .value ? ' overlay overlay-dark-backgroud' : ' overlay overlay-light-backgroud' ) : ' ' ;
@@ -237,14 +230,8 @@ const onSpiltSizeChange = (size) => {
237230 mailboxSplitSize .value = size;
238231}
239232
240- const attachmentLoding = ref (false )
241233const saveToS3Proxy = async (filename , blob ) => {
242- attachmentLoding .value = true
243- try {
244- await props .saveToS3 (curMail .value .id , filename, blob);
245- } finally {
246- attachmentLoding .value = false
247- }
234+ await props .saveToS3 (curMail .value .id , filename, blob);
248235}
249236
250237const multiActionModeClick = (enableMulti ) => {
@@ -415,57 +402,10 @@ onBeforeUnmount(() => {
415402 <template #2 >
416403 <n-card :bordered =" false" embedded v-if =" curMail" class =" mail-item" :title =" curMail.subject"
417404 style =" overflow : auto ; max-height : 100vh ;" >
418- <n-space >
419- <n-tag type =" info" >
420- ID: {{ curMail.id }}
421- </n-tag >
422- <n-tag type =" info" >
423- {{ utcToLocalDate(curMail.created_at, useUTCDate) }}
424- </n-tag >
425- <n-tag type =" info" >
426- FROM: {{ curMail.source }}
427- </n-tag >
428- <n-tag v-if =" showEMailTo" type =" info" >
429- TO: {{ curMail.address }}
430- </n-tag >
431- <n-popconfirm v-if =" enableUserDeleteEmail" @positive-click =" deleteMail" >
432- <template #trigger >
433- <n-button tertiary type =" error" size =" small" >{{ t('delete') }}</n-button >
434- </template >
435- {{ t('deleteMailTip') }}
436- </n-popconfirm >
437- <n-button v-if =" curMail.attachments && curMail.attachments.length > 0" size =" small" tertiary type =" info"
438- @click =" getAttachments(curMail.attachments)" >
439- {{ t('attachments') }}
440- </n-button >
441- <n-button tag =" a" target =" _blank" tertiary type =" info" size =" small" :download =" curMail.id + '.eml'"
442- :href =" getDownloadEmlUrl(curMail.raw)" >
443- <template #icon >
444- <n-icon :component =" CloudDownloadRound" />
445- </template >
446- {{ t('downloadMail') }}
447- </n-button >
448- <n-button v-if =" showReply" size =" small" tertiary type =" info" @click =" replyMail" >
449- <template #icon >
450- <n-icon :component =" ReplyFilled" />
451- </template >
452- {{ t('reply') }}
453- </n-button >
454- <n-button v-if =" showReply" size =" small" tertiary type =" info" @click =" forwardMail" >
455- <template #icon >
456- <n-icon :component =" ForwardFilled" />
457- </template >
458- {{ t('forwardMail') }}
459- </n-button >
460- <n-button size =" small" tertiary type =" info" @click =" showTextMail = !showTextMail" >
461- {{ showTextMail ? t('showHtmlMail') : t('showTextMail') }}
462- </n-button >
463- </n-space >
464- <pre v-if =" showTextMail" style =" margin-top : 10px ;" >{{ curMail.text }}</pre >
465- <iframe v-else-if =" useIframeShowMail" :srcdoc =" curMail.message"
466- style =" margin-top : 10px ;width : 100% ; height : 100% ;" >
467- </iframe >
468- <ShadowHtmlComponent v-else :htmlContent =" curMail.message" style =" margin-top : 10px ;" />
405+ <MailContentRenderer :mail =" curMail" :showEMailTo =" showEMailTo"
406+ :enableUserDeleteEmail =" enableUserDeleteEmail" :showReply =" showReply" :showSaveS3 =" showSaveS3"
407+ :onDelete =" deleteMail" :onReply =" replyMail" :onForward =" forwardMail"
408+ :onSaveToS3 =" saveToS3Proxy" />
469409 </n-card >
470410 <n-card :bordered =" false" embedded class =" mail-item" v-else >
471411 <n-result status =" info" :title =" t('pleaseSelectMail')" >
@@ -517,89 +457,14 @@ onBeforeUnmount(() => {
517457 style =" height : 80vh ;" >
518458 <n-drawer-content :title =" curMail ? curMail.subject : ''" closable >
519459 <n-card :bordered =" false" embedded style =" overflow : auto ;" >
520- <n-space >
521- <n-tag type =" info" >
522- ID: {{ curMail.id }}
523- </n-tag >
524- <n-tag type =" info" >
525- {{ utcToLocalDate(curMail.created_at, useUTCDate) }}
526- </n-tag >
527- <n-tag type =" info" >
528- FROM: {{ curMail.source }}
529- </n-tag >
530- <n-tag v-if =" showEMailTo" type =" info" >
531- TO: {{ curMail.address }}
532- </n-tag >
533- <n-popconfirm v-if =" enableUserDeleteEmail" @positive-click =" deleteMail" >
534- <template #trigger >
535- <n-button tertiary type =" error" size =" small" >{{ t('delete') }}</n-button >
536- </template >
537- {{ t('deleteMailTip') }}
538- </n-popconfirm >
539- <n-button v-if =" curMail.attachments && curMail.attachments.length > 0" size =" small" tertiary type =" info"
540- @click =" getAttachments(curMail.attachments)" >
541- {{ t('attachments') }}
542- </n-button >
543- <n-button tag =" a" target =" _blank" tertiary type =" info" size =" small" :download =" curMail.id + '.eml'"
544- :href =" getDownloadEmlUrl(curMail)" >
545- <n-icon :component =" CloudDownloadRound" />
546- {{ t('downloadMail') }}
547- </n-button >
548- <n-button v-if =" showReply" size =" small" tertiary type =" info" @click =" replyMail" >
549- <template #icon >
550- <n-icon :component =" ReplyFilled" />
551- </template >
552- {{ t('reply') }}
553- </n-button >
554- <n-button v-if =" showReply" size =" small" tertiary type =" info" @click =" forwardMail" >
555- <template #icon >
556- <n-icon :component =" ForwardFilled" />
557- </template >
558- {{ t('forwardMail') }}
559- </n-button >
560- <n-button size =" small" tertiary type =" info" @click =" showTextMail = !showTextMail" >
561- {{ showTextMail ? t('showHtmlMail') : t('showTextMail') }}
562- </n-button >
563- </n-space >
564- <pre v-if =" showTextMail" style =" margin-top : 10px ;" >{{ curMail.text }}</pre >
565- <iframe v-else-if =" useIframeShowMail" :srcdoc =" curMail.message"
566- style =" margin-top : 10px ;width : 100% ; height : 100% ;" >
567- </iframe >
568- <ShadowHtmlComponent :key =" curMail.id" v-else :htmlContent =" curMail.message" style =" margin-top : 10px ;" />
460+ <MailContentRenderer :mail =" curMail" :showEMailTo =" showEMailTo"
461+ :enableUserDeleteEmail =" enableUserDeleteEmail" :showReply =" showReply" :showSaveS3 =" showSaveS3"
462+ :useUTCDate =" useUTCDate" :onDelete =" deleteMail" :onReply =" replyMail"
463+ :onForward =" forwardMail" :onSaveToS3 =" saveToS3Proxy" />
569464 </n-card >
570465 </n-drawer-content >
571466 </n-drawer >
572467 </div >
573- <n-modal v-model:show =" showAttachments" preset =" dialog" title =" Dialog" >
574- <template #header >
575- <div >{{ t("attachments") }}</div >
576- </template >
577- <n-spin v-model:show =" attachmentLoding" >
578- <n-list hoverable clickable >
579- <n-list-item v-for =" row in curAttachments" v-bind:key =" row.id" >
580- <n-thing class =" center" :title =" row.filename" >
581- <template #description >
582- <n-space >
583- <n-tag type =" info" >
584- Size: {{ row.size }}
585- </n-tag >
586- <n-button v-if =" showSaveS3" @click =" saveToS3Proxy(row.filename, row.blob)" ghost type =" info"
587- size =" small" >
588- {{ t('saveToS3') }}
589- </n-button >
590- </n-space >
591- </template >
592- </n-thing >
593- <template #suffix >
594- <n-button tag =" a" target =" _blank" tertiary type =" info" size =" small" :download =" row.filename"
595- :href =" row.url" >
596- <n-icon :component =" CloudDownloadRound" />
597- </n-button >
598- </template >
599- </n-list-item >
600- </n-list >
601- </n-spin >
602- </n-modal >
603468 <n-modal v-model:show =" showMultiActionDownload" preset =" dialog" :title =" t('downloadMail')" >
604469 <n-tag type =" info" >
605470 {{ multiActionDownloadZip.filename }}
0 commit comments