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