2 lines
5.1 KiB
JavaScript
2 lines
5.1 KiB
JavaScript
import{d as Q,K as Z,l as T,i as D,Z as j,H as J,c as d,q as r,h as k,C as P,A as i,F as V,r as b,o as n,Q as y,f as a,M as W,G as u,N as X,a6 as Y,D as S,a7 as tt,a8 as ot,E as et,O as x,B as st}from"./index-C4UKuwCQ.js";/* empty css */import{R as at}from"./index-BDV2IQRF.js";import{S as nt}from"./index-DVb3VLcj.js";import{_ as lt}from"./index-x1lD9bO6.js";import{T as rt,a as it}from"./index-BKxeFVs3.js";import"./index-BAOCFoRq.js";import{f as dt,h as ct,i as ut}from"./index-DMocdcUs.js";import{F as $}from"./index-BFy-ZR_w.js";import{S as pt}from"./index-Y5pyQQ_e.js";import{I as mt}from"./index-C8Ze-KO3.js";import{I as _t}from"./index-nprHl-Vj.js";import{I as ft}from"./index-J5Fvxmxh.js";import{M as vt}from"./index-QwxSwrho.js";import"./index-Dv5Lj9Gr.js";import"./index-N39laun4.js";import"./index-CuH62uB4.js";import"./index-BMrux7Sq.js";import"./index-D_04e1GI.js";import"./resize-observer-DsiuURlg.js";import"./use-children-components-DYdC3jUY.js";import"./use-merge-state-BIwn2CEf.js";import"./keyboard-b0R5wflF.js";const gt={class:"mr-2"},ht={key:1,class:"post-list"},kt=["onClick"],yt={key:0,class:"post-cover"},Ct={class:"post-content"},It={class:"post-main"},Tt={class:"post-title"},Pt={class:"post-actions"},St={class:"post-summary"},xt={class:"post-meta"},wt={class:"post-meta-message"},Dt={key:0,class:"post-tags"},Vt={key:2,class:"post-empty"},bt={key:3,class:"loadmore"},$t=Q({__name:"index",setup(Bt){const B=Z(),C=et(),s=T({total:0,record:[]}),m=T({all:0,draft:0,normal:0}),c=D(!1),l=T({companyId:B.userInfo.id,postTitle:"",page:1,pageSize:8,status:void 0}),_=D(!1),E=t=>{const o=t.target,p=o.scrollTop+o.clientHeight>=o.scrollHeight-1;p&&!_.value?_.value=!0:!p&&_.value&&(_.value=!1)};j(_,t=>{t&&(s.record.length<s.total?(l.page=l.page+1,g()):s.record.length===s.total?x.info("没有更多了!"):x.error("加载失败,请刷新后重试!"))});const L=()=>{C.push("/settings/creator/editor")};J(()=>{M()});async function M(){c.value=!0,await g(),await dt().then(t=>{m.all=t.data.all,m.draft=t.data.draft,m.normal=t.data.normal}),c.value=!1}async function g(){await ct(l).then(t=>{l.page>1?s.record.push(...t.data.record):s.record=t.data.record,s.total=t.data.total})}const A=async()=>{l.page=1,c.value=!0,await g(),c.value=!1},F=async t=>{l.status=t,l.page=1,l.postTitle="",c.value=!0,await g(),c.value=!1},N=t=>{C.push(`/settings/creator/editor?id=${t.forumPostId}`)},R=t=>{C.push(`/forum/post-detail?postId=${t.forumPostId}`)},H=t=>{const o=vt.confirm({title:"删除提示",content:`确认删除 《${t.title}》 这篇帖子么?`,okText:"确认",hideCancel:!1,cancelText:"取消",okLoading:!1,onBeforeOk(p){o.update({okLoading:!0}),ut({forumPostId:t.forumPostId}).then(f=>{x.success(f.message);const h=s.record.findIndex(I=>I.forumPostId===t.forumPostId);h!==-1&&(s.record.splice(h,1),s.total=s.total-1),p(!0)}).catch(()=>{p(!1)}).finally(()=>{o.update({okLoading:!1})})},onCancel:()=>{console.log("用户取消了删除")}})};return(t,o)=>{const p=mt,f=it,h=rt,I=lt,O=W,w=Y,U=tt,q=ot,z=nt,G=at,K=pt;return n(),d("div",{class:"post-container",onScroll:E},[r(h,{modelValue:l.status,"onUpdate:modelValue":o[1]||(o[1]=e=>l.status=e),onChange:F,class:"sticky-tabs"},{extra:i(()=>[a("div",gt,[r(p,{placeholder:"请输入帖子标题搜索",modelValue:l.postTitle,"onUpdate:modelValue":o[0]||(o[0]=e=>l.postTitle=e),onPressEnter:A},null,8,["modelValue"])])]),default:i(()=>[(n(),k(f,{key:void 0,title:`全部 (${m.all})`},null,8,["title"])),(n(),k(f,{key:y($).NORMAL,title:`已发布 (${m.normal})`},null,8,["title"])),(n(),k(f,{key:y($).DRAFT,title:`草稿箱 (${m.draft})`},null,8,["title"]))]),_:1},8,["modelValue"]),c.value?(n(),k(I,{key:0,"in-container":!0})):s.record.length>0?(n(),d("div",ht,[(n(!0),d(V,null,b(s.record,e=>(n(),d("div",{key:e.forumPostId,class:"post-item",onClick:v=>R(e)},[e.cover?(n(),d("div",yt,[r(O,{url:e.cover},null,8,["url"])])):P("",!0),a("div",Ct,[a("div",It,[a("div",Tt,u(e.title),1),a("div",Pt,[r(U,null,{content:i(()=>[r(w,{onClick:v=>N(e)},{icon:i(()=>[r(y(_t))]),default:i(()=>[o[3]||(o[3]=S(" 编辑 "))]),_:2},1032,["onClick"]),r(w,{onClick:v=>H(e)},{icon:i(()=>[r(y(ft))]),default:i(()=>[o[4]||(o[4]=S(" 删除 "))]),_:2},1032,["onClick"])]),default:i(()=>[a("div",{class:"post-action i-ion:ios-more",onClick:o[2]||(o[2]=X(()=>{},["stop"]))})]),_:2},1024)])]),a("div",St,u(e.summary),1),a("div",xt,[a("div",wt,[a("div",null,u(e.publishTime),1),o[5]||(o[5]=a("div",{class:"post-meta-divider"},null,-1)),a("div",null,u(e.viewCount)+" 浏览",1),a("div",null,u(e.likeCount)+" 点赞",1),a("div",null,u(e.commentCount)+" 评论",1),a("div",null,u(e.favoriteCount)+" 收藏",1)]),e.tags&&e.tags.length>0?(n(),d("div",Dt,[(n(!0),d(V,null,b(e.tags,v=>(n(),d("div",{key:v,class:"post-tag"},u(v),1))),128))])):P("",!0)])])],8,kt))),128))])):(n(),d("div",Vt,[r(G,{title:"暂无文章",subtitle:"请添加属于自己的文章吧!"},{extra:i(()=>[r(z,null,{default:i(()=>[r(q,{type:"primary",onClick:L},{default:i(()=>o[6]||(o[6]=[S("开始创作")])),_:1})]),_:1})]),_:1})])),s.record.length>0&&!c.value&&s.record.length<s.total?(n(),d("div",bt,[r(K,{dot:""})])):P("",!0)],32)}}}),eo=st($t,[["__scopeId","data-v-2ee720ab"]]);export{eo as default};
|