Files
CoreInject/frontend/dist/assets/_YA5wcFS.js
2025-11-14 04:00:32 +08:00

228 lines
52 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{d as e,f as l,k as a,l as t,g as s,F as i,z as n,b as r,m as o,x as u,u as d,e as c,r as v,C as m,D as p,B as y,w as h,c as g,R as f,i as k,j as w,t as b,o as I,Q as R,J as C,H as N,O as U,S}from"./CD7TqNEc.js"
import{_ as F,a as A,c as E,A as x,b as L,d as T,e as z,g as D,u as P,h as M,M as $,T as B}from"./DTEPVF5R.js"
import{R as _}from"./LYVCVZrq.js"
import{U as j}from"./CTwXCDf2.js"
import{I as q}from"./CugD9gGX.js"
import{P as O}from"./Cq_Y6BRc.js"
import{P as H}from"./BvcmZ1eR.js"
import{I as V}from"./5jZb0Mvm.js"
import{a as J}from"./DHQqjBVd.js"
import{g as Q,a as G,b as K,f as W,E as X,c as Y,d as Z,u as ee,e as le}from"./D0Zic1w3.js"
import{u as ae}from"./Tr3ZfNrL.js"
import{u as te}from"./CJ-6BEJ8.js"
import{g as se}from"./6K6b4Qy_.js"
const ie={key:0,class:"post-attachments"},ne={key:0,class:"post-images"},re={key:1,class:"post-files"},oe=["onClick"],ue={class:"attachment-name"},de={class:"attachment-size"},ce=A(e({__name:"PostAttachmentList",props:{attachments:{},type:{default:"post"}},emits:["imageClick","fileClick"],setup(e,{emit:v}){const m=e,p=v,y=l(()=>Q(m.attachments)),h=l(()=>G(m.attachments)),g=l(()=>K(m.attachments)),f=e=>{p("imageClick",e)}
return(l,v)=>e.attachments&&e.attachments.length>0?(c(),a("div",ie,[y.value.length>0?(c(),a("div",ne,[s(V,{"image-ids":g.value,"show-index":!1,columns:4,"max-width":120,onImageClick:f},null,8,["image-ids"])])):t("",!0),h.value.length>0?(c(),a("div",re,[(c(!0),a(i,null,n(h.value,e=>(c(),a("div",{key:e.id,class:r(["attachment-item",{clickable:!0}]),onClick:l=>(e=>{p("fileClick",e)})(e)},[s(F,{icon:"mdi:file",class:"attachment-icon"}),o("span",ue,u(e.name),1),o("span",de,u(d(J)(e.size)),1),s(F,{icon:"mdi:download",class:"attachment-action-icon",title:"下载文件"})],8,oe))),128))])):t("",!0)])):t("",!0)}}),[["__scopeId","data-v-7d2f6224"]])
function ve(e){const a=E(),t=(null==e?void 0:e.maxImageCount)??3,s=(null==e?void 0:e.maxFileCount)??3,i=(null==e?void 0:e.maxImageSize)??10485760,n=(null==e?void 0:e.maxFileSize)??20971520,r=v([]),o=v([]),u=v(null),d=v(null),c=l(()=>r.value.length>0||o.value.length>0)
return{selectedImages:r,selectedFiles:o,imageInput:u,fileInput:d,handleImageSelect:e=>{const l=e.target
Array.from(l.files||[]).forEach(e=>{if(r.value.length>=t)return void a.error(`图片数量不能超过${t}`)
if(e.size>i){const l=Math.round(i/1048576)
return r.value.push({file:e,preview:"",error:`单张图片大小不能超过${l}MB`}),void a.error(`单张图片大小不能超过${l}MB`)}const l=new FileReader
l.onload=l=>{var a
const t=r.value.findIndex(l=>l.file===e)
t>=0&&(r.value[t].preview=null==(a=l.target)?void 0:a.result)},l.readAsDataURL(e),r.value.push({file:e,preview:""})}),l.value=""},handleFileSelect:e=>{const l=e.target
Array.from(l.files||[]).forEach(e=>{if(o.value.length>=s)a.error(`文件数量不能超过${s}`)
else{if(e.size>n){const l=Math.round(n/1048576)
return o.value.push({file:e,error:`单个文件大小不能超过${l}MB`}),void a.error(`单个文件大小不能超过${l}MB`)}o.value.push({file:e})}}),l.value=""},removeImage:e=>{r.value.splice(e,1)},removeFile:e=>{o.value.splice(e,1)},triggerImageUpload:()=>{var e
null==(e=u.value)||e.click()},triggerFileUpload:()=>{var e
null==(e=d.value)||e.click()},uploadAttachments:async()=>{var e,l,a,t
const s=[]
for(let i=0;i<r.value.length;i++){const a=r.value[i],t=await x.uploadImageAttachment(a.file)
if(!t.success||!(null==(e=t.data)?void 0:e.attachmentId))throw new Error(t.message||(null==(l=t.data)?void 0:l.message)||"图片上传失败")
s.push(t.data.attachmentId)}for(let i=0;i<o.value.length;i++){const e=o.value[i],l=await x.uploadFileAttachment(e.file)
if(!l.success||!(null==(a=l.data)?void 0:a.attachmentId))throw new Error(l.message||(null==(t=l.data)?void 0:t.message)||"文件上传失败")
s.push(l.data.attachmentId)}return s},clearAttachments:()=>{r.value=[],o.value=[]},validateAttachments:()=>{if(r.value.length>t)return a.error(`图片数量不能超过${t}`),!1
if(o.value.length>s)return a.error(`文件数量不能超过${s}`),!1
for(const e of r.value)if(e.file.size>i){const e=Math.round(i/1048576)
return a.error(`单张图片大小不能超过${e}MB`),!1}for(const e of o.value)if(e.file.size>n){const e=Math.round(n/1048576)
return a.error(`单个文件大小不能超过${e}MB`),!1}return!0},canSubmit:c}}const me={class:"reply-form"},pe={class:"form-avatar"},ye={class:"form-content"},he=["placeholder","rows","maxlength"],ge={class:"form-actions"},fe={class:"upload-area"},ke=["disabled","title"],we=["disabled","title"],be={key:0,class:"limit-hint"},Ie={key:1,class:"upload-count"},Re=["disabled"],Ce={key:0,class:"attachment-preview-list"},Ne=["src"],Ue=["onClick"],Se={key:0,class:"attachment-error"},Fe={class:"file-name"},Ae={class:"file-size"},Ee=["onClick"],xe={key:0,class:"attachment-error"},Le=A(e({__name:"ReplyForm",props:{userId:{},userName:{},mode:{default:"main"},visible:{type:Boolean,default:!0},replyToUserName:{},showCancel:{type:Boolean,default:!1},showLimitHint:{type:Boolean,default:!0},maxImageCount:{},maxFileCount:{},maxImageSize:{},maxFileSize:{},isSubmitting:{type:Boolean,default:!1}},emits:["submit","cancel"],setup(e,{expose:h,emit:g}){const f=e,k=g,w=v(""),b=l(()=>"nested"===f.mode?3:f.maxImageCount??10),I=l(()=>"nested"===f.mode?3:f.maxFileCount??5),R=l(()=>"nested"===f.mode?10485760:f.maxImageSize??10485760),C=l(()=>"nested"===f.mode?20971520:f.maxFileSize??20971520),N=ve({maxImageCount:b.value,maxFileCount:I.value,maxImageSize:R.value,maxFileSize:C.value}),{selectedImages:U,selectedFiles:S,imageInput:A,fileInput:E,handleImageSelect:x,handleFileSelect:T,removeImage:z,removeFile:D,triggerImageUpload:P,triggerFileUpload:M,canSubmit:$}=N,B=l(()=>w.value.trim().length>0||$.value),_=()=>{B.value&&!f.isSubmitting&&k("submit",w.value,U.value,S.value)},j=()=>{w.value="",N.clearAttachments(),k("cancel")}
return h({content:w,selectedImages:U,selectedFiles:S,clear:()=>{w.value="",N.clearAttachments()}}),(l,v)=>"main"===e.mode||e.visible?(c(),a("div",{key:0,class:r(["reply-form-container",{"nested-mode":"nested"===e.mode}])},[o("div",me,[o("div",pe,[s(L,{userId:e.userId,"user-name":e.userName||"我",width:"36px",height:"36px"},null,8,["userId","user-name"])]),o("div",ye,[m(o("textarea",{"onUpdate:modelValue":v[0]||(v[0]=e=>w.value=e),class:"reply-textarea",placeholder:"nested"===e.mode&&e.replyToUserName?`回复 ${e.replyToUserName}:`:"写下你的回复...",rows:"nested"===e.mode?2:3,maxlength:"nested"===e.mode?500:1e3},null,8,he),[[p,w.value]]),o("div",ge,[o("div",fe,[o("input",{ref_key:"imageInput",ref:A,type:"file",accept:"image/*",multiple:"",onChange:v[1]||(v[1]=(...e)=>d(x)&&d(x)(...e)),style:{display:"none"}},null,544),o("input",{ref_key:"fileInput",ref:E,type:"file",multiple:"",onChange:v[2]||(v[2]=(...e)=>d(T)&&d(T)(...e)),style:{display:"none"}},null,544),o("button",{class:r(["upload-btn",{small:"nested"===e.mode}]),onClick:v[3]||(v[3]=(...e)=>d(P)&&d(P)(...e)),disabled:d(U).length>=b.value,title:"main"===e.mode?`添加图片(最多${b.value}张,单张不超过${Math.round(R.value/1048576)}MB`:void 0},[s(F,{icon:"mdi:image-outline",class:"btn-icon"}),"main"===e.mode?(c(),a(i,{key:0},[y(" 图片 ("+u(d(U).length)+"/"+u(b.value)+") ",1)],64)):(c(),a(i,{key:1},[y(" 图片 ")],64))],10,ke),o("button",{class:r(["upload-btn",{small:"nested"===e.mode}]),onClick:v[4]||(v[4]=(...e)=>d(M)&&d(M)(...e)),disabled:d(S).length>=I.value,title:"main"===e.mode?`添加文件(最多${I.value}个,单个不超过${Math.round(C.value/1048576)}MB`:void 0},[s(F,{icon:"mdi:file-outline",class:"btn-icon"}),"main"===e.mode?(c(),a(i,{key:0},[y(" 文件 ("+u(d(S).length)+"/"+u(I.value)+") ",1)],64)):(c(),a(i,{key:1},[y(" 文件 ")],64))],10,we),e.showLimitHint&&"main"===e.mode?(c(),a("div",be,[s(F,{icon:"mdi:information-outline",class:"hint-icon"}),o("span",null,"当前讨论区限制:图片最多 "+u(b.value)+" 张(单张不超过 "+u(Math.round(R.value/1048576))+" MB文件最多 "+u(I.value)+" 个(单个不超过 "+u(Math.round(C.value/1048576))+" MB",1)])):t("",!0),"main"===e.mode&&(d(U).length>0||d(S).length>0)?(c(),a("span",Ie,u(d(U).length+d(S).length)+" 个附件 ",1)):t("",!0)]),o("div",{class:r(["form-actions-right",{"nested-actions":"nested"===e.mode}])},[e.showCancel&&"nested"===e.mode?(c(),a("button",{key:0,class:"cancel-btn",onClick:j}," 取消 ")):t("",!0),o("button",{class:r(["submit-reply-btn",{small:"nested"===e.mode}]),onClick:_,disabled:!B.value||e.isSubmitting},[s(F,{icon:e.isSubmitting?"mdi:loading":"mdi:send",class:r(["btn-icon",{spinning:e.isSubmitting}])},null,8,["icon","class"]),y(" "+u(e.isSubmitting?"nested"===e.mode?"发送中...":"发表中...":"nested"===e.mode?"发送":"发表回复"),1)],10,Re)],2)]),d(U).length>0||d(S).length>0?(c(),a("div",Ce,[(c(!0),a(i,null,n(d(U),(e,l)=>(c(),a("div",{key:`img-${l}`,class:"attachment-preview-item"},[o("img",{src:e.preview,alt:"预览图"},null,8,Ne),o("button",{class:"remove-attachment-btn",onClick:e=>d(z)(l)},[s(F,{icon:"mdi:close"})],8,Ue),e.error?(c(),a("div",Se,u(e.error),1)):t("",!0)]))),128)),(c(!0),a(i,null,n(d(S),(e,l)=>(c(),a("div",{key:`file-${l}`,class:"attachment-preview-item file"},[s(F,{icon:"mdi:file",class:"file-icon"}),o("span",Fe,u(e.file.name),1),o("span",Ae,u(d(J)(e.file.size)),1),o("button",{class:"remove-attachment-btn",onClick:e=>d(D)(l)},[s(F,{icon:"mdi:close"})],8,Ee),e.error?(c(),a("div",xe,u(e.error),1)):t("",!0)]))),128))])):t("",!0)])])],2)):t("",!0)}}),[["__scopeId","data-v-bb409454"]]),Te={class:"reply-avatar"},ze={class:"reply-content-wrapper"},De={class:"reply-header"},Pe={class:"reply-author clickable"},Me={key:1,class:"reply-to"},$e={class:"reply-time"},Be={class:"reply-content"},_e={key:0,class:"reply-edit-form"},je=["value","rows"],qe={key:1,class:"edit-new-attachments"},Oe=["src"],He=["onClick"],Ve=["onClick"],Je={class:"edit-attachment-actions"},Qe={class:"reply-actions"},Ge=["disabled"],Ke=["disabled"],We={key:0,class:"nested-replies"},Xe=A(e({__name:"PostReplyItem",props:{reply:{},isAuthor:{type:Boolean},isAdmin:{type:Boolean},userId:{},userName:{},isNew:{type:Boolean,default:!1},isEditing:{type:Boolean,default:!1},editingContent:{default:""},editingAttachments:{default:()=>[]},editingNewImages:{default:()=>[]},editingNewFiles:{default:()=>[]},showNestedForm:{type:Boolean,default:!1},replyingToNestedReplyId:{},nestedReplyToUserName:{default:""},isSubmittingNestedReply:{type:Boolean,default:!1},editingNestedReplyId:{default:null},editingNestedReplyContent:{default:""},editingNestedReplyAttachments:{default:()=>[]},editingNestedReplyNewAttachments:{default:()=>[]},editingNestedReplyNewFiles:{default:()=>[]},likeLoading:{type:[Boolean,String,null],default:!1},size:{default:"medium"},showNestedReplies:{type:Boolean,default:!0}},emits:["edit","save","cancel","delete","report","reply","like","dislike","nestedSubmit","nestedCancel","nestedEdit","nestedSave","nestedEditCancel","nestedDelete","nestedReport","nestedReplyClick","nestedLike","nestedDislike","authorHover","authorLeave","imageClick","fileClick","nestedImageClick","removeAttachment","removeNewImage","removeNewFile","editImageSelect","editFileSelect","nestedRemoveAttachment","nestedRemoveNewImage","nestedRemoveNewFile","nestedEditImageSelect","nestedEditFileSelect"],setup(e,{emit:l}){const m=e,p=l,{isUserOnline:I}=ae(),R=v(null),C=v(null),N=W,U=v(m.editingContent||"")
h(()=>m.editingContent,e=>{U.value=e||""})
const S=e=>{p("authorHover",e,m.reply.replyUser.id,m.reply.replyUser.nickName||m.reply.replyUser.username,m.reply.replyUser.username||"",m.reply.replyUser.avatar)},A=e=>{m.reply.replyToUser&&p("authorHover",e,m.reply.replyToUser.id,m.reply.replyToUser.nickName||m.reply.replyToUser.username,m.reply.replyToUser.username||"",m.reply.replyToUser.avatar)},E=()=>{p("authorLeave")},x=e=>{p("imageClick",e)},T=e=>{if(m.reply.attachments){const l=m.reply.attachments.filter(e=>"image"===e.type).findIndex(l=>l.id===e)
l>=0&&p("imageClick",l)}},z=e=>{p("fileClick",e)},D=()=>{p("edit")},P=()=>{p("save")},M=()=>{p("cancel")},$=()=>{p("delete")},B=()=>{p("report")},_=()=>{p("reply")},j=(e,l,a)=>{p("nestedSubmit",e,l,a)},q=()=>{p("nestedCancel")},O=()=>{p("nestedEditCancel")},H=()=>{p("like")},V=()=>{p("dislike")}
return(l,v)=>(c(),g(f("small"===e.size?"div":k),{name:"small"===e.size?void 0:"reply-fade",appear:"small"!==e.size},{default:w(()=>[o("div",{class:r(["reply-item",{"reply-new":e.isNew&&"medium"===e.size,"reply-small":"small"===e.size,"reply-medium":"medium"===e.size}])},[o("div",Te,[s(L,{"avatar-id":e.reply.replyUser.avatar,"user-name":e.reply.replyUser.nickName||e.reply.replyUser.username,userId:e.reply.replyUser.id,size:e.size},null,8,["avatar-id","user-name","userId","size"]),o("div",{class:r(["online-indicator",{online:d(I)(e.reply.replyUser.id),offline:!1===d(I)(e.reply.replyUser.id)}])},null,2)]),o("div",ze,[o("div",De,[o("div",{class:"author-wrapper",onMouseenter:b(S,["stop"]),onMouseleave:b(E,["stop"])},[o("span",Pe,u(e.reply.replyUser.nickName||e.reply.replyUser.username),1),"admin"===e.reply.replyUser.role||"qiuchenly"===e.reply.replyUser.role?(c(),a("span",{key:0,class:r(["role-tag",{"role-admin":"admin"===e.reply.replyUser.role,"role-qiuchenly":"qiuchenly"===e.reply.replyUser.role}])},u("admin"===e.reply.replyUser.role?"管理员":"qiuchenly"),3)):t("",!0),e.reply.replyToUser?(c(),a("span",Me,[y(u("small"===e.size?"回复":"回复了")+" ",1),o("span",{class:"reply-to-name clickable",onMouseenter:b(A,["stop"]),onMouseleave:b(E,["stop"]),onClick:v[0]||(v[0]=b(l=>"small"===e.size?void p("reply"):void 0,["stop"]))}," @"+u(e.reply.replyToUser.nickName||e.reply.replyToUser.username),33)])):t("",!0)],32),o("span",$e,u(d(N)(e.reply.date)),1)]),o("div",Be,[e.isEditing?(c(),a("div",_e,[o("textarea",{value:U.value,onInput:v[1]||(v[1]=e=>U.value=e.target.value),class:"reply-textarea",rows:"small"===e.size?3:4,maxlength:"5000"},null,40,je),e.editingAttachments.length>0?(c(),g(X,{key:0,attachments:e.editingAttachments,onRemove:v[2]||(v[2]=e=>p("removeAttachment",e)),onImageClick:T},null,8,["attachments"])):t("",!0),e.editingNewImages.length>0||e.editingNewFiles.length>0?(c(),a("div",qe,[(c(!0),a(i,null,n(e.editingNewImages,(e,l)=>(c(),a("div",{key:`img-${l}`,class:"edit-attachment-preview"},[e.preview?(c(),a("img",{key:0,src:e.preview,alt:"预览"},null,8,Oe)):t("",!0),o("button",{class:"remove-attachment-btn",onClick:e=>p("removeNewImage",l)},[s(F,{icon:"mdi:close"})],8,He)]))),128)),(c(!0),a(i,null,n(e.editingNewFiles,(e,l)=>(c(),a("div",{key:`file-${l}`,class:"edit-attachment-preview file"},[s(F,{icon:"mdi:file"}),o("span",null,u(e.file.name),1),o("button",{class:"remove-attachment-btn",onClick:e=>p("removeNewFile",l)},[s(F,{icon:"mdi:close"})],8,Ve)]))),128))])):t("",!0),o("div",Je,[o("input",{ref_key:"editImageInput",ref:R,type:"file",accept:"image/*",multiple:"",onChange:v[3]||(v[3]=e=>p("editImageSelect",e)),style:{display:"none"}},null,544),o("input",{ref_key:"editFileInput",ref:C,type:"file",multiple:"",onChange:v[4]||(v[4]=e=>p("editFileSelect",e)),style:{display:"none"}},null,544),o("button",{class:"upload-btn small",onClick:v[5]||(v[5]=e=>{var l
return null==(l=R.value)?void 0:l.click()})},[s(F,{icon:"mdi:image-outline"}),v[12]||(v[12]=y(" 添加图片 ",-1))]),o("button",{class:"upload-btn small",onClick:v[6]||(v[6]=e=>{var l
return null==(l=C.value)?void 0:l.click()})},[s(F,{icon:"mdi:file-outline"}),v[13]||(v[13]=y(" 添加文件 ",-1))])]),o("div",{class:"edit-reply-actions"},[o("button",{class:"cancel-btn",onClick:M},"取消"),o("button",{class:"submit-reply-btn small",onClick:P},"保存")])])):(c(),a(i,{key:1},[o("p",null,u(e.reply.content),1),e.reply.attachments&&e.reply.attachments.length>0?(c(),g(ce,{key:0,attachments:e.reply.attachments,type:"small"===e.size?"nested":"reply",onImageClick:x,onFileClick:z},null,8,["attachments","type"])):t("",!0)],64))]),o("div",Qe,[o("button",{class:r(["action-btn small",{active:"liked"===e.reply.userLikeStatus}]),onClick:H,disabled:!0===e.likeLoading||e.likeLoading===e.reply.id},[s(F,{icon:"liked"===e.reply.userLikeStatus?"mdi:thumb-up":"mdi:thumb-up-outline",class:"action-icon"},null,8,["icon"]),o("span",null,u(e.reply.likeCount||0),1)],10,Ge),o("button",{class:r(["action-btn small",{active:"disliked"===e.reply.userLikeStatus}]),onClick:V,disabled:!0===e.likeLoading||e.likeLoading===e.reply.id},[s(F,{icon:"disliked"===e.reply.userLikeStatus?"mdi:thumb-down":"mdi:thumb-down-outline",class:"action-icon"},null,8,["icon"]),o("span",null,u(e.reply.dislikeCount||0),1)],10,Ke),o("button",{class:"action-btn small",onClick:_},[s(F,{icon:"mdi:reply-outline",class:"action-icon"}),v[14]||(v[14]=o("span",null,"回复",-1))]),e.isAuthor||e.isAdmin?(c(),a("button",{key:0,class:"action-btn small edit-btn",onClick:D},[s(F,{icon:"mdi:pencil",class:"action-icon"}),v[15]||(v[15]=o("span",null,"编辑",-1))])):t("",!0),e.isAuthor||e.isAdmin?(c(),a("button",{key:1,class:"action-btn small delete-btn",onClick:$},[s(F,{icon:"mdi:delete-outline",class:"action-icon"}),v[16]||(v[16]=o("span",null,"删除",-1))])):t("",!0),o("button",{class:"action-btn small report-btn",onClick:B},[s(F,{icon:"mdi:flag-outline",class:"action-icon"}),v[17]||(v[17]=o("span",null,"举报",-1))])]),e.showNestedReplies&&e.reply.nestedReplies&&e.reply.nestedReplies.length>0?(c(),a("div",We,[(c(!0),a(i,null,n(e.reply.nestedReplies,l=>(c(),a(i,{key:l.id},[s(Xe,{reply:l,size:"small","is-author":l.replyUser&&("object"==typeof l.replyUser?l.replyUser.id:l.replyUser)===e.userId,"is-admin":e.isAdmin,"is-editing":e.editingNestedReplyId===l.id,"editing-content":e.editingNestedReplyContent,"editing-attachments":e.editingNestedReplyAttachments,"editing-new-images":e.editingNestedReplyNewAttachments,"editing-new-files":e.editingNestedReplyNewFiles,"like-loading":"string"==typeof e.likeLoading?e.likeLoading===l.id:e.likeLoading,"show-nested-replies":!1,onEdit:a=>((e,l)=>{p("nestedEdit",e,l)})(e.reply.id,l),onSave:e=>{return a=l.id,void p("nestedSave",a)
var a},onCancel:O,onDelete:a=>{return t=e.reply.id,s=l.id,void p("nestedDelete",t,s)
var t,s},onReport:a=>{return t=e.reply.id,s=l.id,void p("nestedReport",t,s)
var t,s},onReply:a=>{return t=e.reply.id,s=l.replyUser.id,i=l.replyUser.nickName||l.replyUser.username,n=l.id,void p("nestedReplyClick",t,s,i,n)
var t,s,i,n},onLike:a=>p("nestedLike",e.reply.id,l.id),onDislike:a=>p("nestedDislike",e.reply.id,l.id),onAuthorHover:S,onAuthorLeave:E,onImageClick:e=>p("nestedImageClick",l,e),onFileClick:z,onRemoveAttachment:v[7]||(v[7]=e=>p("nestedRemoveAttachment",e)),onRemoveNewImage:v[8]||(v[8]=e=>p("nestedRemoveNewImage",e)),onRemoveNewFile:v[9]||(v[9]=e=>p("nestedRemoveNewFile",e)),onEditImageSelect:v[10]||(v[10]=e=>p("nestedEditImageSelect",e)),onEditFileSelect:v[11]||(v[11]=e=>p("nestedEditFileSelect",e))},null,8,["reply","is-author","is-admin","is-editing","editing-content","editing-attachments","editing-new-images","editing-new-files","like-loading","onEdit","onSave","onDelete","onReport","onReply","onLike","onDislike","onImageClick"]),e.showNestedForm&&e.replyingToNestedReplyId===l.id?(c(),g(Le,{key:0,mode:"nested",visible:!0,"reply-to-user-name":e.nestedReplyToUserName,"user-id":e.userId,"user-name":e.userName,"show-cancel":!0,"is-submitting":e.isSubmittingNestedReply,onSubmit:j,onCancel:q},null,8,["reply-to-user-name","user-id","user-name","is-submitting"])):t("",!0)],64))),128))])):t("",!0),e.showNestedReplies&&e.showNestedForm&&!e.replyingToNestedReplyId?(c(),g(Le,{key:1,mode:"nested",visible:e.showNestedForm,"reply-to-user-name":e.nestedReplyToUserName,"user-id":e.userId,"user-name":e.userName,"show-cancel":!0,"is-submitting":e.isSubmittingNestedReply,onSubmit:j,onCancel:q},null,8,["visible","reply-to-user-name","user-id","user-name","is-submitting"])):t("",!0)])],2)]),_:1},8,["name","appear"]))}}),[["__scopeId","data-v-51b4d4e6"]]),Ye=e=>"string"!=typeof e||"user"!==e&&"admin"!==e&&"qiuchenly"!==e?{0:"user",1:"admin",2:"qiuchenly"}["number"==typeof e?e:parseInt(String(e||0))]||"user":e,Ze=e=>"string"!=typeof e||"user"!==e&&"admin"!==e&&"qiuchenly"!==e?{0:"user",1:"admin",2:"qiuchenly"}["number"==typeof e?e:parseInt(String(e||0))]||"user":e,el=e=>{e.replyUser&&void 0!==e.replyUser.role&&(e.replyUser.role=Ze(e.replyUser.role)),e.replyToUser&&void 0!==e.replyToUser.role&&(e.replyToUser.role=Ze(e.replyToUser.role)),e.nestedReplies&&Array.isArray(e.nestedReplies)&&e.nestedReplies.forEach(e=>{e.replyUser&&void 0!==e.replyUser.role&&(e.replyUser.role=Ze(e.replyUser.role)),e.replyToUser&&void 0!==e.replyToUser.role&&(e.replyToUser.role=Ze(e.replyToUser.role))})}
function ll(e,l,a){const t=E(),s=T()
return{handleLike:async()=>{var i,n
if(!a.value||!e.value||!l.value)return
const r="liked"===a.value.userLikeStatus?"cancel":"like"
s.show("cancel"===r?"取消点赞中...":"点赞中...")
try{const s=await x.likeForumReply(e.value,l.value,a.value.id,r)
s.success&&a.value?(a.value.userLikeStatus=s.userLikeStatus,a.value.likeCount=s.likeCount,a.value.dislikeCount=s.dislikeCount,"cancel"===r?t.success("已取消点赞"):t.success("点赞成功")):t.error("点赞失败")}catch(o){t.error((null==(n=null==(i=o.response)?void 0:i.data)?void 0:n.message)||o.message||"点赞失败")}finally{s.hide()}},handleDislike:async()=>{var i,n
if(!a.value||!e.value||!l.value)return
const r="disliked"===a.value.userLikeStatus?"cancel":"dislike"
s.show("cancel"===r?"取消点踩中...":"点踩中...")
try{const s=await x.likeForumReply(e.value,l.value,a.value.id,r)
s.success&&a.value?(a.value.userLikeStatus=s.userLikeStatus,a.value.likeCount=s.likeCount,a.value.dislikeCount=s.dislikeCount,"cancel"===r?t.success("已取消点踩"):t.success("点踩成功")):t.error("点踩失败")}catch(o){t.error((null==(n=null==(i=o.response)?void 0:i.data)?void 0:n.message)||o.message||"点踩失败")}finally{s.hide()}}}}const al={class:"post-detail-wrapper"},tl={class:"post-detail-page"},sl={class:"page-container"},il={class:"page-header"},nl={class:"header-buttons"},rl={key:0,class:"loading"},ol={key:1,class:"error"},ul={key:2,class:"post-detail-content"},dl={key:0,class:"forum-breadcrumb"},cl={class:"forum-icon-wrapper"},vl={class:"forum-icon"},ml=["src","alt"],pl=["src","alt"],yl={class:"forum-name"},hl={class:"post-breadcrumb-title"},gl={class:"post-main"},fl={class:"post-header"},kl={class:"post-title"},wl={class:"post-meta"},bl={class:"author-avatar"},Il={class:"post-author clickable"},Rl={class:"post-time"},Cl={class:"post-content"},Nl={class:"post-actions"},Ul=["disabled"],Sl=["disabled"],Fl={class:"replies-section"},Al={class:"replies-header"},El={key:0,class:"replies-list"},xl={key:2,class:"empty-replies"},Ll=A(e({__name:"PostDetail",setup(e){const p=C(),y=N(),f=E(),k=T(),w=z(),{user:A}=P(),{isAdmin:V}=M(),{isUserOnline:J,queryUsersOnlineStatus:Q}=ae(),G=v(null),K=v(null),X=v(!0),ie=v(""),ne=v(!1),re=v(!1),oe=l(()=>y.params.bundleId),ue=l(()=>y.params.postId),de=v(1),me=v(50),pe=v(0),ye=l(()=>Math.ceil(pe.value/me.value)),he=v(null),ge=v(null),fe=l(()=>{var e
return"builtin"===(null==(e=he.value)?void 0:e.type)}),ke=l(()=>{var e
return"created"===(null==(e=he.value)?void 0:e.type)}),we=l(()=>he.value?se(he.value.bundleId):"mdi:forum-outline"),be=l(()=>K.value?fe.value?"":ke.value?ge.value||"":x.getAppIconUrl(K.value.bundleId):""),Ie=v(5),Re=v(5),Ce=v(20971520),Ne=v(20971520),Ue=v(null),Se=v(null),Fe=v(null),Ae=v(null),Ee=ee(),{previewVisible:xe,previewImagesInfo:Te,previewIndex:ze,preloadPostImages:De,handleImageClick:Pe,closePreview:Me}=Ee,$e=ve({maxImageCount:Ie.value,maxFileCount:Re.value,maxImageSize:Ce.value,maxFileSize:Ne.value}),{loadPost:Be}=function(e,l,a,t,s,i,n,r,o,u,d,c,v,m,p,y,h,g){const{queryUsersOnlineStatus:f}=ae()
return{loadPost:async()=>{var k,w,b,I
if(!l.value||!e.value)return h.value="无效的帖子ID或应用ID",void(y.value=!1)
y.value=!0,h.value=""
try{const b=await x.getForumByBundleId(e.value)
if(!b||"builtin"!==b.type&&"created"!==b.type){b&&(o.value=b.maxImageCount||5,u.value=b.maxFileCount||5,d.value=b.maxImageSize||20971520,c.value=b.maxFileSize||20971520)
const l=await(async e=>{try{return await x.getForumPermission(e)||{bundleId:e,appName:"",enabled:!1,postCount:0,createdAt:(new Date).toISOString(),updatedAt:(new Date).toISOString()}}catch(l){return{bundleId:e,appName:"",enabled:!1,postCount:0,createdAt:(new Date).toISOString(),updatedAt:(new Date).toISOString()}}})(e.value)
if(!l||!l.enabled)return h.value="该讨论区暂未开放,请等待管理员启用",void(y.value=!1)
try{t.value=await x.getApp(e.value),n.value=!1,r.value=!1}catch(R){}}else if(s.value=b,t.value={bundleId:b.bundleId,name:b.name,version:"",path:"",status:"unsupported",injection:null,update:null,hasIcon:!1},o.value=b.maxImageCount||5,u.value=b.maxFileCount||5,d.value=b.maxImageSize||20971520,c.value=b.maxFileSize||20971520,"created"===b.type&&b.iconId)try{const e=await x.getIcon(b.iconId)
i.value=e,n.value=!0,r.value=!1}catch(R){r.value=!0,n.value=!0}else n.value=!0,r.value=!1
try{const t=await x.getForumPost(e.value,l.value,v.value,m.value)
if(t){if(t.author&&void 0!==t.author.role&&(t.author.role=Ze(t.author.role)),t.replies&&Array.isArray(t.replies)&&t.replies.forEach(e=>{el(e)}),a.value=t,void 0!==t.replyTotal&&(p.value=t.replyTotal),void 0!==t.replyPage&&(v.value=t.replyPage),t.attachments&&g(t.attachments).catch(e=>{}),t.replies)for(const e of t.replies)if(e.attachments&&g(e.attachments).catch(e=>{}),e.nestedReplies)for(const l of e.nestedReplies)l.attachments&&g(l.attachments).catch(e=>{})
if(t&&a.value){const e=[],l=Z(a.value)
l&&e.push(l),t.replies&&Array.isArray(t.replies)&&t.replies.forEach(l=>{l.replyUser&&l.replyUser.id&&e.push(l.replyUser.id),l.nestedReplies&&Array.isArray(l.nestedReplies)&&l.nestedReplies.forEach(l=>{l.replyUser&&l.replyUser.id&&e.push(l.replyUser.id)})})
const s=Array.from(new Set(e)).filter(e=>e)
s.length>0&&f(s).catch(e=>{})}}else h.value="帖子不存在"}catch(R){const e=(null==(w=null==(k=R.response)?void 0:k.data)?void 0:w.message)||R.message||"加载帖子失败"
e.includes("锁定")||e.includes("无法查看")?h.value="帖子已锁定,无法查看":h.value=e,a.value=null}}catch(R){const e=(null==(I=null==(b=R.response)?void 0:b.data)?void 0:I.message)||R.message||"加载帖子失败"
e.includes("锁定")||e.includes("无法查看")?h.value="帖子已锁定,无法查看":h.value=e,a.value=null}finally{y.value=!1}}}}(oe,ue,G,K,he,ge,ne,re,Ie,Re,Ce,Ne,de,me,pe,X,ie,De),{handleLike:_e,handleDislike:je}=function(e,l,a){const t=E(),s=T()
return{handleLike:async()=>{var i,n
if(!a.value||!e.value||!l.value)return
const r="liked"===a.value.userLikeStatus?"cancel":"like"
s.show("cancel"===r?"取消点赞中...":"点赞中...")
try{const s=await x.likeForumPost(e.value,l.value,r)
s.success&&a.value?(a.value.userLikeStatus=s.userLikeStatus,a.value.likeCount=s.likeCount,a.value.dislikeCount=s.dislikeCount,"cancel"===r?t.success("已取消点赞"):t.success("点赞成功")):t.error("点赞失败")}catch(o){t.error((null==(n=null==(i=o.response)?void 0:i.data)?void 0:n.message)||o.message||"点赞失败")}finally{s.hide()}},handleDislike:async()=>{var i,n
if(!a.value||!e.value||!l.value)return
const r="disliked"===a.value.userLikeStatus?"cancel":"dislike"
s.show("cancel"===r?"取消点踩中...":"点踩中...")
try{const s=await x.likeForumPost(e.value,l.value,r)
s.success&&a.value?(a.value.userLikeStatus=s.userLikeStatus,a.value.likeCount=s.likeCount,a.value.dislikeCount=s.dislikeCount,"cancel"===r?t.success("已取消点踩"):t.success("点踩成功")):t.error("点踩失败")}catch(o){t.error((null==(n=null==(i=o.response)?void 0:i.data)?void 0:n.message)||o.message||"点踩失败")}finally{s.hide()}}}}(oe,ue,G),{showPostEditDialog:qe,postEditData:Oe,postEditLoading:He,handleEditPost:Ve,handleDeletePost:Je,handlePostEditConfirm:Qe,handlePostEditCancel:Ge}=function(e,l,a,t){const s=C(),i=E(),n=T(),r=z(),o=v(!1),u=v(null),d=v(!1)
return{showPostEditDialog:o,postEditData:u,postEditLoading:d,handleEditPost:()=>{if(!a.value)return
d.value=!0,o.value=!0
const l=a.value.author,t="object"==typeof l&&null!==l?l:null
u.value={id:a.value.id,bundleId:e.value,title:a.value.title,content:a.value.content,attachments:(a.value.attachments||[]).map(e=>({id:e.id,name:e.name,type:"image"===e.type?"image":"file",size:e.size})),author:t?{id:t.id||"",name:t.nickName||t.username||"",avatar:t.avatar}:void 0},d.value=!1},handleDeletePost:async()=>{var t,o
if(a.value&&e.value&&l.value&&await r.show({title:"删除帖子",message:`确定要删除帖子 "${a.value.title}" 吗?删除后无法恢复。`,type:"danger",confirmText:"删除",cancelText:"取消"})){n.show("删除中...")
try{const a=await x.deleteForumPost(e.value,l.value)
a.success?(i.success("帖子删除成功",2e3),s.push(`/discussion/${e.value}`)):i.error(a.message||"删除帖子失败",3e3)}catch(u){i.error((null==(o=null==(t=u.response)?void 0:t.data)?void 0:o.message)||u.message||"删除帖子失败",3e3)}finally{n.hide()}}},handlePostEditConfirm:async s=>{var r,d
if(a.value&&e.value&&l.value){n.show("保存中...")
try{const a=await x.updateForumPost(e.value,l.value,s.title,s.content,s.attachmentIds)
a.success?(i.success("帖子更新成功",2e3),o.value=!1,u.value=null,await t()):i.error(a.message||"更新帖子失败",3e3)}catch(c){i.error((null==(d=null==(r=c.response)?void 0:r.data)?void 0:d.message)||c.message||"更新帖子失败",3e3)}finally{n.hide()}}},handlePostEditCancel:()=>{o.value=!1,u.value=null}}}(oe,ue,G,Be),{handleAttachmentClick:Ke}={handleAttachmentClick:async e=>{if("image"===e.type)return
const l=await x.getAttachmentDownloadUrl(e.id)
if(!l)return
const a=document.createElement("a")
a.href=l.url,a.download=l.name,a.target="_blank",document.body.appendChild(a),a.click(),document.body.removeChild(a)}},We=v(null),Ll=function(e,l){const a=E(),t=T(),s=v(!1),i=v(null)
return{showReportDialog:s,reportInfo:i,handleReportPost:e=>{i.value={userId:Z(e),userName:Y(e),content:e.content,type:"post",postId:e.id},s.value=!0},handleReportReply:e=>{i.value={userId:e.replyUser.id,userName:e.replyUser.nickName||e.replyUser.username,content:e.content,type:"reply",postId:l,replyId:e.id},s.value=!0},handleReportNestedReply:e=>{i.value={userId:e.replyUser.id,userName:e.replyUser.nickName||e.replyUser.username,content:e.content,type:"nestedReply",postId:l,replyId:e.id},s.value=!0},handleReportSubmit:async(i,n,r)=>{var o,u
if(e&&l&&r.type){t.show("提交举报中...")
try{let t=""
if("post"===r.type?t=r.postId||l:("reply"===r.type||"nestedReply"===r.type)&&(t=r.replyId||""),!t)return
const o=await x.submitReport(r.type,t,e,l,i,r.content,n||void 0)
o.success?(s.value=!1,a.success("举报提交成功")):a.error(o.message||"举报失败")}catch(d){a.error((null==(u=null==(o=d.response)?void 0:o.data)?void 0:u.message)||d.message||"举报失败")}finally{t.hide()}}}}}(oe.value,ue.value),{showReportDialog:Tl,reportInfo:zl,handleReportPost:Dl,handleReportReply:Pl,handleReportNestedReply:Ml,handleReportSubmit:$l}=Ll,Bl=async()=>{if(oe.value&&ue.value&&G.value)try{const e=await x.getForumPost(oe.value,ue.value,de.value,me.value)
if(e){e.replies&&Array.isArray(e.replies)&&e.replies.forEach(e=>{el(e)}),G.value.replies=e.replies
const l=[],a=Z(G.value)
a&&l.push(a),e.replies&&Array.isArray(e.replies)&&e.replies.forEach(e=>{e.replyUser&&e.replyUser.id&&l.push(e.replyUser.id),e.nestedReplies&&Array.isArray(e.nestedReplies)&&e.nestedReplies.forEach(e=>{e.replyUser&&e.replyUser.id&&l.push(e.replyUser.id)})})
const t=Array.from(new Set(l)).filter(e=>e)
if(t.length>0&&Q(t).catch(e=>{}),G.value.replyCount=e.replyCount,void 0!==e.replyTotal&&(pe.value=e.replyTotal),void 0!==e.replyPage&&(de.value=e.replyPage),e.replies)for(const s of e.replies)if(s.attachments&&De(s.attachments).catch(e=>{}),s.nestedReplies)for(const e of s.nestedReplies)e.attachments&&De(e.attachments).catch(e=>{})}}catch(e){}},_l=function(e,l,a){const t=E(),s=T(),i=v(null),n=v(""),r=v([]),o=v([]),u=v([]),d=v(null),c=v(null),m=v(null),p=v(null),y=v(""),h=v([]),g=v([]),f=v([]),k=v(null),w=v(null),b=()=>{i.value=null,n.value="",r.value=[],o.value=[],u.value=[]},I=()=>{m.value=null,p.value=null,y.value="",h.value=[],g.value=[],f.value=[]}
return{editingReplyId:i,editingReplyContent:n,editingReplyAttachments:r,editingReplyNewAttachments:o,editingReplyNewFiles:u,editReplyImageInput:d,editReplyFileInput:c,handleEditReply:e=>{i.value=e.id,n.value=e.content,r.value=(e.attachments||[]).map(e=>({id:e.id,name:e.name,type:"image"===e.type?"image":"file",size:e.size})),o.value=[],u.value=[]},cancelEditReply:b,handleEditReplyImageSelect:e=>{const l=e.target,a=Array.from(l.files||[])
for(const s of a){if(o.value.length>=3){t.error("图片数量不能超过3张")
break}if(s.size>10485760){t.error("单张图片大小不能超过10MB")
continue}const e=new FileReader
e.onload=e=>{var l
const a=o.value.findIndex(e=>e.file===s)
a>=0&&(o.value[a].preview=null==(l=e.target)?void 0:l.result)},e.readAsDataURL(s),o.value.push({file:s,preview:""})}l.value=""},handleEditReplyFileSelect:e=>{const l=e.target,a=Array.from(l.files||[])
for(const s of a){if(u.value.length>=3){t.error("文件数量不能超过3个")
break}s.size>20971520?t.error("单个文件大小不能超过20MB"):u.value.push({file:s})}l.value=""},handleSaveReply:async i=>{var d,c
if(e&&l&&n.value.trim()){s.show("保存中...")
try{const d=[...r.value.map(e=>e.id)]
for(const e of o.value){s.show(`上传图片中... (${o.value.indexOf(e)+1}/${o.value.length})`)
const l=await x.uploadImageAttachment(e.file)
if(!l.success||!l.attachmentId)throw new Error(l.message||`图片上传失败: ${e.file.name}`)
d.push(l.attachmentId)}for(const e of u.value){s.show(`上传文件中... (${u.value.indexOf(e)+1}/${u.value.length})`)
const l=await x.uploadFileAttachment(e.file)
if(!l.success||!l.attachmentId)throw new Error(l.message||`文件上传失败: ${e.file.name}`)
d.push(l.attachmentId)}s.show("更新回复中...")
const c=await x.updateForumReply(e,l,i,n.value.trim(),d.length>0?d:void 0)
c.success?(t.success("回复更新成功",2e3),b(),await a()):t.error(c.message||"更新回复失败",3e3)}catch(v){t.error(v.message||(null==(c=null==(d=v.response)?void 0:d.data)?void 0:c.message)||"更新回复失败",3e3)}finally{s.hide()}}else t.error("回复内容不能为空",2e3)},editingNestedReplyId:m,editingNestedReplyParentId:p,editingNestedReplyContent:y,editingNestedReplyAttachments:h,editingNestedReplyNewAttachments:g,editingNestedReplyNewFiles:f,editNestedReplyImageInput:k,editNestedReplyFileInput:w,handleEditNestedReply:(e,l)=>{m.value=l.id,p.value=e,y.value=l.content,h.value=(l.attachments||[]).map(e=>({id:e.id,name:e.name,type:"image"===e.type?"image":"file",size:e.size})),g.value=[],f.value=[]},cancelEditNestedReply:I,handleEditNestedReplyImageSelect:e=>{const l=e.target,a=Array.from(l.files||[])
for(const s of a){if(g.value.length>=3){t.error("图片数量不能超过3张")
break}if(s.size>10485760){t.error("单张图片大小不能超过10MB")
continue}const e=new FileReader
e.onload=e=>{var l
const a=g.value.findIndex(e=>e.file===s)
a>=0&&(g.value[a].preview=null==(l=e.target)?void 0:l.result)},e.readAsDataURL(s),g.value.push({file:s,preview:""})}l.value=""},handleEditNestedReplyFileSelect:e=>{const l=e.target,a=Array.from(l.files||[])
for(const s of a){if(f.value.length>=3){t.error("文件数量不能超过3个")
break}s.size>20971520?t.error("单个文件大小不能超过20MB"):f.value.push({file:s})}l.value=""},handleSaveNestedReply:async i=>{var n,r
if(e&&l&&p.value&&y.value.trim()){s.show("保存中...")
try{const n=[...h.value.map(e=>e.id)]
for(const e of g.value){s.show(`上传图片中... (${g.value.indexOf(e)+1}/${g.value.length})`)
const l=await x.uploadImageAttachment(e.file)
if(!l.success||!l.attachmentId)throw new Error(l.message||`图片上传失败: ${e.file.name}`)
n.push(l.attachmentId)}for(const e of f.value){s.show(`上传文件中... (${f.value.indexOf(e)+1}/${f.value.length})`)
const l=await x.uploadFileAttachment(e.file)
if(!l.success||!l.attachmentId)throw new Error(l.message||`文件上传失败: ${e.file.name}`)
n.push(l.attachmentId)}s.show("更新回复中...")
const r=await x.updateForumReply(e,l,i,y.value.trim(),n.length>0?n:void 0)
r.success?(t.success("回复更新成功",2e3),I(),await a()):t.error(r.message||"更新回复失败",3e3)}catch(o){t.error(o.message||(null==(r=null==(n=o.response)?void 0:n.data)?void 0:r.message)||"更新回复失败",3e3)}finally{s.hide()}}else t.error("回复内容不能为空",2e3)}}}(oe.value,ue.value,Bl),{editingReplyId:jl,editingReplyContent:ql,editingReplyAttachments:Ol,editingReplyNewAttachments:Hl,editingReplyNewFiles:Vl,handleEditReply:Jl,cancelEditReply:Ql,handleSaveReply:Gl,handleEditReplyImageSelect:Kl,handleEditReplyFileSelect:Wl,editingNestedReplyId:Xl,editingNestedReplyContent:Yl,editingNestedReplyAttachments:Zl,editingNestedReplyNewAttachments:ea,editingNestedReplyNewFiles:la,handleEditNestedReply:aa,cancelEditNestedReply:ta,handleSaveNestedReply:sa,handleEditNestedReplyImageSelect:ia,handleEditNestedReplyFileSelect:na}=_l,ra=function(e,l,a,t,s){const i=E(),n=T(),r=s||z(),o=v(!1),u=v(!1),d=()=>e(),c=()=>l()
return{isSubmittingReply:o,isSubmittingNestedReply:u,submitReply:async e=>{const l=e||""
if((l.trim()||t.canSubmit.value)&&t.validateAttachments()){o.value=!0,n.show("发表回复中...")
try{const e=await t.uploadAttachments(),s=await x.createForumReply(d(),c(),l.trim(),void 0,void 0,e.length>0?e:void 0)
s.success?(await a(),t.clearAttachments(),i.success("回复成功"),setTimeout(()=>{const e=document.querySelector(".replies-section")
e&&e.scrollIntoView({behavior:"smooth",block:"start"})},100)):i.error(s.message||"回复失败")}catch(s){i.error(s.message||"回复失败")}finally{o.value=!1,n.hide()}}},submitNestedReply:async(e,l,t,s,r)=>{if(l.trim()||r.canSubmit.value){u.value=!0,n.show("发送回复中...")
try{const n=await r.uploadAttachments(),o=await x.createNestedReply(d(),c(),e,l.trim(),t,s,n.length>0?n:void 0)
o.success?(await a(),r.clearAttachments(),i.success("回复成功"),setTimeout(()=>{const l=document.querySelector(`[data-reply-id="${e}"]`)
l&&l.scrollIntoView({behavior:"smooth",block:"nearest"})},100)):i.error(o.message||"回复失败")}catch(o){i.error(o.message||"回复失败")}finally{u.value=!1,n.hide()}}},deleteReply:async e=>{var l,t
const s=d(),o=c()
if(s&&o){if(await r.show({title:"删除回复",message:"确定要删除这条回复吗?删除后无法恢复。",type:"danger",confirmText:"删除",cancelText:"取消"})){n.show("删除中...")
try{const l=await x.deleteForumReply(s,o,e)
l.success?(i.success("回复删除成功",2e3),await a()):i.error(l.message||"删除回复失败",3e3)}catch(u){i.error((null==(t=null==(l=u.response)?void 0:l.data)?void 0:t.message)||u.message||"删除回复失败",3e3)}finally{n.hide()}}}else i.error("参数错误,无法删除回复",2e3)},deleteNestedReply:async e=>{var l,t
const s=d(),o=c()
if(s&&o&&await r.show({title:"删除回复",message:"确定要删除这条回复吗?删除后无法恢复。",type:"danger",confirmText:"删除",cancelText:"取消"})){n.show("删除中...")
try{const l=await x.deleteForumReply(s,o,e)
l.success?(i.success("回复删除成功",2e3),await a()):i.error(l.message||"删除回复失败",3e3)}catch(u){i.error((null==(t=null==(l=u.response)?void 0:l.data)?void 0:t.message)||u.message||"删除回复失败",3e3)}finally{n.hide()}}}}}(()=>oe.value,()=>ue.value,Bl,$e,w),{isSubmittingReply:oa,isSubmittingNestedReply:ua,submitReply:da,submitNestedReply:ca,deleteReply:va,deleteNestedReply:ma}=ra,pa=e=>{Hl.value.splice(e,1)},ya=e=>{Vl.value.splice(e,1)},ha=e=>{ea.value.splice(e,1)},ga=e=>{la.value.splice(e,1)},fa=(e,l)=>{ma(l)},ka=(e,l,a,t)=>{var s,i
if(t)Se.value=Se.value===t?null:t,Ue.value=Se.value===t?e:null,Se.value===t?(Fe.value=l||null,Ae.value=a||null):(Fe.value=null,Ae.value=null)
else if(Ue.value=Ue.value===e?null:e,Se.value=null,Ue.value===e){const l=null==(i=null==(s=G.value)?void 0:s.replies)?void 0:i.find(l=>l.id===e)
l&&(Fe.value=l.replyUser.id,Ae.value=l.replyUser.nickName||l.replyUser.username)}else Fe.value=null,Ae.value=null},wa=()=>{Ue.value=null,Se.value=null,Fe.value=null,Ae.value=null},ba=e=>{de.value=e,Be()},Ia=te(),{showUserMenu:Ra,userMenuPosition:Ca,selectedUserId:Na,selectedUserName:Ua,selectedUserUsername:Sa,userAvatarId:Fa,handleAuthorHover:Aa,handleAuthorLeave:Ea,handleCardMouseEnter:xa,handleCloseUserMenu:La}=Ia,Ta=()=>{p.push(`/discussion/${oe.value}`)},za=()=>{p.push("/")},Da=W,Pa=()=>{G.value&&Dl(G.value)},Ma=(e,l)=>{var a,t
if(!G.value)return
const s=null==(a=G.value.replies)?void 0:a.find(l=>l.id===e)
if(!s)return
const i=null==(t=s.nestedReplies)?void 0:t.find(e=>e.id===l)
i&&Ml(i)},$a=v(null),Ba=async(e,l)=>{var a
if(!G.value)return
const t=null==(a=G.value.replies)?void 0:a.find(l=>l.id===e)
if(!t||!t.nestedReplies)return
const s=t.nestedReplies.find(e=>e.id===l)
if(!s)return
$a.value=l
const i=v(s),{handleLike:n}=ll(oe,ue,i)
await n(),$a.value=null},_a=async(e,l)=>{var a
if(!G.value)return
const t=null==(a=G.value.replies)?void 0:a.find(l=>l.id===e)
if(!t||!t.nestedReplies)return
const s=t.nestedReplies.find(e=>e.id===l)
if(!s)return
$a.value=l
const i=v(s),{handleDislike:n}=ll(oe,ue,i)
await n(),$a.value=null},ja=l(()=>!(!A.value||!G.value)&&Z(G.value)===A.value._id),qa=e=>!(!A.value||!e.replyUser)&&("object"==typeof e.replyUser&&null!==e.replyUser?e.replyUser.id:"string"==typeof e.replyUser?e.replyUser:"")===A.value._id,Oa=(e,l)=>{p.push(`/messages?userId=${e}&userName=${encodeURIComponent(l)}`)},Ha=(e,l)=>{}
return function(e,l,a,t){const{subscribeForum:s,unsubscribeForum:i,subscribePost:n,unsubscribePost:r,isConnected:o}=D(),{queryUsersOnlineStatus:u}=ae(),d=v(null),c=v(null),m=v(!1),p=v(!1),y=e=>{var s
const i=e.detail
if(!i||!i.reply||!i.postId)return
const n=i.reply
if(i.postId===l&&a.value){if(a.value.replies&&a.value.replies.findIndex(e=>e.id===n.id)>=0)return
var r;(r=n).replyUser&&void 0!==r.replyUser.role&&(r.replyUser.role=Ye(r.replyUser.role)),r.replyToUser&&void 0!==r.replyToUser.role&&(r.replyToUser.role=Ye(r.replyToUser.role)),r.nestedReplies&&Array.isArray(r.nestedReplies)&&r.nestedReplies.forEach(e=>{e.replyUser&&void 0!==e.replyUser.role&&(e.replyUser.role=Ye(e.replyUser.role)),e.replyToUser&&void 0!==e.replyToUser.role&&(e.replyToUser.role=Ye(e.replyToUser.role))}),n.isNew=!0,a.value.replies||(a.value.replies=[]),a.value.replies.push(n),setTimeout(()=>{var e,l
const t=null==(l=null==(e=a.value)?void 0:e.replies)?void 0:l.find(e=>e.id===n.id)
t&&(t.isNew=!1)},3e3),t.value=(t.value||0)+1,(null==(s=n.replyUser)?void 0:s.id)&&u([n.replyUser.id]).catch(e=>{})}},g=async()=>{if(e&&d.value!==e&&!m.value&&o.value){m.value=!0
try{await s(e),d.value=e}catch(ie){}finally{m.value=!1}}},f=async()=>{if(d.value)try{await i(d.value),d.value=null}catch(ie){}},k=async()=>{if(l&&c.value!==l&&!p.value&&o.value){p.value=!0
try{await n(l),c.value=l}catch(ie){}finally{p.value=!1}}},w=async()=>{if(c.value)try{await r(c.value),c.value=null}catch(ie){}},b=()=>{d.value=null,c.value=null,m.value=!1,p.value=!1},C=()=>{d.value&&o.value}
h(()=>o.value,a=>{a&&setTimeout(()=>{o.value&&(e&&g(),l&&k())},500)}),I(()=>{window.addEventListener("websocket:new-reply",y),window.addEventListener("websocket:disconnected",b),window.addEventListener("beforeunload",C),o.value&&(e&&g(),l&&k())}),R(async()=>{if(d.value)try{await Promise.race([f(),new Promise(e=>setTimeout(e,2e3))])}catch(ie){}if(c.value)try{await Promise.race([w(),new Promise(e=>setTimeout(e,2e3))])}catch(ie){}window.removeEventListener("websocket:new-reply",y),window.removeEventListener("websocket:disconnected",b),window.removeEventListener("beforeunload",C)})}(oe.value,ue.value,G,pe),I(()=>{Be()}),R(async()=>{}),(e,l)=>{var p,y,h
return c(),a("div",al,[o("div",tl,[o("div",sl,[o("div",il,[o("div",nl,[o("button",{class:"back-button",onClick:Ta},[s(F,{icon:"mdi:arrow-left",class:"back-icon"}),l[20]||(l[20]=o("span",null,"返回讨论区",-1))]),o("button",{class:"home-button",onClick:za},[s(F,{icon:"fluent-color:home-48",class:"home-icon"}),l[21]||(l[21]=o("span",null,"首页",-1))])])]),X.value?(c(),a("div",rl,[...l[22]||(l[22]=[o("div",{class:"spinner"},null,-1),o("p",null,"加载中...",-1)])])):ie.value?(c(),a("div",ol,[o("p",null,u(ie.value),1),o("button",{onClick:l[0]||(l[0]=(...e)=>d(Be)&&d(Be)(...e)),class:"btn btn-primary"},"重试")])):G.value?(c(),a("div",ul,[K.value?(c(),a("div",dl,[o("div",{class:"forum-info",onClick:Ta},[o("div",cl,[o("div",vl,[!be.value||fe.value||ke.value?t("",!0):m((c(),a("img",{key:0,src:be.value,alt:K.value.name,onLoad:l[1]||(l[1]=e=>ne.value=!0),onError:l[2]||(l[2]=e=>re.value=!0)},null,40,ml)),[[U,ne.value&&!re.value]]),ke.value&&ge.value?m((c(),a("img",{key:1,src:ge.value,alt:K.value.name,onLoad:l[3]||(l[3]=e=>ne.value=!0),onError:l[4]||(l[4]=e=>re.value=!0)},null,40,pl)),[[U,ne.value&&!re.value]]):t("",!0),fe.value?(c(),g(F,{key:2,icon:we.value,class:"builtin-forum-icon"},null,8,["icon"])):t("",!0),m(o("div",{class:"icon-placeholder"},u(K.value.name.charAt(0).toUpperCase()),513),[[U,(!be.value||!ne.value||re.value)&&!fe.value&&!ke.value]])])]),o("span",yl,u(K.value.name),1),s(F,{icon:"mdi:chevron-right",class:"breadcrumb-separator"})]),o("span",hl,u(G.value.title),1)])):t("",!0),o("div",gl,[o("div",fl,[o("h1",kl,u(G.value.title),1),o("div",wl,[o("div",{class:"author-wrapper",onMouseenter:l[5]||(l[5]=b(e=>d(Aa)(e,d(Z)(G.value),d(Y)(G.value),d(le)(G.value)||"",void 0),["stop"])),onMouseleave:l[6]||(l[6]=b((...e)=>d(Ea)&&d(Ea)(...e),["stop"]))},[o("div",bl,[s(L,{userId:d(Z)(G.value),width:"36px",height:"36px"},null,8,["userId"]),o("div",{class:r(["online-indicator",{online:d(J)(d(Z)(G.value)),offline:!1===d(J)(d(Z)(G.value))}])},null,2)]),o("span",Il,u(d(Y)(G.value)),1)],32),o("span",Rl,u(d(Da)(G.value.publishTime)),1)])]),o("div",Cl,[o("p",null,u(G.value.content),1),G.value&&G.value.attachments&&G.value.attachments.length>0?(c(),g(ce,{key:0,attachments:G.value.attachments||[],type:"post",onImageClick:l[7]||(l[7]=e=>{var l
return d(Pe)((null==(l=G.value)?void 0:l.attachments)||[],e)}),onFileClick:d(Ke)},null,8,["attachments","onFileClick"])):t("",!0)]),o("div",Nl,[o("button",{class:r(["action-btn",{active:"liked"===G.value.userLikeStatus}]),onClick:l[8]||(l[8]=(...e)=>d(_e)&&d(_e)(...e)),disabled:d(k).loadingState.value.visible},[s(F,{icon:"mdi:thumb-up",class:"action-icon"}),o("span",null,u(G.value.likeCount),1)],10,Ul),o("button",{class:r(["action-btn",{active:"disliked"===G.value.userLikeStatus}]),onClick:l[9]||(l[9]=(...e)=>d(je)&&d(je)(...e)),disabled:d(k).loadingState.value.visible},[s(F,{icon:"mdi:thumb-down",class:"action-icon"}),o("span",null,u(G.value.dislikeCount),1)],10,Sl),ja.value||d(V)?(c(),a("button",{key:0,class:"action-btn edit-btn",onClick:l[10]||(l[10]=(...e)=>d(Ve)&&d(Ve)(...e))},[s(F,{icon:"mdi:pencil",class:"action-icon"}),l[23]||(l[23]=o("span",null,"编辑",-1))])):t("",!0),ja.value||d(V)?(c(),a("button",{key:1,class:"action-btn delete-btn",onClick:l[11]||(l[11]=(...e)=>d(Je)&&d(Je)(...e))},[s(F,{icon:"mdi:delete-outline",class:"action-icon"}),l[24]||(l[24]=o("span",null,"删除",-1))])):t("",!0),o("button",{class:"action-btn report-btn",onClick:Pa},[s(F,{icon:"mdi:flag-outline",class:"action-icon"}),l[25]||(l[25]=o("span",null,"举报",-1))])])]),o("div",Fl,[o("div",Al,[o("h2",null,"回帖 ("+u(G.value.replyCount)+")",1)]),s(Le,{ref_key:"replyFormRef",ref:We,"user-id":null==(p=d(A))?void 0:p._id,"user-name":(null==(y=d(A))?void 0:y.nickName)||(null==(h=d(A))?void 0:h.username),"max-image-count":Ie.value,"max-file-count":Re.value,"max-image-size":Ce.value,"max-file-size":Ne.value,"is-submitting":d(oa),onSubmit:l[12]||(l[12]=(e,l,a)=>(async(e,l,a)=>{l&&l.length>0&&($e.selectedImages.value=l),a&&a.length>0&&($e.selectedFiles.value=a),await da(e||""),We.value&&We.value.clear()})(e,l,a))},null,8,["user-id","user-name","max-image-count","max-file-count","max-image-size","max-file-size","is-submitting"]),G.value.replies&&G.value.replies.length>0?(c(),a("div",El,[(c(!0),a(i,null,n(G.value.replies,e=>{var a,t,s
return c(),g(Xe,{key:e.id,reply:e,"is-author":qa(e),"is-admin":d(V),"user-id":null==(a=d(A))?void 0:a._id,"user-name":(null==(t=d(A))?void 0:t.nickName)||(null==(s=d(A))?void 0:s.username),"is-new":e.isNew,"is-editing":d(jl)===e.id,"editing-content":d(ql),"editing-attachments":d(Ol),"editing-new-images":d(Hl),"editing-new-files":d(Vl),"show-nested-form":Ue.value===e.id,"replying-to-nested-reply-id":Se.value,"nested-reply-to-user-name":Ae.value||e.replyUser.nickName||e.replyUser.username,"is-submitting-nested-reply":d(ua),"editing-nested-reply-id":d(Xl),"editing-nested-reply-content":d(Yl),"editing-nested-reply-attachments":d(Zl),"editing-nested-reply-new-attachments":d(ea),"editing-nested-reply-new-files":d(la),onEdit:l=>d(Jl)(e),onSave:l=>d(Gl)(e.id),onCancel:d(Ql),onDelete:l=>{return a=e.id,void(oe.value&&ue.value?va(a):f.error("参数错误,无法删除回复",2e3))
var a},onReport:l=>(e=>{var l
if(!G.value)return
const a=null==(l=G.value.replies)?void 0:l.find(l=>l.id===e)
a&&Pl(a)})(e.id),onReply:l=>ka(e.id),onLike:l=>(async e=>{var l
if(!G.value)return
const a=null==(l=G.value.replies)?void 0:l.find(l=>l.id===e)
if(!a)return
$a.value=e
const t=v(a),{handleLike:s}=ll(oe,ue,t)
await s(),$a.value=null})(e.id),onDislike:l=>(async e=>{var l
if(!G.value)return
const a=null==(l=G.value.replies)?void 0:l.find(l=>l.id===e)
if(!a)return
$a.value=e
const t=v(a),{handleDislike:s}=ll(oe,ue,t)
await s(),$a.value=null})(e.id),"like-loading":$a.value===e.id?e.id:$a.value,onNestedSubmit:(l,a,t)=>(async(e,l,a,t)=>{const s=ve({maxImageCount:3,maxFileCount:3,maxImageSize:10485760,maxFileSize:20971520})
s.selectedImages.value=a,s.selectedFiles.value=t,await ca(e,l,Fe.value||void 0,Ae.value||void 0,s),wa()})(e.id,l,a,t),onNestedCancel:wa,onNestedEdit:d(aa),onNestedSave:d(sa),onNestedEditCancel:d(ta),onNestedDelete:fa,onNestedReport:Ma,onNestedReplyClick:l[13]||(l[13]=(e,l,a,t)=>ka(e,l,a,t)),onNestedLike:Ba,onNestedDislike:_a,onAuthorHover:d(Aa),onAuthorLeave:d(Ea),onImageClick:l=>d(Pe)(e.attachments||[],l),onFileClick:d(Ke),onNestedImageClick:l[14]||(l[14]=(e,l)=>d(Pe)(e.attachments||[],l)),onRemoveAttachment:l[15]||(l[15]=e=>Ol.value=d(Ol).filter(l=>l.id!==e)),onRemoveNewImage:pa,onRemoveNewFile:ya,onEditImageSelect:d(Kl),onEditFileSelect:d(Wl),onNestedRemoveAttachment:l[16]||(l[16]=e=>Zl.value=d(Zl).filter(l=>l.id!==e)),onNestedRemoveNewImage:ha,onNestedRemoveNewFile:ga,onNestedEditImageSelect:d(ia),onNestedEditFileSelect:d(na)},null,8,["reply","is-author","is-admin","user-id","user-name","is-new","is-editing","editing-content","editing-attachments","editing-new-images","editing-new-files","show-nested-form","replying-to-nested-reply-id","nested-reply-to-user-name","is-submitting-nested-reply","editing-nested-reply-id","editing-nested-reply-content","editing-nested-reply-attachments","editing-nested-reply-new-attachments","editing-nested-reply-new-files","onEdit","onSave","onCancel","onDelete","onReport","onReply","onLike","onDislike","like-loading","onNestedSubmit","onNestedEdit","onNestedSave","onNestedEditCancel","onAuthorHover","onAuthorLeave","onImageClick","onFileClick","onEditImageSelect","onEditFileSelect","onNestedEditImageSelect","onNestedEditFileSelect"])}),128))])):t("",!0),G.value.replies&&G.value.replies.length>0&&ye.value>1?(c(),g(O,{key:1,"current-page":de.value,"total-pages":ye.value,total:pe.value,onPageChange:ba},null,8,["current-page","total-pages","total"])):t("",!0),G.value.replies&&0!==G.value.replies.length?t("",!0):(c(),a("div",xl,[...l[26]||(l[26]=[o("p",null,"还没有回帖,快来抢沙发吧!",-1)])]))])])):t("",!0)])]),s(q,{visible:d(xe),"images-info":d(Te),"initial-index":d(ze),"show-navigation":!0,"show-info":!0,onClose:d(Me),onIndexChange:l[17]||(l[17]=e=>ze.value=e)},null,8,["visible","images-info","initial-index","onClose"]),s(_,{visible:d(Tl),"report-info":d(zl),onClose:l[18]||(l[18]=e=>Tl.value=!1),onSubmit:d($l)},null,8,["visible","report-info","onSubmit"]),s(H,{visible:d(qe),"onUpdate:visible":l[19]||(l[19]=e=>S(qe)?qe.value=e:null),postData:d(Oe),loading:d(He),onConfirm:d(Qe),onCancel:d(Ge)},null,8,["visible","postData","loading","onConfirm","onCancel"]),s($,{visible:d(w).visible.value,title:d(w).config.value.title||"",message:d(w).config.value.message||"",type:"danger"===d(w).config.value.type?"error":d(w).config.value.type||"warning","confirm-text":d(w).config.value.confirmText,"cancel-text":d(w).config.value.cancelText,onConfirm:d(w).handleConfirm,onCancel:d(w).handleCancel},null,8,["visible","title","message","type","confirm-text","cancel-text","onConfirm","onCancel"]),s(j,{visible:d(Ra),"user-id":d(Na),"user-name":d(Ua),username:d(Sa)||"","avatar-id":d(Fa)||void 0,position:d(Ca),onClose:d(La),onSendMessage:Oa,onBlockUser:Ha,onMouseEnter:d(xa)},null,8,["visible","user-id","user-name","username","avatar-id","position","onClose","onMouseEnter"]),s(B,{toasts:d(f).toasts.value,onRemove:d(f).removeToast},null,8,["toasts","onRemove"])])}}}),[["__scopeId","data-v-9ed3dc2c"]])
export{Ll as default}