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/Topic-Ci6XOjt-.js

2 lines
5.1 KiB

import{E as I,F as q,G as A,H as M,I as O,J as j,_ as D}from"./index-CEQM3iaT.js";import{D as J}from"./@vicons-BcP-CCNH.js";import{n as H,M as B,i as Z,B as K,P as Q,O as R,G as W,e as X,f as Y,a as x,J as ee,j as oe}from"./naive-ui-1pzJR9kY.js";import{d as P,r as _,c as $,b as C,l as te,f as c,j as p,q as n,w as a,t as w,G as L,z as k,Z as u,bq as m,C as ne,ar as se,F as ae,x as ce}from"./@vue-CT9fXtKS.js";import{_ as ie}from"./main-nav.vue_vue_type_style_index_0_lang-tx84Ctyj.js";import{u as le}from"./vuex-BtQJPySv.js";import"./vue-router-Oso6ZnuY.js";import"./axios-upsvKRUO.js";import"./moment-P60zs0je.js";/* empty css */import"./seemly-96Y8tuX4.js";import"./vueuc-rMdi6pp7.js";import"./evtd-CI_DDEu_.js";import"./@css-render-D-71Ub-V.js";import"./vooks-D483k878.js";import"./vdirs-Bxp-63WN.js";import"./@juggle-DY95s5UV.js";import"./css-render-wuhQizsj.js";import"./@emotion-WldOFDRm.js";import"./lodash-es-BI2Xm8S2.js";import"./treemate-N4GG0L_2.js";import"./async-validator-P8scd9xB.js";import"./date-fns-Db9XENWt.js";const _e={key:0,class:"tag-item"},pe={key:0,class:"tag-quote"},ue={key:1,class:"tag-quote tag-follow"},re={key:0,class:"options"},ge=P({__name:"tag-item",props:{tag:{},showAction:{type:Boolean},checkFollowing:{type:Boolean},checkPin:{type:Boolean}},setup(F){const l=_(!1),t=F,d=$(()=>t.tag.user?t.tag.user.avatar:I),r=$(()=>{let e=[];return t.tag.is_following===0?e.push({label:"关注",key:"follow"}):(t.tag.is_pin===0?e.push({label:"钉住",key:"pin"}):e.push({label:"取消钉住",key:"unpin"}),t.tag.is_top===0?e.push({label:"置顶",key:"stick"}):e.push({label:"取消置顶",key:"unstick"}),e.push({label:"取消关注",key:"unfollow"})),e}),i=e=>{switch(e){case"follow":O({topic_id:t.tag.id}).then(o=>{t.tag.is_following=1,window.$message.success("关注成功")}).catch(o=>{console.log(o)});break;case"unfollow":M({topic_id:t.tag.id}).then(o=>{t.tag.is_following=0,window.$message.success("取消关注")}).catch(o=>{console.log(o)});break;case"pin":A({topic_id:t.tag.id}).then(o=>{t.tag.is_pin=1,window.$message.success("钉住成功")}).catch(o=>{console.log(o)});break;case"unpin":A({topic_id:t.tag.id}).then(o=>{t.tag.is_pin=0,window.$message.success("取消钉住")}).catch(o=>{console.log(o)});break;case"stick":q({topic_id:t.tag.id}).then(o=>{t.tag.is_top=o.top_status,window.$message.success("置顶成功")}).catch(o=>{console.log(o)});break;case"unstick":q({topic_id:t.tag.id}).then(o=>{t.tag.is_top=o.top_status,window.$message.success("取消置顶")}).catch(o=>{console.log(o)});break}};return C(()=>{l.value=!1}),(e,o)=>{const v=te("router-link"),h=H,y=B,s=Z,f=K,b=Q,g=R;return!e.checkFollowing&&!e.checkPin||e.checkFollowing&&e.tag.is_following===1||e.checkPin&&e.tag.is_following===1&&e.tag.is_pin===1?(c(),p("div",_e,[n(g,null,{header:a(()=>[(c(),w(y,{type:"success",size:"large",round:"",key:e.tag.id},{avatar:a(()=>[n(h,{src:d.value},null,8,["src"])]),default:a(()=>[n(v,{class:"hash-link",to:{name:"home",query:{q:e.tag.tag,t:"tag"}}},{default:a(()=>[L(" #"+k(e.tag.tag),1)]),_:1},8,["to"]),e.showAction?u("",!0):(c(),p("span",pe,"("+k(e.tag.quote_num)+")",1)),e.showAction?(c(),p("span",ue,"("+k(e.tag.quote_num)+")",1)):u("",!0)]),_:1}))]),"header-extra":a(()=>[e.showAction?(c(),p("div",re,[n(b,{placement:"bottom-end",trigger:"click",size:"small",options:r.value,onSelect:i},{default:a(()=>[n(f,{type:"success",quaternary:"",circle:"",block:""},{icon:a(()=>[n(s,null,{default:a(()=>[n(m(J))]),_:1})]),_:1})]),_:1},8,["options"])])):u("",!0)]),_:1})])):u("",!0)}}}),me={key:0,class:"empty-wrap"},de=P({__name:"Topic",setup(F){const l=le(),t=_([]),d=_("hot"),r=_(!1),i=_(!1),e=_(!1),o=_(!1);ne(i,()=>{i.value||(window.$message.success("保存成功"),l.commit("refreshTopicFollow"))});const v=$({get:()=>{let s="编辑";return i.value&&(s="保存"),s},set:s=>{}}),h=()=>{r.value=!0,j({type:d.value,num:50}).then(s=>{t.value=s.topics,r.value=!1}).catch(s=>{t.value=[],console.log(s),r.value=!1})},y=s=>{d.value=s,e.value=s==="follow",o.value=s==="pin",h()};return C(()=>{h()}),(s,f)=>{const b=ie,g=X,V=B,z=Y,N=ge,S=x,U=ee,E=oe,G=W;return c(),p("div",null,[n(b,{title:"话题"}),n(G,{class:"main-content-wrap tags-wrap",bordered:""},{default:a(()=>[n(z,{type:"line",animated:"","onUpdate:value":y},se({default:a(()=>[n(g,{name:"hot",tab:"热门"}),n(g,{name:"new",tab:"最新"}),m(l).state.userLogined?(c(),w(g,{key:0,name:"follow",tab:"关注"})):u("",!0),m(l).state.userLogined?(c(),w(g,{key:1,name:"pin",tab:"钉住"})):u("",!0)]),_:2},[m(l).state.userLogined?{name:"suffix",fn:a(()=>[n(V,{checked:i.value,"onUpdate:checked":f[0]||(f[0]=T=>i.value=T),checkable:""},{default:a(()=>[L(k(v.value),1)]),_:1},8,["checked"])]),key:"0"}:void 0]),1024),n(E,{show:r.value},{default:a(()=>[n(S,null,{default:a(()=>[(c(!0),p(ae,null,ce(t.value,T=>(c(),w(N,{tag:T,showAction:m(l).state.userLogined&&i.value,checkFollowing:e.value,checkPin:o.value},null,8,["tag","showAction","checkFollowing","checkPin"]))),256))]),_:1}),t.value.length===0?(c(),p("div",me,[n(U,{size:"large",description:"暂无数据"})])):u("",!0)]),_:1},8,["show"])]),_:1})])}}}),Ie=D(de,[["__scopeId","data-v-f89944c3"]]);export{Ie as default};