UNPKG

vue-files-preview-inno

Version:

A tool for previewing files such as doc, excel, pdf, image, markdown, txt, audio, and video and so on.

3 lines (2 loc) 3.45 kB
"use strict";const e=require("vue"),g=require("../../../../node_modules/@kenjiuno/msgreader/lib/index.js"),m=require("../../utils/utils.js"),v={key:0,class:"msg-preview"},k={class:"msg-header"},y={class:"msg-subject"},_={class:"msg-meta"},h={key:0,class:"msg-field"},E={class:"msg-value"},f={key:0,class:"msg-email"},B={key:1,class:"msg-field"},N={class:"msg-value"},V={key:2,class:"msg-field"},b={class:"msg-value"},D={key:3,class:"msg-field"},S={class:"msg-value msg-attachments"},T={class:"msg-body"},C=["innerHTML"],F={key:1,class:"msg-body-text"},w={key:2,class:"msg-body-empty"},x=e.defineComponent({__name:"index",props:{file:{default:()=>null},url:{default:()=>null},name:{}},emits:["rendered","error"],setup(i,{emit:d}){const r=i,o=d,s=e.ref(null);function c(n){try{const t=new g(n);s.value=t.getFileData(),o("rendered")}catch(t){o("error",t instanceof Error?t:new Error("Failed to parse MSG file"))}}e.watch(()=>r.file,n=>{n&&m.getFileRenderByFile(n).then(t=>{c(t)}).catch(t=>{o("error",t)})},{immediate:!0}),e.watch(()=>r.url,n=>{n&&!r.file&&m.getFileRenderByUrl(n).then(t=>{c(t)}).catch(t=>{o("error",t)})},{immediate:!0});function u(n){return!n||n.length===0?"":n.map(t=>{const l=t.name||"",a=t.email||t.smtpAddress||"";return l&&a?`${l} <${a}>`:l||a}).join("; ")}function p(n){if(!n)return"";try{return new Date(n).toLocaleString()}catch{return n}}return(n,t)=>s.value?(e.openBlock(),e.createElementBlock("div",v,[e.createElementVNode("div",k,[e.createElementVNode("h2",y,e.toDisplayString(s.value.subject||"(No Subject)"),1),e.createElementVNode("div",_,[s.value.senderName||s.value.senderEmail?(e.openBlock(),e.createElementBlock("div",h,[t[0]||(t[0]=e.createElementVNode("span",{class:"msg-label"},"From",-1)),e.createElementVNode("span",E,[e.createTextVNode(e.toDisplayString(s.value.senderName)+" ",1),s.value.senderEmail?(e.openBlock(),e.createElementBlock("span",f,"<"+e.toDisplayString(s.value.senderEmail)+">",1)):e.createCommentVNode("",!0)])])):e.createCommentVNode("",!0),s.value.recipients&&s.value.recipients.length?(e.openBlock(),e.createElementBlock("div",B,[t[1]||(t[1]=e.createElementVNode("span",{class:"msg-label"},"To",-1)),e.createElementVNode("span",N,e.toDisplayString(u(s.value.recipients)),1)])):e.createCommentVNode("",!0),s.value.clientSubmitTime||s.value.messageDeliveryTime?(e.openBlock(),e.createElementBlock("div",V,[t[2]||(t[2]=e.createElementVNode("span",{class:"msg-label"},"Date",-1)),e.createElementVNode("span",b,e.toDisplayString(p(s.value.clientSubmitTime||s.value.messageDeliveryTime)),1)])):e.createCommentVNode("",!0),s.value.attachments&&s.value.attachments.length?(e.openBlock(),e.createElementBlock("div",D,[t[3]||(t[3]=e.createElementVNode("span",{class:"msg-label"},"Attachments",-1)),e.createElementVNode("span",S,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value.attachments,(l,a)=>(e.openBlock(),e.createElementBlock("span",{key:a,class:"msg-attachment-tag"},e.toDisplayString(l.fileName||l.name||"attachment"),1))),128))])])):e.createCommentVNode("",!0)])]),e.createElementVNode("div",T,[s.value.bodyHtml?(e.openBlock(),e.createElementBlock("div",{key:0,class:"msg-body-html",innerHTML:s.value.bodyHtml},null,8,C)):s.value.body?(e.openBlock(),e.createElementBlock("pre",F,e.toDisplayString(s.value.body),1)):(e.openBlock(),e.createElementBlock("div",w,"No content"))])])):e.createCommentVNode("",!0)}});module.exports=x; //# sourceMappingURL=index.vue2.js.map