import{d as K,c as F,r as me,e as a,f as i,k as n,w as t,bf as o,y as R,t as g,A as p,Z as d,v as z,j as h,l as ge,h as H,x as se,F as ne,H as v,b as fe}from"./@vue-73x4sYJ2.js";import{u as te}from"./vuex-6eozxOS7.js";import{u as ve,b as ke}from"./vue-router-22lN-LLO.js";import{J as ye,O as he,P as we,Q as be,u as $e,f as Ce,_ as L,R as Ie,S as Me}from"./index-Lx4Mi1rj.js";import{K as x,k as Se,N as ze,O as qe,Q as ee,U as Oe,r as T,s as Re,t as Ae,X as A,Y as Fe,Z as B,_ as V,R as D}from"./@vicons-UfsZxvNZ.js";import{F as Te,j as m,o as Ne,M as Pe,l as Ue,e as ae,P as oe,T as We,O as je,U as Be,a as Ve,G as De,Q as He,J as Qe,k as Je,H as Ze}from"./naive-ui-qF3urcFV.js";import{_ as Ee}from"./whisper-nUbeLD5N.js";import{_ as Ge}from"./main-nav.vue_vue_type_style_index_0_lang--76-h8Yy.js";import{W as Ke}from"./v3-infinite-loading-yUDJG3gQ.js";import"./axios-QLjAsgXu.js";import"./moment-TH1CLKMj.js";/* empty css */import"./seemly-tZbmuCcS.js";import"./vueuc-oXvKre1p.js";import"./evtd-9ZCiDXyn.js";import"./@css-render-RY9kiobo.js";import"./vooks-574GUng3.js";import"./vdirs-gz97tqc5.js";import"./@juggle--NVrOerG.js";import"./css-render-Jaty3dru.js";import"./@emotion-vV6BesBt.js";import"./lodash-es-KEIJqYRD.js";import"./treemate-hmrDCADh.js";import"./async-validator-BHjhHa7C.js";import"./date-fns-E8ESfRGG.js";const Le={class:"sender-wrap"},Xe={key:0,class:"nickname"},Ye={key:0,class:"username"},xe={key:1,class:"nickname"},es={key:0,class:"username"},ss={key:2,class:"nickname"},ns={class:"timestamp"},ts={class:"timestamp-txt"},as={key:0,class:"brief-content"},os={key:1,class:"whisper-content-wrap"},ls={key:2,class:"requesting-friend-wrap"},rs={key:2,class:"status-info"},is={key:3,class:"status-info"},us="https://assets.paopao.info/public/avatar/default/admin.png",cs=K({__name:"message-item",props:{message:{}},emits:["send-whisper","reload"],setup(Q,{emit:w}){const N=ve(),c=te(),f=Te(),u=Q,b=e=>()=>H(m,null,{default:()=>H(e)}),$=F(()=>{let e=u.message.type==4&&u.message.sender_user_id==c.state.userInfo.id?u.message.receiver_user:u.message.sender_user,s=[{label:"私信 @"+e.username,key:"whisper",icon:b(T)}];return c.state.userInfo.id!=e.id&&(e.is_following?s.push({label:"取消关注 @"+e.username,key:"unfollow",icon:b(Re)}):s.push({label:"关注 @"+e.username,key:"follow",icon:b(Ae)})),s}),_=w,k=e=>{let s=e.type==4&&e.sender_user_id==c.state.userInfo.id?e.receiver_user:e.sender_user;f.success({title:"提示",content:"确定"+(s.is_following?"取消关注 @":"关注 @")+s.username+" 吗?",positiveText:"确定",negativeText:"取消",onPositiveClick:()=>{s.is_following?$e({user_id:s.id}).then(y=>{window.$message.success("操作成功"),s.is_following=!1,setTimeout(()=>{_("reload")},50)}).catch(y=>{}):Ce({user_id:s.id}).then(y=>{window.$message.success("关注成功"),s.is_following=!0,setTimeout(()=>{_("reload")},50)}).catch(y=>{})}})},q=e=>{switch(e){case"whisper":const s=u.message;if(s.type!=99){let y=s.type==4&&s.sender_user_id==c.state.userInfo.id?s.receiver_user:s.sender_user;_("send-whisper",y)}break;case"follow":case"unfollow":k(u.message);break}},C=F(()=>u.message.type!==4||u.message.sender_user_id!==c.state.userInfo.id),P=F(()=>u.message.type==4&&u.message.receiver_user_id==c.state.userInfo.id),O=F(()=>u.message.type==4&&u.message.sender_user_id==c.state.userInfo.id),r=e=>{S(e),(e.type===1||e.type===2||e.type===3)&&(e.post&&e.post.id>0?N.push({name:"post",query:{id:e.post_id}}):window.$message.error("该动态已被删除"))},J=e=>{S(e),he({user_id:e.sender_user_id}).then(s=>{e.reply_id=2,window.$message.success("已同意添加好友")}).catch(s=>{console.log(s)})},U=e=>{S(e),we({user_id:e.sender_user_id}).then(s=>{e.reply_id=3,window.$message.success("已拒绝添加好友")}).catch(s=>{console.log(s)})},S=e=>{u.message.receiver_user_id==c.state.userInfo.id&&e.is_read===0&&be({id:e.id}).then(s=>{e.is_read=1}).catch(s=>{console.log(s)})};return(e,s)=>{const y=Ne,W=me("router-link"),I=Pe,Z=Ue,l=ae,j=oe,E=We,G=je;return a(),i("div",{class:ge(["message-item",{unread:C.value&&e.message.is_read===0}]),onClick:s[5]||(s[5]=M=>S(e.message))},[n(G,{"content-indented":""},{avatar:t(()=>[n(y,{round:"",size:30,src:e.message.type==4&&e.message.sender_user_id==o(c).state.userInfo.id?e.message.receiver_user.avatar:e.message.sender_user.id>0?e.message.sender_user.avatar:us},null,8,["src"])]),header:t(()=>[h("div",Le,[e.message.type!=4&&e.message.sender_user.id>0||P.value?(a(),i("span",Xe,[n(W,{onClick:s[0]||(s[0]=R(()=>{},["stop"])),class:"username-link",to:{name:"user",query:{s:e.message.sender_user.username}}},{default:t(()=>[p(g(e.message.sender_user.nickname),1)]),_:1},8,["to"]),o(c).state.desktopModelShow?(a(),i("span",Ye," @"+g(e.message.sender_user.username),1)):d("",!0)])):O.value?(a(),i("span",xe,[n(W,{onClick:s[1]||(s[1]=R(()=>{},["stop"])),class:"username-link",to:{name:"user",query:{s:e.message.receiver_user.username}}},{default:t(()=>[p(g(e.message.receiver_user.nickname),1)]),_:1},8,["to"]),o(c).state.desktopModelShow?(a(),i("span",es," @"+g(e.message.receiver_user.username),1)):d("",!0)])):(a(),i("span",ss," 系统 ")),O.value?(a(),z(I,{key:3,class:"top-tag",type:"info",size:"small",round:""},{icon:t(()=>[n(o(m),{component:o(x)},null,8,["component"])]),default:t(()=>[p(" 私信已发送 ")]),_:1})):d("",!0),e.message.type==4&&e.message.receiver_user_id==o(c).state.userInfo.id?(a(),z(I,{key:4,class:"top-tag",type:"warning",size:"small",round:""},{icon:t(()=>[n(o(m),{component:o(x)},null,8,["component"])]),default:t(()=>[p(" 私信已接收 ")]),_:1})):d("",!0)])]),"header-extra":t(()=>[h("span",ns,[C.value&&e.message.is_read===0?(a(),z(Z,{key:0,dot:"",processing:""})):d("",!0),h("span",ts,g(o(ye)(e.message.created_on)),1),n(j,{placement:"bottom-end",trigger:"click",size:"small",options:$.value,onSelect:q},{default:t(()=>[n(l,{quaternary:"",circle:""},{icon:t(()=>[n(o(m),null,{default:t(()=>[n(o(Se))]),_:1})]),_:1})]),_:1},8,["options"])])]),description:t(()=>[n(E,{"show-icon":!1,class:"brief-wrap",type:!C.value||e.message.is_read>0?"default":"success"},{default:t(()=>[e.message.type!=4?(a(),i("div",as,[p(g(e.message.brief)+" ",1),e.message.type===1||e.message.type===2||e.message.type===3?(a(),i("span",{key:0,onClick:s[2]||(s[2]=R(M=>r(e.message),["stop"])),class:"hash-link view-link"},[n(o(m),null,{default:t(()=>[n(o(ze))]),_:1}),p(" 查看详情 ")])):d("",!0)])):d("",!0),e.message.type===4?(a(),i("div",os,g(e.message.content),1)):d("",!0),e.message.type===5?(a(),i("div",ls,[p(g(e.message.content)+" ",1),e.message.reply_id===1?(a(),i("span",{key:0,onClick:s[3]||(s[3]=R(M=>J(e.message),["stop"])),class:"hash-link view-link"},[n(o(m),null,{default:t(()=>[n(o(qe))]),_:1}),p(" 同意 ")])):d("",!0),e.message.reply_id===1?(a(),i("span",{key:1,onClick:s[4]||(s[4]=R(M=>U(e.message),["stop"])),class:"hash-link view-link"},[n(o(m),null,{default:t(()=>[n(o(ee))]),_:1}),p(" 拒绝 ")])):d("",!0),e.message.reply_id===2?(a(),i("span",rs,[n(o(m),null,{default:t(()=>[n(o(Oe))]),_:1}),p(" 已同意 ")])):d("",!0),e.message.reply_id===3?(a(),i("span",is,[n(o(m),null,{default:t(()=>[n(o(ee))]),_:1}),p(" 已拒绝 ")])):d("",!0)])):d("",!0)]),_:1},8,["type"])]),_:1})],2)}}}),_s=L(cs,[["__scopeId","data-v-019d5af4"]]),ds={class:"content"},ps=K({__name:"message-skeleton",props:{num:{default:1}},setup(Q){return(w,N)=>{const c=Be;return a(!0),i(ne,null,se(new Array(w.num),f=>(a(),i("div",{class:"skeleton-item",key:f},[h("div",ds,[n(c,{text:"",repeat:2}),n(c,{text:"",style:{width:"60%"}})])]))),128)}}}),ms=L(ps,[["__scopeId","data-v-01d2e871"]]),gs={class:"title title-action"},fs={class:"title title-filter"},vs={key:0,class:"skeleton-wrap"},ks={key:1},ys={key:0,class:"empty-wrap"},hs={key:1},ws={class:"load-more-wrap"},bs={class:"load-more-spinner"},$s=K({__name:"Messages",setup(Q){const w=te(),N=ke(),c=v(!1),f=v(!1),u=v(+N.query.p||1),b=v(20),$=v(0),_=v([]),k=v("所有消息"),q=v("all"),C=v(!1),P=v({id:0,avatar:"",username:"",nickname:"",is_admin:!1,is_friend:!0,is_following:!1,created_on:0,follows:0,followings:0,status:1}),O=()=>{f.value=!1,u.value=1,$.value=0,_.value=[]},r=l=>()=>H(m,null,{default:()=>H(l)}),J=F(()=>{let l;switch(k.value){case"所有消息":l=[{label:"系统消息",key:"system",icon:r(V)},{label:"我的私信",key:"whisper",icon:r(T)},{label:"好友申请",key:"requesting",icon:r(D)},{label:"未读消息",key:"unread",icon:r(A)}];break;case"系统消息":l=[{label:"所有消息",key:"all",icon:r(B)},{label:"我的私信",key:"whisper",icon:r(T)},{label:"好友申请",key:"requesting",icon:r(D)},{label:"未读消息",key:"unread",icon:r(A)}];break;case"我的私信":l=[{label:"所有消息",key:"all",icon:r(B)},{label:"系统消息",key:"system",icon:r(V)},{label:"好友申请",key:"requesting",icon:r(D)},{label:"未读消息",key:"unread",icon:r(A)}];break;case"好友申请":l=[{label:"所有消息",key:"all",icon:r(B)},{label:"系统消息",key:"system",icon:r(V)},{label:"我的私信",key:"whisper",icon:r(T)},{label:"未读消息",key:"unread",icon:r(A)}];break;case"未读消息":l=[{label:"所有消息",key:"all",icon:r(B)},{label:"系统消息",key:"system",icon:r(V)},{label:"我的私信",key:"whisper",icon:r(T)},{label:"好友申请",key:"requesting",icon:r(D)}];break;default:l=[];break}return l}),U=l=>{switch(l){case"all":k.value="所有消息";break;case"system":k.value="系统消息";break;case"whisper":k.value="我的私信";break;case"requesting":k.value="好友申请";break;case"unread":k.value="未读消息";break}q.value=l,O(),I()},S=()=>{U("unread")},e=()=>{w.state.unreadMsgCount>0&&_.value.length>0&&Me().then(l=>{if(q.value!="unread")for(let j in _.value)_.value[j].is_read=1;else _.value=[];w.commit("updateUnreadMsgCount",0)}).catch(l=>{console.log(l)})},s=l=>{P.value=l,C.value=!0},y=()=>{C.value=!1},W=()=>{O(),I()},I=()=>{c.value=!0,Ie({style:q.value,page:u.value,page_size:b.value}).then(l=>{c.value=!1,l.list.length===0&&(f.value=!0),u.value>1?_.value=_.value.concat(l.list):(_.value=l.list,window.scrollTo(0,0)),$.value=Math.ceil(l.pager.total_rows/b.value)}).catch(l=>{c.value=!1,u.value>1&&u.value--})},Z=()=>{u.value<$.value||$.value==0?(f.value=!1,u.value++,I()):f.value=!0};return fe(()=>{I()}),(l,j)=>{const E=Ge,G=Ee,M=ae,le=He,re=oe,X=Ve,ie=ms,ue=Qe,ce=_s,_e=Ze,de=De,pe=Je;return a(),i("div",null,[n(E,{title:"消息"}),n(de,{class:"main-content-wrap messages-wrap",bordered:""},{default:t(()=>[n(G,{show:C.value,user:P.value,onSuccess:y},null,8,["show","user"]),n(X,{justify:"space-between"},{default:t(()=>[h("div",gs,[n(M,{text:"",size:"small",focusable:!1,onClick:S},{icon:t(()=>[n(o(m),null,{default:t(()=>[n(o(A))]),_:1})]),default:t(()=>[p(" "+g(o(w).state.unreadMsgCount)+" 条未读 ",1)]),_:1}),n(le,{vertical:""}),n(M,{text:"",size:"small",focusable:!1,onClick:e},{default:t(()=>[p("全标已读")]),_:1})]),h("div",fs,[n(re,{placement:"bottom-end",trigger:"click",size:"small",options:J.value,onSelect:U},{default:t(()=>[n(M,{text:""},{icon:t(()=>[n(o(m),null,{default:t(()=>[n(o(Fe))]),_:1})]),default:t(()=>[p(" "+g(k.value),1)]),_:1})]),_:1},8,["options"])])]),_:1}),c.value&&_.value.length===0?(a(),i("div",vs,[n(ie,{num:b.value},null,8,["num"])])):(a(),i("div",ks,[_.value.length===0?(a(),i("div",ys,[n(ue,{size:"large",description:"暂无数据"})])):(a(),i("div",hs,[(a(!0),i(ne,null,se(_.value,Y=>(a(),z(_e,{key:Y.id},{default:t(()=>[n(ce,{message:Y,onSendWhisper:s,onReload:W},null,8,["message"])]),_:2},1024))),128))]))]))]),_:1}),$.value>0?(a(),z(X,{key:0,justify:"center"},{default:t(()=>[n(o(Ke),{class:"load-more",slots:{complete:"没有更多消息了",error:"加载出错"},onInfinite:Z},{spinner:t(()=>[h("div",ws,[f.value?d("",!0):(a(),z(pe,{key:0,size:14})),h("span",bs,g(f.value?"没有更多消息了":"加载更多"),1)])]),_:1})]),_:1})):d("",!0)])}}}),Ks=L($s,[["__scopeId","data-v-a2e6a3be"]]);export{Ks as default};