mirror of
https://github.com/schroinerxy/cloud-mail.git
synced 2026-06-21 19:35:50 +08:00
2 lines
13 KiB
JavaScript
2 lines
13 KiB
JavaScript
import{c as r,o as t,ap as re,f as s,ab as a,e as c,n as D,g as d,p as m,h as j,t as S,i as C,P as R,aj as Ee,af as xe,al as $e,z as p,D as ae,bN as Be,bO as Ce,F as N,k as De,r as Q,N as oe,m as v,ah as Fe,a7 as ne,an as Ue}from"./index-BtzXKQwE.js";import{a as Le,E as Ae,s as Te,b as ze}from"./time-utils-B0dkmGNr.js";import{E as Ve}from"./el-scrollbar-CKPMF6AL.js";import{E as Me}from"./el-empty-B50ZRwXV.js";import"./el-tooltip-l0sNRNKZ.js";import{a as Ne,E as je}from"./el-tag-Crsyy918.js";import{E as de}from"./el-checkbox-DMbFvupR.js";import{l as ie}from"./index-EFTyCj7O.js";import{I as h}from"./iconify-py6I6n_h.js";import{_ as ue}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{u as Re}from"./email-CLpV48-R.js";import{b as ce}from"./day-PdIoF79x.js";/* empty css *//* empty css *//* empty css */import{E as qe}from"./index-CTUonbyI.js";const Pe={style:{background:"var(--el-bg-color)"}},He={class:"email-row"},Oe={key:0,class:"pc-star"},We={key:1},Ge={class:"email-sender"},Je={key:0,class:"email-status"},Ke={key:1},Qe={class:"name"},Xe={class:"phone-time"},Ye={class:"email-text-skeleton"},Ze={key:0,class:"user-info"},et={class:"user"},tt={class:"account"},st={key:0,class:"del-status"},lt={__name:"index",props:{rows:{type:Number,default:1},showStar:{type:Boolean,default:!0},accountShow:{type:Boolean,default:!1},showStatus:{type:Boolean,default:!1},showUserInfo:{type:Boolean,default:!1},type:{type:String,default:""}},setup(l){const q=l;return(P,w)=>{const $=de,k=Le,I=Ae,B=Ne;return t(!0),r(R,null,re(l.rows,g=>(t(),r("div",Pe,[s("div",He,[a($,{disabled:"",class:D(q.type==="all-email"?"all-email-checkbox":"checkbox")},null,8,["class"]),l.showStar?(t(),r("div",Oe,[a(d(h),{style:{color:"var(--el-border-color)"},icon:"solar:star-line-duotone",width:"18",height:"18"})])):c("",!0),l.showStar?c("",!0):(t(),r("div",We)),s("div",{class:D(["title",(l.accountShow,"title-column")])},[s("div",Ge,[l.showStatus?(t(),r("div",Je)):(t(),r("div",Ke)),s("span",Qe,[s("span",null,[a(I,{animated:""},{template:m(()=>[a(k,{variant:"text",class:"name-skeleton"})]),_:1})]),w[0]||(w[0]=s("span",null,null,-1))]),s("span",Xe,[a(I,{animated:""},{template:m(()=>[a(k,{variant:"text",style:{width:"50px",height:"1rem"}})]),_:1})])]),s("div",null,[s("div",Ye,[a(I,{animated:""},{template:m(()=>[a(k,{variant:"text",class:"text-skeleton-one"}),a(k,{variant:"text",class:"text-skeleton-two"})]),_:1})]),l.showUserInfo?(t(),r("div",Ze,[s("div",et,[a(I,{animated:""},{template:m(()=>[a(k,{variant:"text",style:{width:"180px","margin-right":"15px",height:"1rem","margin-bottom":"4px"}})]),_:1})]),s("div",tt,[a(I,{animated:""},{template:m(()=>[a(k,{variant:"text",style:{width:"180px","margin-right":"15px",height:"1rem","margin-bottom":"4px"}})]),_:1})]),g.isDel?(t(),r("div",st,[a(B,{type:"danger",size:"small"},{default:m(()=>[j(S(P.$t("deleted")),1)]),_:1})])):c("",!0)])):c("",!0)])],2),s("div",{class:"email-right-skeleton",style:C(l.showUserInfo?"align-self: start;":"")},[a(I,{animated:""},{template:m(()=>[a(k,{variant:"text",style:{width:"50px","margin-right":"15px",height:"1rem"}})]),_:1})],4)])]))),256)}}},X=ue(lt,[["__scopeId","data-v-002b4228"]]),at={class:"email-container"},ot={class:"header-actions"},nt={class:"header-right"},it={key:0,class:"email-count"},ct={class:"scroll-box","infinite-scroll-immediate":!1,"infinite-scroll-distance":"600"},rt=["data-checked","onClick"],dt=["onClick"],ut={key:1},ht={key:0,class:"email-status"},ft={key:7,class:"del-status"},mt={key:1},vt={class:"name"},wt={class:"phone-time"},kt={class:"email-text"},gt={class:"email-subject"},yt={class:"email-content"},pt={key:0,class:"user-info"},St={class:"user"},It={class:"account"},_t={class:"email-time"},bt={key:0,class:"follow-loading"},Et={key:3,class:"noLoading"},xt={key:4,class:"empty"},$t={__name:"index",props:{getEmailList:Function,emailDelete:Function,starAdd:Function,starCancel:Function,cancelSuccess:Function,starSuccess:Function,actionLeft:{type:String,default:"0"},timeSort:{type:Number,default:0},showStatus:{type:Boolean,default:!1},showAccountIcon:{type:Boolean,default:!0},showUserInfo:{type:Boolean,default:!1},showStar:{type:Boolean,default:!0},allowStar:{type:Boolean,default:!0},type:{type:String,default:""},skeleton:{type:Boolean,default:!0},showFirstLoading:{type:Boolean,default:!0}},emits:["jump","refresh-before","delete-draft"],setup(l,{expose:q,emit:P}){const w=l,$=P,{t:k}=Ee(),I=xe(),B=$e(),g=Re(),y=p(!1),F=p(!1),_=p(!1),o=ae([]),E=p(0),U=p(!1),L=p(!1),H=p(null),A=p(!0);let Y=0;const O=p(null),W=p(null);let T=!1,Z=innerWidth<1025,z=0;const b=ae({emailId:0,size:30});q({refreshList:le,deleteEmail:te,addItem:ke,emailList:o,firstLoad:A,latestEmail:O,noLoading:_,total:E}),Be(()=>{H.value.scrollTop=Y}),M(),Ce(()=>{Y=H.value.scrollTop}),N(()=>o.map(e=>e.checked),()=>{o.length>0&&pe()},{deep:!0}),N(()=>g.deleteIds,()=>{g.deleteIds&&te(g.deleteIds)}),N(()=>g.cancelStarEmailId,()=>{o.forEach(e=>{e.emailId===g.cancelStarEmailId&&(e.isStar=0)})}),N(()=>g.addStarEmailId,()=>{o.forEach(e=>{e.emailId===g.addStarEmailId&&(e.isStar=1)})});function he(){if(o.length>20)return z=20;if(o.length===0)return z=1;z=o.length}const V=De(()=>B.accountShow&&I.settings.manyEmail===0);function fe(e){if(e.content){const i=document.createElement("div");i.innerHTML=e.content.replace(/<(img|iframe|object|embed|video|audio|source|link)[^>]*>/gi,""),i.querySelectorAll("script, style, title").forEach(x=>x.remove());let u=i.textContent||i.innerText||"";return u=u.replace(/\s+/g," ").trim(),ee(u)}return e.text?ee(e.text):""}function ee(e){return e.replace(/[\u200B-\u200F\uFEFF\u034F\u200B-\u200F\u00A0\u3000\u00AD]/g,"").replace(/\s+/g," ").trim()}function me(e){if(e.isStar)e.isStar=0,w.starCancel(e.emailId).then(()=>{e.isStar=0,w.cancelSuccess?.(e)}).catch(i=>{console.error(i),e.isStar=1});else{if(!w.allowStar)return;e.isStar=1,w.starAdd(e.emailId).then(()=>{e.isStar=1,w.starSuccess(e)}).catch(i=>{console.error(i),e.isStar=0})}}function ve(){B.accountShow=!B.accountShow}const we=()=>{qe.confirm(k("delEmailsConfirm"),{confirmButtonText:k("confirm"),cancelButtonText:k("cancel"),type:"warning"}).then(()=>{if(w.type==="draft"){const i=ye();$("delete-draft",i);return}const e=se();w.emailDelete(e).then(()=>{Ue({message:k("delSuccessMsg"),type:"success",plain:!0}),g.deleteIds=e})})};function te(e){e.forEach(i=>{o.forEach((f,u)=>{i===f.emailId&&o.splice(u,1)})}),o.length<b.size&&!_.value&&M()}function ke(e){if(o.findIndex(u=>u.emailId===e.emailId)>-1)return;if(w.timeSort){_.value&&(o.push(e),O.value=e),E.value++;return}const f=o.findIndex(u=>u.emailId<e.emailId);f!==-1?o.splice(f,0,e):_.value&&o.push(e),E.value++}function ge(e){o.forEach(i=>i.checked=e),L.value=!1}function se(){return o.filter(e=>e.checked).map(e=>e.emailId)}function ye(){return o.filter(e=>e.checked).map(e=>e.draftId)}function pe(){const e=o.filter(i=>i.checked).length;U.value=e===o.length,L.value=e>0&&e<o.length}function Se(e){$("jump",e)}function M(e=!1){if(T)return;if(T=!0,e)he(),y.value=!0;else if(y.value||_.value){T=!1;return}o.length===0?y.value=!0:F.value=!e;let i=Date.now();w.getEmailList(b.emailId,b.size).then(async f=>{let x=Date.now()-i;x<500&&!b.emailId&&await Te(500-x),A.value=!1;let G=f.list.map(J=>({...J,checked:!1}));e&&(o.length=0),O.value=f.latestEmail,o.push(...G),e&&W.value?.setScrollTop(0),_.value=f.list.length<b.size,F.value=f.list.length>=b.size,E.value=f.total,b.emailId=f.list.length>0?f.list.at(-1).emailId:0}).finally(()=>{y.value=!1,T=!1})}function Ie(){$("refresh-before"),w.skeleton&&W.value.setScrollTop(0),le()}function le(){U.value=!1,L.value=!1,b.emailId=0,M(!0)}function _e(){M()}return(e,i)=>{const f=de,u=je,x=Me,G=Ve,J=Fe("perm"),be=ze;return t(),r("div",at,[s("div",ot,[a(f,{modelValue:U.value,"onUpdate:modelValue":i[0]||(i[0]=n=>U.value=n),indeterminate:L.value,disabled:!o.length||y.value,onChange:ge},null,8,["modelValue","indeterminate","disabled"]),s("div",{class:"header-left",style:C("padding-left:"+l.actionLeft)},[Q(e.$slots,"first",{},void 0,!0),a(d(h),{class:"icon reload",icon:"ion:reload",width:"18",height:"18",onClick:Ie}),se().length>0?oe((t(),v(d(h),{key:0,class:"icon",icon:"uiw:delete",width:"16",height:"16",onClick:we},null,512)),[[J,"email:delete"]]):c("",!0)],4),s("div",nt,[E.value?(t(),r("span",it,S(e.$t("emailCount",{total:E.value})),1)):c("",!0),l.showAccountIcon?(t(),v(d(h),{key:1,class:"more-icon icon",width:"16",height:"16",icon:"akar-icons:dot-grid-fill",onClick:ve})):c("",!0)])]),s("div",{ref_key:"scroll",ref:H,class:"scroll"},[a(G,{ref_key:"scrollbarRef",ref:W,style:{height:"100%"}},{default:m(()=>[oe((t(),r("div",ct,[l.skeleton&&!y.value?(t(!0),r(R,{key:0},re(o,n=>(t(),r("div",{key:n.emailId},[s("div",{class:"email-row","data-checked":n.checked,onClick:K=>Se(n)},[a(f,{class:D(w.type==="all-email"?"all-email-checkbox":"checkbox"),modelValue:n.checked,"onUpdate:modelValue":K=>n.checked=K,onClick:i[1]||(i[1]=ne(()=>{},["stop"]))},null,8,["class","modelValue","onUpdate:modelValue"]),l.showStar?(t(),r("div",{key:0,onClick:ne(K=>me(n),["stop"]),class:"pc-star"},[n.isStar?(t(),v(d(h),{key:0,icon:"fluent-color:star-16",width:"20",height:"20"})):(t(),v(d(h),{key:1,icon:"solar:star-line-duotone",width:"18",height:"18"}))],8,dt)):c("",!0),l.showStar?c("",!0):(t(),r("div",ut)),s("div",{class:D(["title",(V.value,"title-column")])},[s("div",{class:"email-sender",style:C(l.showStatus?"gap: 10px;":"")},[l.showStatus?(t(),r("div",ht,[n.status===0?(t(),v(u,{key:0,effect:"dark",content:e.$t("received")},{default:m(()=>[a(d(h),{icon:"ic:round-mark-email-read",style:{color:"#67C23A"},width:"20",height:"20"}),i[2]||(i[2]=j(" /> "))]),_:1},8,["content"])):c("",!0),n.status===1?(t(),v(u,{key:1,effect:"dark",content:e.$t("sent")},{default:m(()=>[a(d(h),{icon:"bi:send-arrow-up-fill",style:{color:"#67C23A"},width:"20",height:"20"})]),_:1},8,["content"])):c("",!0),n.status===2?(t(),v(u,{key:2,effect:"dark",content:e.$t("delivered")},{default:m(()=>[a(d(h),{icon:"bi:send-check-fill",style:{color:"#67C23A"},width:"20",height:"20"})]),_:1},8,["content"])):c("",!0),n.status===3?(t(),v(u,{key:3,effect:"dark",content:e.$t("bounced")},{default:m(()=>[a(d(h),{icon:"bi:send-x-fill",style:{color:"#F56C6C"},width:"20",height:"20"})]),_:1},8,["content"])):c("",!0),n.status===4?(t(),v(u,{key:4,effect:"dark",content:e.$t("complained")},{default:m(()=>[a(d(h),{icon:"bi:send-exclamation-fill",style:{color:"#FBBD08"},width:"20",height:"20"})]),_:1},8,["content"])):c("",!0),n.status===5?(t(),v(u,{key:5,effect:"dark",content:e.$t("delayed")},{default:m(()=>[a(d(h),{icon:"bi:send-arrow-up-fill",style:{color:"#FBBD08"},width:"20",height:"20"})]),_:1},8,["content"])):c("",!0),n.status===7?(t(),v(u,{key:6,effect:"dark",content:e.$t("noRecipient")},{default:m(()=>[a(d(h),{icon:"ic:round-mark-email-read",style:{color:"#FBBD08"},width:"20",height:"20"})]),_:1},8,["content"])):c("",!0),n.isDel?(t(),r("div",ft,[a(u,{effect:"dark",content:e.$t("selectDeleted")},{default:m(()=>[a(d(h),{class:"icon",icon:"mdi:email-remove",width:"20",height:"20"})]),_:1},8,["content"])])):c("",!0)])):(t(),r("div",mt)),s("span",vt,[s("span",null,[Q(e.$slots,"name",{email:n},()=>[j(S(n.name),1)],!0)]),s("span",null,[n.isStar?(t(),v(d(h),{key:0,icon:"fluent-color:star-16",width:"18",height:"18"})):c("",!0)])]),s("span",wt,S(d(ce)(n.createTime)),1)],4),s("div",null,[s("div",kt,[s("span",gt,[Q(e.$slots,"subject",{email:n},()=>[j(S(n.subject||""),1)],!0)]),s("span",yt,S(fe(n)||""),1)]),l.showUserInfo?(t(),r("div",pt,[s("div",St,[s("span",null,[a(d(h),{icon:"mynaui:user",width:"20",height:"20"})]),s("span",null,S(n.userEmail),1)]),s("div",It,[s("span",null,[a(d(h),{icon:"mdi-light:email",width:"20",height:"20"})]),s("span",null,S(n.type===0?n.toEmail:n.sendEmail),1)])])):c("",!0)])],2),s("div",{class:"email-right",style:C(l.showUserInfo?"align-self: start;":"")},[s("span",_t,S(d(ce)(n.createTime)),1)],4)],8,rt)]))),128)):c("",!0),l.skeleton?(t(),r(R,{key:1},[A.value&&l.showFirstLoading?(t(),v(X,{key:0,rows:20,showStar:l.showStar,accountShow:V.value,showStatus:l.showStatus,showUserInfo:l.showUserInfo,type:l.type},null,8,["showStar","accountShow","showStatus","showUserInfo","type"])):c("",!0),y.value?(t(),v(X,{key:1,rows:d(z),showStar:l.showStar,accountShow:V.value,showStatus:l.showStatus,showUserInfo:l.showUserInfo,type:l.type},null,8,["rows","showStar","accountShow","showStatus","showUserInfo","type"])):c("",!0),F.value?(t(),v(X,{key:2,rows:d(Z)?1:2,showStar:l.showStar,accountShow:V.value,showStatus:l.showStatus,showUserInfo:l.showUserInfo,type:l.type},null,8,["rows","showStar","accountShow","showStatus","showUserInfo","type"])):c("",!0)],64)):(t(),r(R,{key:2},[i[3]||(i[3]=s("div",null,null,-1)),s("div",{class:D(["loading",y.value?"loading-show":"loading-hide"]),style:C(A.value?"background: transparent":"")},[a(ie)],6),F.value?(t(),r("div",bt,[a(ie)])):c("",!0)],64)),_.value&&o.length>0&&!(l.skeleton&&y.value)?(t(),r("div",Et,[s("div",null,S(e.$t("noMoreData")),1)])):c("",!0),_.value&&o.length===0&&!(l.skeleton&&y.value)?(t(),r("div",xt,[a(x,{"image-size":d(Z)?120:0,description:e.$t("noMessagesFound")},null,8,["image-size","description"])])):c("",!0)])),[[be,_e]])]),_:3},512)],512)])}}},Ht=ue($t,[["__scopeId","data-v-9c4eeb48"]]);export{Ht as e};
|