import{A as e,Bt as t,C as n,D as r,H as i,J as a,K as o,O as s,Q as c,S as l,T as u,W as d,X as f,b as p,h as m,ht as h,lt as g,w as _}from"./@css-render-YsNuQTaE.js";import{r as v}from"./pinia-TbaIYBWH.js";import{G as y,P as b,W as x,c as S,ct as C,f as w,it as T,l as E,lt as D,nt as O,s as k,x as A}from"./naive-ui-DIGPL69-.js";import"./@juggle-BrKhuOcS.js";import{c as j,l as M,n as N,r as P}from"./sidebar-CIS7wt6Z.js";import{a as F}from"./@vicons-Bd7TWO2p.js";import{C as I,D as L,M as R,f as z,y as B}from"./index-D3WChr5M.js";import{t as V}from"./main-nav-BLJ4tcq0.js";var H={key:0,class:`tag-item`},U={key:0,class:`tag-quote`},W={key:1,class:`tag-quote tag-follow`},G={key:0,class:`options`},K=e({__name:`tag-item`,props:{tag:{},showAction:{type:Boolean},checkFollowing:{type:Boolean},checkPin:{type:Boolean}},setup(e){let o=g(!1),u=e,f=p(()=>u.tag.user?u.tag.user.avatar:N),m=p(()=>{let e=[];return u.tag.is_following===0?e.push({label:`关注`,key:`follow`}):(u.tag.is_pin===0?e.push({label:`钉住`,key:`pin`}):e.push({label:`取消钉住`,key:`unpin`}),u.tag.is_top===0?e.push({label:`置顶`,key:`stick`}):e.push({label:`取消置顶`,key:`unstick`}),e.push({label:`取消关注`,key:`unfollow`})),e}),v=e=>{switch(e){case`follow`:z({topic_id:u.tag.id}).then(e=>{u.tag.is_following=1,window.$message.success(`关注成功`)}).catch(e=>{console.log(e)});break;case`unfollow`:R({topic_id:u.tag.id}).then(e=>{u.tag.is_following=0,window.$message.success(`取消关注`)}).catch(e=>{console.log(e)});break;case`pin`:I({topic_id:u.tag.id}).then(e=>{u.tag.is_pin=1,window.$message.success(`钉住成功`)}).catch(e=>{console.log(e)});break;case`unpin`:I({topic_id:u.tag.id}).then(e=>{u.tag.is_pin=0,window.$message.success(`取消钉住`)}).catch(e=>{console.log(e)});break;case`stick`:L({topic_id:u.tag.id}).then(e=>{u.tag.is_top=e.top_status,window.$message.success(`置顶成功`)}).catch(e=>{console.log(e)});break;case`unstick`:L({topic_id:u.tag.id}).then(e=>{u.tag.is_top=e.top_status,window.$message.success(`取消置顶`)}).catch(e=>{console.log(e)});break;default:break}};return i(()=>{o.value=!1}),(i,o)=>{let u=a(`router-link`),p=T,g=C,b=y,S=O,w=x,E=k;return!e.checkFollowing&&!e.checkPin||e.checkFollowing&&e.tag.is_following===1||e.checkPin&&e.tag.is_following===1&&e.tag.is_pin===1?(d(),_(`div`,H,[s(E,null,{header:c(()=>[(d(),l(g,{type:`success`,size:`large`,round:``,key:e.tag.id},{avatar:c(()=>[s(p,{src:f.value},null,8,[`src`])]),default:c(()=>[s(u,{class:`hash-link`,to:{name:`home`,query:{q:e.tag.tag,t:`tag`}}},{default:c(()=>[r(` #`+t(e.tag.tag),1)]),_:1},8,[`to`]),e.showAction?n(``,!0):(d(),_(`span`,U,`(`+t(e.tag.quote_num)+`)`,1)),e.showAction?(d(),_(`span`,W,`(`+t(e.tag.quote_num)+`)`,1)):n(``,!0)]),_:1}))]),"header-extra":c(()=>[e.showAction?(d(),_(`div`,G,[s(w,{placement:`bottom-end`,trigger:`click`,size:`small`,options:m.value,onSelect:v},{default:c(()=>[s(S,{type:`success`,quaternary:``,circle:``,block:``},{icon:c(()=>[s(b,null,{default:c(()=>[s(h(F))]),_:1})]),_:1})]),_:1},8,[`options`])])):n(``,!0)]),_:1})])):n(``,!0)}}}),q={key:0,class:`empty-wrap`},J=P(e({__name:`Topic`,setup(e){let a=M(),{userLogined:y}=v(j()),x=g([]),T=g(`hot`),O=g(!1),k=g(!1),N=g(!1),P=g(!1);f(k,()=>{k.value||(window.$message.success(`保存成功`),a.doRefreshTopicFollow())});let F=p({get:()=>{let e=`编辑`;return k.value&&(e=`保存`),e},set:e=>{}}),I=()=>{O.value=!0,B({type:T.value,num:50}).then(e=>{x.value=e.topics,O.value=!1}).catch(e=>{x.value=[],console.log(e),O.value=!1})},L=e=>{T.value=e,N.value=e===`follow`,P.value=e===`pin`,I()};return i(()=>{I()}),(e,i)=>{let a=V,f=E,p=C,g=S,v=K,T=b,j=D,M=w,I=A;return d(),_(`div`,null,[s(a,{title:`话题`}),s(I,{class:`main-content-wrap tags-wrap`,bordered:``},{default:c(()=>[s(g,{type:`line`,animated:``,"onUpdate:value":L},u({default:c(()=>[s(f,{name:`hot`,tab:`热门`}),s(f,{name:`new`,tab:`最新`}),h(y)?(d(),l(f,{key:0,name:`follow`,tab:`关注`})):n(``,!0),h(y)?(d(),l(f,{key:1,name:`pin`,tab:`钉住`})):n(``,!0)]),_:2},[h(y)?{name:`suffix`,fn:c(()=>[s(p,{checked:k.value,"onUpdate:checked":i[0]||=e=>k.value=e,checkable:``},{default:c(()=>[r(t(F.value),1)]),_:1},8,[`checked`])]),key:`0`}:void 0]),1024),s(M,{show:O.value},{default:c(()=>[s(T,null,{default:c(()=>[(d(!0),_(m,null,o(x.value,e=>(d(),l(v,{tag:e,showAction:h(y)&&k.value,checkFollowing:N.value,checkPin:P.value},null,8,[`tag`,`showAction`,`checkFollowing`,`checkPin`]))),256))]),_:1}),x.value.length===0?(d(),_(`div`,q,[s(j,{size:`large`,description:`暂无数据`})])):n(``,!0)]),_:1},8,[`show`])]),_:1})])}}}),[[`__scopeId`,`data-v-5410fcc5`]]);export{J as default};