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-e4d02674.js

2 lines
7.8 KiB

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