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.
paopao-ce/web/dist/assets/Messages-fb6513c1.js

2 lines
8.7 KiB

import{d as U,c as N,r as K,e as t,f as r,k as n,w as o,bf as a,j as w,y as O,A as _,x as g,q as S,Y as u,l as X,h as H,u as E,F as G,H as y,b as Z}from"./@vue-a481fc63.js";import{u as J}from"./vuex-44de225f.js";import{u as x,b as ee}from"./vue-router-e5a2430e.js";import{I as se,N as ne,O as te,P as oe,u as ae,f as re,_ as j,Q as ie}from"./index-daff1b26.js";import{N as V,k as le,O as ue,Q as _e,R as Q,U as pe,r as ce,s as de,t as me}from"./@vicons-c265fba6.js";import{F as ge,j as m,o as fe,M as ve,l as ye,e as ke,P as he,T as we,O as $e,U as be,G as Ce,R as Ie,J as Me,H as Oe}from"./naive-ui-defd0b2d.js";import{_ as Se}from"./whisper-9b4eeceb.js";import{_ as ze}from"./main-nav.vue_vue_type_style_index_0_lang-93352cc4.js";import"./axios-4a70c6fc.js";import"./moment-2ab8298d.js";/* empty css */import"./seemly-76b7b838.js";import"./vueuc-39372edb.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 Re={class:"sender-wrap"},Fe={key:0,class:"nickname"},Ne={class:"username"},qe={key:1,class:"nickname"},Pe={class:"username"},Te={key:2,class:"nickname"},Ae={class:"timestamp"},We={class:"timestamp-txt"},Be={key:0,class:"brief-content"},Ue={key:1,class:"whisper-content-wrap"},je={key:2,class:"requesting-friend-wrap"},De={key:2,class:"status-info"},He={key:3,class:"status-info"},Ve="https://assets.paopao.info/public/avatar/default/admin.png",Qe=U({__name:"message-item",props:{message:{}},emits:["send-whisper","reload"],setup(q,{emit:f}){const i=q,c=x(),l=J(),$=ge(),v=e=>()=>H(m,null,{default:()=>H(e)}),b=N(()=>{let e=[{label:"私信",key:"whisper",icon:v(ce)}],s=i.message.type==4&&i.message.sender_user_id==l.state.userInfo.id?i.message.receiver_user:i.message.sender_user;return l.state.userInfo.id!=s.id&&(s.is_following?e.push({label:"取消关注",key:"unfollow",icon:v(de)}):e.push({label:"关注",key:"follow",icon:v(me)})),e}),C=e=>{let s=e.type==4&&e.sender_user_id==l.state.userInfo.id?e.receiver_user:e.sender_user;$.success({title:"提示",content:"确定"+(s.is_following?"取消关注":"关注")+"该用户吗?",positiveText:"确定",negativeText:"取消",onPositiveClick:()=>{s.is_following?ae({user_id:s.id}).then(d=>{window.$message.success("操作成功"),s.is_following=!1,setTimeout(()=>{f("reload")},50)}).catch(d=>{}):re({user_id:s.id}).then(d=>{window.$message.success("关注成功"),s.is_following=!0,setTimeout(()=>{f("reload")},50)}).catch(d=>{})}})},z=e=>{switch(e){case"whisper":const s=i.message;if(s.type!=99){let d=s.type==4&&s.sender_user_id==l.state.userInfo.id?s.receiver_user:s.sender_user;f("send-whisper",d)}break;case"follow":case"unfollow":C(i.message);break}},I=N(()=>i.message.type!==4||i.message.sender_user_id!==l.state.userInfo.id),P=N(()=>i.message.type==4&&i.message.receiver_user_id==l.state.userInfo.id),k=N(()=>i.message.type==4&&i.message.sender_user_id==l.state.userInfo.id),T=e=>{h(e),(e.type===1||e.type===2||e.type===3)&&(e.post&&e.post.id>0?c.push({name:"post",query:{id:e.post_id}}):window.$message.error("该动态已被删除"))},p=e=>{h(e),ne({user_id:e.sender_user_id}).then(s=>{e.reply_id=2,window.$message.success("已同意添加好友")}).catch(s=>{console.log(s)})},D=e=>{h(e),te({user_id:e.sender_user_id}).then(s=>{e.reply_id=3,window.$message.success("已拒绝添加好友")}).catch(s=>{console.log(s)})},h=e=>{i.message.receiver_user_id==l.state.userInfo.id&&e.is_read===0&&oe({id:e.id}).then(s=>{e.is_read=1}).catch(s=>{console.log(s)})};return(e,s)=>{const d=fe,R=K("router-link"),M=ve,A=ye,W=ke,F=he,L=we,Y=$e;return t(),r("div",{class:X(["message-item",{unread:I.value&&e.message.is_read===0}]),onClick:s[5]||(s[5]=B=>h(e.message))},[n(Y,{"content-indented":""},{avatar:o(()=>[n(d,{round:"",size:30,src:e.message.type==4&&e.message.sender_user_id==a(l).state.userInfo.id?e.message.receiver_user.avatar:e.message.sender_user.id>0?e.message.sender_user.avatar:Ve},null,8,["src"])]),header:o(()=>[w("div",Re,[e.message.type!=4&&e.message.sender_user.id>0||P.value?(t(),r("span",Fe,[n(R,{onClick:s[0]||(s[0]=O(()=>{},["stop"])),class:"username-link",to:{name:"user",query:{s:e.message.sender_user.username}}},{default:o(()=>[_(g(e.message.sender_user.nickname),1)]),_:1},8,["to"]),w("span",Ne," @"+g(e.message.sender_user.username),1)])):k.value?(t(),r("span",qe,[n(R,{onClick:s[1]||(s[1]=O(()=>{},["stop"])),class:"username-link",to:{name:"user",query:{s:e.message.receiver_user.username}}},{default:o(()=>[_(g(e.message.receiver_user.nickname),1)]),_:1},8,["to"]),w("span",Pe," @"+g(e.message.receiver_user.username),1)])):(t(),r("span",Te," 系统 ")),e.message.type==4?(t(),S(M,{key:3,class:"top-tag",type:"success",size:"small",round:""},{default:o(()=>[_(" 私信 ")]),_:1})):u("",!0),k.value?(t(),S(M,{key:4,class:"top-tag",type:"info",size:"small",round:""},{icon:o(()=>[n(a(m),{component:a(V)},null,8,["component"])]),default:o(()=>[_(" 已发送 ")]),_:1})):u("",!0),e.message.type==4&&e.message.receiver_user_id==a(l).state.userInfo.id?(t(),S(M,{key:5,class:"top-tag",type:"warning",size:"small",round:""},{icon:o(()=>[n(a(m),{component:a(V)},null,8,["component"])]),default:o(()=>[_(" 已接收 ")]),_:1})):u("",!0)])]),"header-extra":o(()=>[w("span",Ae,[I.value&&e.message.is_read===0?(t(),S(A,{key:0,dot:"",processing:""})):u("",!0),w("span",We,g(a(se)(e.message.created_on)),1),n(F,{placement:"bottom-end",trigger:"click",size:"small",options:b.value,onSelect:z},{default:o(()=>[n(W,{quaternary:"",circle:""},{icon:o(()=>[n(a(m),null,{default:o(()=>[n(a(le))]),_:1})]),_:1})]),_:1},8,["options"])])]),description:o(()=>[n(L,{"show-icon":!1,class:"brief-wrap",type:!I.value||e.message.is_read>0?"default":"success"},{default:o(()=>[e.message.type!=4?(t(),r("div",Be,[_(g(e.message.brief)+" ",1),e.message.type===1||e.message.type===2||e.message.type===3?(t(),r("span",{key:0,onClick:s[2]||(s[2]=O(B=>T(e.message),["stop"])),class:"hash-link view-link"},[n(a(m),null,{default:o(()=>[n(a(ue))]),_:1}),_(" 查看详情 ")])):u("",!0)])):u("",!0),e.message.type===4?(t(),r("div",Ue,g(e.message.content),1)):u("",!0),e.message.type===5?(t(),r("div",je,[_(g(e.message.content)+" ",1),e.message.reply_id===1?(t(),r("span",{key:0,onClick:s[3]||(s[3]=O(B=>p(e.message),["stop"])),class:"hash-link view-link"},[n(a(m),null,{default:o(()=>[n(a(_e))]),_:1}),_(" 同意 ")])):u("",!0),e.message.reply_id===1?(t(),r("span",{key:1,onClick:s[4]||(s[4]=O(B=>D(e.message),["stop"])),class:"hash-link view-link"},[n(a(m),null,{default:o(()=>[n(a(Q))]),_:1}),_(" 拒绝 ")])):u("",!0),e.message.reply_id===2?(t(),r("span",De,[n(a(m),null,{default:o(()=>[n(a(pe))]),_:1}),_(" 已同意 ")])):u("",!0),e.message.reply_id===3?(t(),r("span",He,[n(a(m),null,{default:o(()=>[n(a(Q))]),_:1}),_(" 已拒绝 ")])):u("",!0)])):u("",!0)]),_:1},8,["type"])]),_:1})],2)}}});const Ee=j(Qe,[["__scopeId","data-v-282eff6a"]]),Ge={class:"content"},Je=U({__name:"message-skeleton",props:{num:{default:1}},setup(q){return(f,i)=>{const c=be;return t(!0),r(G,null,E(new Array(f.num),l=>(t(),r("div",{class:"skeleton-item",key:l},[w("div",Ge,[n(c,{text:"",repeat:2}),n(c,{text:"",style:{width:"60%"}})])]))),128)}}});const Le=j(Je,[["__scopeId","data-v-01d2e871"]]),Ye={key:0,class:"skeleton-wrap"},Ke={key:1},Xe={key:0,class:"empty-wrap"},Ze={key:0,class:"pagination-wrap"},xe=U({__name:"Messages",setup(q){const f=ee(),i=J(),c=y(!1),l=y(+f.query.p||1),$=y(10),v=y(0),b=y([]),C=y(!1),z=y({id:0,avatar:"",username:"",nickname:"",is_admin:!1,is_friend:!0,is_following:!1,created_on:0,follows:0,followings:0,status:1}),I=p=>{z.value=p,C.value=!0},P=()=>{C.value=!1},k=()=>{c.value=!0,ie({page:l.value,page_size:$.value}).then(p=>{c.value=!1,b.value=p.list,v.value=Math.ceil(p.pager.total_rows/$.value)}).catch(p=>{c.value=!1})},T=p=>{l.value=p,k()};return Z(()=>{k()}),(p,D)=>{const h=ze,e=Se,s=Le,d=Me,R=Ee,M=Oe,A=Ce,W=Ie;return t(),r("div",null,[n(h,{title:"消息"}),n(A,{class:"main-content-wrap messages-wrap",bordered:""},{default:o(()=>[n(e,{show:C.value,user:z.value,onSuccess:P},null,8,["show","user"]),c.value?(t(),r("div",Ye,[n(s,{num:$.value},null,8,["num"])])):(t(),r("div",Ke,[b.value.length===0?(t(),r("div",Xe,[n(d,{size:"large",description:"暂无数据"})])):u("",!0),(t(!0),r(G,null,E(b.value,F=>(t(),S(M,{key:F.id},{default:o(()=>[n(R,{message:F,onSendWhisper:I,onReload:k},null,8,["message"])]),_:2},1024))),128))]))]),_:1}),v.value>0?(t(),r("div",Ze,[n(W,{page:l.value,"onUpdate:page":T,"page-slot":a(i).state.collapsedRight?5:8,"page-count":v.value},null,8,["page","page-slot","page-count"])])):u("",!0)])}}});const Cs=j(xe,[["__scopeId","data-v-eb622a78"]]);export{Cs as default};