import{P as a,u as t,M as e,p as s}from"./utils-lib.js?v=1761009159";import{j as n,t as r,r as u}from"./base-lib.js?v=1761009159";import{u as i,S as l}from"./useStore4.js?v=1761009159";import{delRewriteTel as c,getRewriteList as o,setRewriteTel as v}from"./site.js?v=1761009159";const d=n("SITE-PSEUDO-STORE",()=>({delPseudoStaticEvent:async t=>{try{await a({loading:"正在删除伪静态规则，请稍候...",request:c(t),message:!0})}catch(e){return{status:!1,msg:"删除失败"}}},getReWriteListEvent:async t=>{try{const{data:e}=await a({request:o(t)});return{data:e,status:status}}catch(e){return{status:!1,msg:"获取伪静态列表失败"}}},setTemplateEvent:async t=>{try{const e=await a({loading:"正在设置模板，请稍候...",request:v(t),message:!0});return{status:e.status,msg:e.msg}}catch(e){return{status:!1,msg:"设置模板失败"}}}})),{siteType:m,siteInfo:w,isBindExtranet:p}=i(),{getFileEvent:y,saveFileEvent:g}=l(),{plugin:f,getGlobalInfo:h}=t(),{webserver:E}=r(f.value),{delPseudoStaticEvent:b,getReWriteListEvent:j,setTemplateEvent:S}=d(),x=u(""),P=u([]),T=u(""),_=u([]),q=u(!1),I=u(""),R=u(!1),F=[{content:"请选择您的应用，若设置伪静态后，网站无法正常访问，请尝试设置回default"},{content:"您可以对伪静态规则进行修改，修改完后保存即可。"}],L=a=>!P.value.includes(a),O=async a=>{await s({title:"删除伪静态模板【".concat(a.name,"】"),content:"删除后不可恢复，确定删除吗？",icon:"warning-filled"});(await b(a)).status&&(await W(),await D())},W=async()=>{const a=["php","proxy"].includes(m.value),t={siteName:(a?"":m.value+"_")+w.value.name};R.value=!0;const e=await j(t);B(e.data,a),R.value=!1},B=async(a,t)=>{_.value=a.rewrite,P.value=a.default_list,I.value=a.sitePath+"/.htaccess",T.value=a.rewrite[0]||"","nginx"===E.value&&(I.value="/www/server/panel/vhost/rewrite/".concat((t?"":m.value.replace("nodejs","node")+"_")+w.value.name,".conf"))},D=async(a={path:I.value})=>{try{R.value=!0;const t=await y(a);return x.value=t.data.data,R.value=!1,t}catch(t){return R.value=!1,{data:"获取伪静态内容失败"}}},G=a=>{let t="/www/server/panel/rewrite/".concat(E.value,"/").concat(a,".conf");"0.当前"===a?D():D({path:t})},M=async(a={data:x.value,encoding:"utf-8",path:"".concat(I.value)})=>{(await g(a)).status&&W()},N=async a=>{try{const t={...a,data:x.value};if(t.name=t.name.trim(),t.name.includes(" "))return e.error("模板名称不能包含空格");if(""===t.name)return e.error("模板名称不能为空");if(_.value.includes(t.name))return e.error("模板名称不能和已有的模板名称重复且不可为空");const s=await S(t);return s.status&&(q.value=!1,await W(),await D()),s.status}catch(t){return!1}},U=async()=>{var a,t;await h();["php","proxy","html","phpasync"].includes(m.value)?p.value=!0:p.value=!!(null==(t=null==(a=w.value)?void 0:a.project_config)?void 0:t.bind_extranet),await W(),await D()};export{T as a,M as b,F as c,N as d,L as e,O as f,G as h,U as i,_ as o,x as s,R as t};
