import{b4 as e}from"./site.js?v=20260328163632";import{u as a,l,K as t,t as s,x as i}from"./utils-lib.js?v=20260328163632";import{u}from"./store4.js?v=20260328163632";import{B as r}from"./index84.js?v=20260328163632";import{i as o,r as n,g as p}from"./index.vue_vue_type_script_setup_true_lang14.js?v=20260328163632";import{k as c,r as m,O as v,c as b,o as d,U as h,V as f,W as g,l as j,Y as x}from"./base-lib.js?v=20260328163632";import{s as y,n as _}from"./naive-ui.js?v=20260328163632";import"./__commonjsHelpers__.js?v=20260328163632";import"./env-lib.js?v=20260328163632";import"./index.vue_vue_type_script_setup_true_lang10.js?v=20260328163632";import"./index158.js?v=20260328163632";import"./ace.js?v=20260328163632";import"./index91.js?v=20260328163632";const w={class:"p-20px pr-40px"},T=c({__name:"add-static-cache",setup(c,{expose:T}){const{siteInfo:U}=u(),{isIIS:N}=a(),I=m(!1),K=m([{label:"html",value:"html"},{label:"htm",value:"htm"},{label:"js",value:"js"},{label:"css",value:"css"},{label:"jpg",value:"jpg"},{label:"jpeg",value:"jpeg"},{label:"png",value:"png"},{label:"gif",value:"gif"},{label:"svg",value:"svg"},{label:"ico",value:"ico"},{label:"woff",value:"woff"},{label:"woff2",value:"woff2"},{label:"ttf",value:"ttf"},{label:"eot",value:"eot"},{label:"mp4",value:"mp4"},{label:"webp",value:"webp"}]),O={labelStyle:"min-width: 100px"},k=m({label:l("名称"),attrs:O,ruleKey:"name",rule:[t({message:l("请输入名称")})],children:[{type:"input",key:"name",attrs:{class:"!w-300px",disabled:o.value,placeholder:l("请输入名称")}}]}),S=m({label:l("开启缓存"),attrs:O,children:[{type:"custom",render:()=>v(y,{value:W.value.open,"onUpdate:value":e=>W.value.open=e},null)}]}),V=m({label:l("静态缓存后缀"),attrs:O,ruleKey:"exts",rules:[t({message:l("请选择静态缓存后缀")},{type:"array"})],children:[{type:"select",key:"exts",attrs:{class:"!w-300px",placeholder:l("请选择静态缓存后缀"),options:K.value,filterable:!0,tag:!0,multiple:!0}}]}),A=m({label:l("缓存时间"),attrs:O,ruleKey:"cacheTime",rules:[{validator:(e,a,t)=>""===a?!!N.value||new Error(l("请输入缓存时间")):!(isNaN(Number(a))||Number(a)<=0)||new Error(l("缓存时间必须为正整数")),trigger:["blur","input"]}],children:[{type:"custom",render:()=>v(r,{modelValue:W.value.cacheTime,"onUpdate:modelValue":e=>W.value.cacheTime=e,placeholder:l("请输入缓存时间"),width:"120px"},{append:()=>v(_,{value:W.value.cacheTimeUnit,"onUpdate:value":e=>W.value.cacheTimeUnit=e,options:[{label:l("分钟"),value:"m"},{label:l("小时"),value:"h"},{label:l("天"),value:"d"}],style:"width: 90px"},null)})}]}),B=m({formAttrs:{labelWidth:"auto"},formItems:b((()=>[...o.value?[k.value,S.value]:[],V.value,A.value]))}),[E,W,q]=s(B);return d((()=>{if(n.value){const{name:e,open:a,exts:l,cacheTime:t}=n.value;Object.assign(W.value,{name:e,open:Boolean(a),exts:l,cacheTime:null==t?void 0:t.replace(/[a-zA-Z]/g,""),cacheTimeUnit:(null==t?void 0:t.replace(/[0-9]/g,""))||"m"})}else Object.assign(W.value,{exts:[],cacheTime:10,cacheTimeUnit:"m"})})),T({onConfirm:async a=>{try{await q.value.validate();const{cacheTime:a,cacheTimeUnit:t,exts:s,...u}=W.value;let r={siteid:U.value.id,name:(new Date).getTime(),open:!0,...u,cacheTime:a?a+t:"",exts:JSON.stringify(s)};return(await i({loading:l("正在保存，请稍后..."),request:e(r),message:!0,success:async e=>{p()}})).status}catch(t){}}}),(e,a)=>{const l=h("bt-loading");return f(),g("div",w,[j(v(x(E),null,null,512),[[l,x(I)]])])}}});export{T as default};
