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