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-31e222da.js

2 lines
7.7 KiB

import{d as V,c as N,r as L,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 Y,h as T,u as E,F as G,H as v,b as K}from"./@vue-a481fc63.js";import{u as J}from"./vuex-44de225f.js";import{u as X,b as Z}from"./vue-router-e5a2430e.js";import{H as x,N as ee,O as se,P as ne,_ as D,Q as te}from"./index-537a241d.js";import{N as U,k as ae,O as oe,Q as re,R as Q,U as ie,r as le}from"./@vicons-4ed09704.js";import{j as d,o as ue,M as _e,l as pe,e as ce,P as de,T as me,O as ge,U as ve,G as fe,R as ye,J as ke,H as he}from"./naive-ui-defd0b2d.js";import{_ as we}from"./whisper-7c8226c3.js";import{_ as $e}from"./main-nav.vue_vue_type_style_index_0_lang-832ff0ed.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 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"},Oe={class:"timestamp"},Re={class:"timestamp-txt"},Ne={key:0,class:"brief-content"},qe={key:1,class:"whisper-content-wrap"},Fe={key:2,class:"requesting-friend-wrap"},Pe={key:2,class:"status-info"},Ae={key:3,class:"status-info"},We="https://assets.paopao.info/public/avatar/default/admin.png",je=V({__name:"message-item",props:{message:{}},emits:["send-whisper"],setup(q,{emit:y}){const p=q,c=X(),l=J(),k=e=>()=>T(d,null,{default:()=>T(e)}),h=N(()=>[{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=N(()=>p.message.type!==4||p.message.sender_user_id!==l.state.userInfo.id),M=N(()=>p.message.type==4&&p.message.receiver_user_id==l.state.userInfo.id),S=N(()=>p.message.type==4&&p.message.sender_user_id==l.state.userInfo.id),F=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),ee({user_id:e.sender_user_id}).then(n=>{e.reply_id=2,window.$message.success("已同意添加好友")}).catch(n=>{console.log(n)})},P=e=>{u(e),se({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&&ne({id:e.id}).then(n=>{e.is_read=1}).catch(n=>{console.log(n)})};return(e,n)=>{const $=ue,O=L("router-link"),b=_e,A=pe,W=ce,j=de,B=me,R=ge;return t(),r("div",{class:Y(["message-item",{unread:g.value&&e.message.is_read===0}]),onClick:n[5]||(n[5]=H=>u(e.message))},[s(R,{"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:We},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(O,{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(O,{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(U)},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(U)},null,8,["component"])]),default:a(()=>[_(" 已接收 ")]),_:1})):i("",!0)])]),"header-extra":a(()=>[f("span",Oe,[g.value&&e.message.is_read===0?(t(),I(A,{key:0,dot:"",processing:""})):i("",!0),f("span",Re,m(o(x)(e.message.created_on)),1),s(j,{placement:"bottom-end",trigger:"click",size:"small",options:h.value,onSelect:w},{default:a(()=>[s(W,{quaternary:"",circle:""},{icon:a(()=>[s(o(d),null,{default:a(()=>[s(o(ae))]),_:1})]),_:1})]),_:1},8,["options"])])]),description:a(()=>[s(B,{"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",Ne,[_(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(H=>F(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",qe,m(e.message.content),1)):i("",!0),e.message.type===5?(t(),r("div",Fe,[_(m(e.message.content)+" ",1),e.message.reply_id===1?(t(),r("span",{key:0,onClick:n[3]||(n[3]=C(H=>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(H=>P(e.message),["stop"])),class:"hash-link view-link"},[s(o(d),null,{default:a(()=>[s(o(Q))]),_:1}),_(" 拒绝 ")])):i("",!0),e.message.reply_id===2?(t(),r("span",Pe,[s(o(d),null,{default:a(()=>[s(o(ie))]),_:1}),_(" 已同意 ")])):i("",!0),e.message.reply_id===3?(t(),r("span",Ae,[s(o(d),null,{default:a(()=>[s(o(Q))]),_:1}),_(" 已拒绝 ")])):i("",!0)])):i("",!0)]),_:1},8,["type"])]),_:1})],2)}}});const Be=D(je,[["__scopeId","data-v-2e510758"]]),He={class:"content"},Ve=V({__name:"message-skeleton",props:{num:{default:1}},setup(q){return(y,p)=>{const c=ve;return t(!0),r(G,null,E(new Array(y.num),l=>(t(),r("div",{class:"skeleton-item",key:l},[f("div",He,[s(c,{text:"",repeat:2}),s(c,{text:"",style:{width:"60%"}})])]))),128)}}});const De=D(Ve,[["__scopeId","data-v-01d2e871"]]),Te={key:0,class:"skeleton-wrap"},Ue={key:1},Qe={key:0,class:"empty-wrap"},Ee={key:0,class:"pagination-wrap"},Ge=V({__name:"Messages",setup(q){const y=Z(),p=J(),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},F=()=>{g.value=!1},z=()=>{c.value=!0,te({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})},P=u=>{l.value=u,z()};return K(()=>{z()}),(u,e)=>{const n=$e,$=we,O=De,b=ke,A=Be,W=he,j=fe,B=ye;return t(),r("div",null,[s(n,{title:"消息"}),s(j,{class:"main-content-wrap messages-wrap",bordered:""},{default:a(()=>[s($,{show:g.value,user:M.value,onSuccess:F},null,8,["show","user"]),c.value?(t(),r("div",Te,[s(O,{num:k.value},null,8,["num"])])):(t(),r("div",Ue,[w.value.length===0?(t(),r("div",Qe,[s(b,{size:"large",description:"暂无数据"})])):i("",!0),(t(!0),r(G,null,E(w.value,R=>(t(),I(W,{key:R.id},{default:a(()=>[s(A,{message:R,onSendWhisper:S},null,8,["message"])]),_:2},1024))),128))]))]),_:1}),h.value>0?(t(),r("div",Ee,[s(B,{page:l.value,"onUpdate:page":P,"page-slot":o(p).state.collapsedRight?5:8,"page-count":h.value},null,8,["page","page-slot","page-count"])])):i("",!0)])}}});const fs=D(Ge,[["__scopeId","data-v-b40dcbaf"]]);export{fs as default};