const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/js/index-C7tUhOir.js","assets/js/vendor-wangeditor-_sNkeykm.js","assets/js/vendor-core-Di0OO4oJ.js","assets/css/vendor-core-CMnMgErA.css","assets/css/vendor-wangeditor-BHtaHxM4.css","assets/js/index-CY1ySRal.js","assets/js/vendor-element-DupX9wXy.js","assets/css/vendor-element-BVn4OBXk.css","assets/css/index-m0oZ9fQD.css","assets/js/emojo-Ben6gd8J.js","assets/css/index-av9x5JQT.css"])))=>i.map(i=>d[i]);
var e=Object.defineProperty,l=Object.defineProperties,a=Object.getOwnPropertyDescriptors,t=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,i=(l,a,t)=>a in l?e(l,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[a]=t,u=(e,l,a)=>new Promise((t,r)=>{var s=e=>{try{u(a.next(e))}catch(l){r(l)}},i=e=>{try{u(a.throw(e))}catch(l){r(l)}},u=e=>e.done?t(e.value):Promise.resolve(e.value).then(s,i);u((a=a.apply(e,l)).next())});import{u as n,j as o,_ as c,r as d}from"./index-CY1ySRal.js";import{a1 as m,C as p,a5 as v,a6 as f,a4 as y,B as h,a7 as b,A as _,e as j,E as x}from"./vendor-element-DupX9wXy.js";import{P as V}from"./formEnum-BLgiZVxV.js";import{q as g,bI as P,bC as A,r as E,R as O,t as w,v as T,A as C,M as S,E as q,u as D,h as L,L as U,aq as F,D as I,bH as N,K as k,J as M}from"./vendor-core-Di0OO4oJ.js";import{g as R,s as B}from"./article-BU3542s_.js";const H={class:"max-w-250 mx-auto my-5"},J={class:"p-5 mt-5 art-card-xs"},K={class:"mb-5 text-xl font-medium"},z={class:"flex justify-end"},G=g((Q=((e,l)=>{for(var a in l||(l={}))r.call(l,a)&&i(e,a,l[a]);if(t)for(var a of t(l))s.call(l,a)&&i(e,a,l[a]);return e})({},{name:"ArticlePublish"}),l(Q,a({__name:"index",setup(e){const l=N(()=>c(()=>import("./index-C7tUhOir.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]))),{t:a}=P(),t=n(),r=A(),s=E(V.Add),i=E(""),g=E(),G=E([]),Q=E(""),W=E(!0),X=E(!1),Y=()=>{G.value=[{id:"platform_notice",name:a("article.platformNotice")},{id:"settlement_notice",name:a("article.settlementNotice")},{id:"shop_announcement",name:a("article.shopAnnouncement")}]},Z=e=>u(null,null,function*(){try{const l=yield R(e);l&&(i.value=l.title,g.value=l.type,Q.value=l.content,W.value=1===l.status)}catch(l){x.error(a("article.getDetailFailed"))}}),$=()=>i.value.trim()?g.value?!(!Q.value||"<p><br></p>"===Q.value)||(x.error(a("article.inputContent")),!1):(x.error(a("article.selectType")),!1):(x.error(a("article.inputTitle")),!1),ee=e=>e.replace(/(\s*)<\/code>/g,"</code>"),le=()=>u(null,null,function*(){yield t.fetchSiteConfig(void 0,!0)}),ae=()=>{s.value===V.Edit?u(null,null,function*(){if($()&&!X.value){X.value=!0;try{const e=ee(Q.value),l={id:r.query.id,title:i.value,type:g.value,content:e,status:W.value?1:0,is_top:0};yield B(l),yield le(),x.success(a("article.saveSuccess")),d.push({name:"ArticleList"}).catch(()=>{})}catch(e){x.error(a("article.saveFailed"))}finally{X.value=!1}}}):u(null,null,function*(){if($()&&!X.value){X.value=!0;try{const e=ee(Q.value),l={title:i.value,type:g.value,content:e,status:W.value?1:0,is_top:0};yield B(l),yield le(),x.success(a("article.publishSuccess")),d.push({name:"ArticleList"}).catch(()=>{})}catch(e){x.error(a("article.publishFailed"))}finally{X.value=!1}}})},{scrollToTop:te}=o();return O(()=>{te(),Y(),(()=>{const{id:e}=r.query;s.value=e?V.Edit:V.Add,Y(),s.value===V.Edit&&e&&Z(Number(e))})()}),(e,t)=>{const r=p,u=m,n=f,o=v,c=y,d=b,x=h,P=_,A=j;return T(),w("div",null,[C("div",null,[C("div",H,[S(c,{gutter:10},{default:q(()=>[S(u,{span:18},{default:q(()=>[S(r,{modelValue:D(i),"onUpdate:modelValue":t[0]||(t[0]=e=>L(i)?i.value=e:null),modelModifiers:{trim:!0},placeholder:D(a)("article.inputTitlePlaceholder"),maxlength:"100"},null,8,["modelValue","placeholder"])]),_:1}),S(u,{span:6},{default:q(()=>[S(o,{modelValue:D(g),"onUpdate:modelValue":t[1]||(t[1]=e=>L(g)?g.value=e:null),placeholder:D(a)("article.selectTypePlaceholder"),filterable:""},{default:q(()=>[(T(!0),w(U,null,F(D(G),e=>(T(),I(n,{key:e.id,label:e.name,value:e.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1})]),_:1}),S(D(l),{class:"mt-2.5",modelValue:D(Q),"onUpdate:modelValue":t[2]||(t[2]=e=>L(Q)?Q.value=e:null)},null,8,["modelValue"]),C("div",J,[C("h2",K,k(D(a)("article.publishSetting")),1),S(P,null,{default:q(()=>[S(x,{label:D(a)("article.visible")},{default:q(()=>[S(d,{modelValue:D(W),"onUpdate:modelValue":t[3]||(t[3]=e=>L(W)?W.value=e:null)},null,8,["modelValue"])]),_:1},8,["label"])]),_:1}),C("div",z,[S(A,{type:"primary",loading:D(X),onClick:ae,class:"w-25"},{default:q(()=>[M(k(D(s)===D(V).Edit?D(a)("article.save"):D(a)("article.publishAction")),1)]),_:1},8,["loading"])])])])])])}}}))));var Q;export{G as default};
