File: /www/server/panel/BTPanel/static/js/white-list.js
import{R as M,w as R,k as $,o as ae,cR as le,cO as se,d3 as ne,d4 as oe,cP as ie,f as re,cZ as ce}from"./utils-lib.js?v=1777008528";import{_ as pe}from"./index118.js?v=1777008528";import{_ as de}from"./index131.js?v=1777008528";import{c as me,r as p,H as P,g as Fe,e as t,x as e,F,o as _e,I as he,J as O,p as d,j as S,k as fe,C as we,y as ve,Q as z,v as E,q as Ee,ap as be,n as De,z as ge}from"./base-lib.js?v=1777008528";import{e as ye,E as Be,g as Ce,b as Ae}from"./index3.js?v=1777008528";import{getTamperRuleByPath as $e,addWhiteDirs as xe,addWhiteFiles as ke,releaseWhiteDirname as x,releaseWhiteFileExt as k,getActionLogsForDirname as qe,getActionLogsForFilename as Te,setWhiteDirWithPs as Ve,removeWhiteDirs as N,removeWhiteFiles as j}from"./site.js?v=1777008528";import{t as We}from"./useController13.js?v=1777008528";import{u as He}from"./useStore2.js?v=1777008528";import{_ as Le}from"./masker.vue_vue_type_script_setup_true_lang.js?v=1777008528";import"./__commonjsHelpers__.js?v=1777008528";import"./index119.js?v=1777008528";import"./index116.js?v=1777008528";import"./index175.js?v=1777008528";import"./index.vue_vue_type_style_index_0_scoped_cdc7f4d3_lang.js?v=1777008528";const Me={class:"flex gap-col-1rem"},Re=me({__name:"white-list",props:{compData:{default:{}}},setup(I,{expose:U}){const{siteInfo:J}=He(),D=re(),i=p("dir"),q=p(),B=p(!1),f=p(""),Q=p(!1),c=p({}),C=p([]);p(!1),p(!1),p(),p(!1),P({sites:[],list:[]}),P({isRecurrence:!1,describe:{title:"",th:"",message:"",propsValue:""}});const Z=Fe(()=>i.value==="dir"?[{content:t(F,null,[e("此处允许使用全路径或目录名或路径的一部分如:"),t("code",null,[e("/www/abc/cache/test/,test,cache/test/")])])},{content:t(F,null,[e("全路径首位必需为"),t("code",null,[e("/")]),e(",如:"),t("code",null,[e("/www/abc/cache/test/")])])},{content:t(F,null,[e("录名或路径的一部分首位不能是"),t("code",null,[e("/")]),e(",如:"),t("code",null,[e("cache/test/")]),e("或"),t("code",null,[e("test")])])},{content:t(F,null,[e("例1:"),t("code",null,[e("/www/abc/")]),e("匹配:"),t("code",null,[e("/www/abc/*")]),e("不匹配:"),t("code",null,[e("/www/abc")]),t("code",null,[e("/www/abc123")])])},{content:t(F,null,[e("例2:"),t("code",null,[e("test")]),e("匹配:"),t("code",null,[e("/www/test/1.txt")]),t("code",null,[e("/www/test_abc")]),e("不匹配:"),t("code",null,[e("/www/1.php")])])},{content:t(F,null,[e("例3:"),t("code",null,[e("cache/test/")]),e("匹配:"),t("code",null,[e("/www/cache/test/1.txt")]),t("code",null,[e("/cache/test/")]),e("不匹配:"),t("code",null,[e("/www/cache/test")]),t("code",null,[e("/cache/")])])}]:[{content:"支持以下5种方式"},{content:t(F,null,[e("1、完整文件路径,如:"),t("code",null,[e("/www/wwwroot/test/123.php")])])},{content:t(F,null,[e("2、相对于网站的相对路径,如:全路径是"),t("code",null,[e("/www/wwwroot/test/app/123.php")]),e("相对路径"),t("code",null,[e("./app/123.php")])])},{content:t(F,null,[e("3、指定目录下的所有文件,如:"),t("code",null,[e("/www/wwwroot/test/app/*")]),e("相对路径"),t("code",null,[e("./app/*")])])},{content:t(F,null,[e("4、指定目录下的指定文件类型,如:"),t("code",null,[e("/www/wwwroot/test/app/*.php")]),e("相对路径"),t("code",null,[e("./app/*.php")])])},{content:t("span",{class:"text-danger"},[e("注意,已经在【受保护的文件类型】中被包含的文件无需专门设置规则")])}]),A=async(a,u,s,l)=>{const n=i.value==="dir",o=n?"目录":"文件",{label:w,value:r}=l,m=new Map([["start","批量开启选中的".concat(o,"白名单")],["stop","批量关闭选中的".concat(o,"白名单")],["delete","批量删除选中的".concat(o,"白名单")]]),h=async(v,b)=>{const L=new Map([["start",n?x:k],["stop",n?x:k],["delete",n?N:j]]).get(r);let y={path_id:c.value.pid,[n?"dirname":"filename"]:v[n?"dir":"filename"]};switch(r){case"start":case"stop":return y.release=r==="start"?1:0,L(y);case"delete":return y.path=c.value.path,L(y)}};await a({title:"批量".concat(w),content:"".concat(m.get(r),",是否继续操作?"),column:[{prop:"".concat(n?"dir":"filename"),label:"".concat(n?"文件全路径 或 相对路径":"文件类型")},Ae()],onConfirm:async()=>(await u(h),_(),!1)})},T=()=>p([{label:"开启".concat(i.value=="dir"?"目录":"文件","白名单"),value:"start",event:A},{label:"关闭".concat(i.value=="dir"?"目录":"文件","白名单"),value:"stop",event:A},{label:"删除".concat(i.value=="dir"?"目录":"文件","白名单"),value:"delete",event:A}]),V=()=>p([ye({key:"dir"}),{label:i.value=="dir"?"目录":"文件名",prop:i.value=="dir"?"dir":"filename"},i.value=="dir"?Be({minWidth:150,width:300,request:te}):{label:"备注",prop:"ps"},{label:"状态",prop:"limit_status",width:50,render:a=>{let u=a.limit_status===1;return t(be,{size:"small",modelValue:u,"onUpdate:modelValue":s=>u=s,onChange:s=>X(a,s)},null)}},Ce([{title:"日志",onClick:ee},{title:"删除",onClick:Y}])]),G=p([{label:"目录白名单",name:"dir",lazy:!0,render:()=>t("span",null,null)},{label:"文件白名单",name:"file",lazy:!0,render:()=>t("span",null,null)}]),_=async(a=!1)=>{var u,s;try{a&&(B.value=!0);const{data:l}=await $e({path:J.value.path});let n=[];if(l.hasOwnProperty("status"))if(c.value=l,i.value=="dir")(u=l==null?void 0:l.unused_white_dirs)==null||u.forEach(o=>{n.push({...o,ps:o.ps||"",limit_status:0})}),(s=l==null?void 0:l.white_dirs)==null||s.forEach(o=>{var m;let w={...o,ps:o.ps||"",limit_status:1},r=(m=l==null?void 0:l.temporarily_dirs)==null?void 0:m.find(h=>h.value===o.dir);r&&(w.time=r.time,w.ps="临时放行截止至"+M(r.time,"yyyy-MM-dd HH:mm:ss")),n.push(w)});else{let o=l.white_files;l.unused_white_files.forEach(r=>{n.push({filename:r,limit_status:0,ps:"-"})}),o.forEach(r=>{var v;let m={filename:r,limit_status:1,ps:"-"},h=(v=l==null?void 0:l.temporarily_files)==null?void 0:v.find(b=>b.value===r);h&&(m.time=h.time,m.ps="临时放行截止至"+M(h.time,"yyyy-MM-dd HH:mm:ss")),n.push(m)})}C.value=n}catch(l){}finally{a&&(B.value=!1)}},K=async()=>{if(f.value==="")return D.error("文件类型不能为空");try{const a=i.value=="dir"?await xe({path_id:c.value.pid,path:c.value.path,dirnames:f.value}):await ke({path_id:c.value.pid,path:c.value.path,filename:f.value});D.request(a),a.status&&(f.value="",_())}catch(a){}},X=async(a,u)=>{const s=i.value=="dir";try{if(a.hasOwnProperty("time")){De(()=>{a.limit_status=!u,D.error("临时放行文件无法修改状态")});return}a.limit_status=u?1:0,await R({title:"".concat(u?"开启":"关闭","【").concat(s?a.dir:a.filename,"】"),content:"".concat(u?"开启该文件白名单后,该文件将不被保护,是否继续?":"关闭该文件白名单后,该文件将被保护,是否继续?")});const l={path_id:c.value.pid,[s?"dirname":"filename"]:a[s?"dir":"filename"],release:u?1:0};(await $({loading:"正在设置白名单状态,请稍后...",request:(s?x:k)(l),message:!0})).status&&_()}catch(l){l==="cancel"&&(a.limit_status=u?0:1)}},Y=async a=>{let u=i.value==="dir",s=u?"目录":"文件";await R({title:"删除【".concat(u?a.dir:a.filename,"】"),content:"删除该".concat(s,"白名单后,该").concat(s,"将受到保护,是否继续操作?")});const l={path_id:c.value.pid,path:c.value.path,[u?"dirname":"filename"]:a[u?"dir":"filename"]},n=u?N:j;(await $({loading:"正在删除".concat(s,"白名单,请稍后..."),request:n(l),message:!0})).status&&_()},ee=async a=>{var s;const u=i.value==="dir";try{const l={path_id:c.value.pid,[u?"dirname":"filename"]:a[u?"dir":"filename"],row:10,pid:c.value.pid,p:1},n=u?qe:Te,{data:o}=await n(l);(s=o.data)!=null&&s.length?We({title:"".concat(i.value==="dir"?"目录【".concat(a.dir,"】"):"文件【".concat(a.filename,"】"),"白名单日志"),row:a,data:o,params:{...l,total:ae(o.page)}}):D.error("暂无日志")}catch(l){}},te=async(a,u)=>{$({loading:"正在修改备注信息,请稍后...",request:Ve({path_id:c.value.pid,dir_name:a.dir,ps:u}),message:!0})},W=V(),H=T(),ue=a=>{f.value="",i.value=a,W.value=V().value,H.value=T().value,C.value=[],_()};return _e(()=>{_(!0)}),U({init:()=>{_(!0)}}),(a,u)=>{var b;const s=le,l=se,n=ge,o=de,w=ne,r=oe,m=pe,h=ie,v=he("bt-loading");return O((S(),fe("div",null,[(b=d(c))!=null&&b.path?ve("",!0):(S(),we(Le,{key:0,compData:{...I.compData,init:_}},null,8,["compData"])),t(s,{ref:"tamperRef",type:"",modelValue:d(i),"onUpdate:modelValue":u[0]||(u[0]=g=>z(i)?i.value=g:null),options:d(G),onChange:ue},null,8,["modelValue","options"]),t(m,null,{"header-left":E(()=>[Ee("div",Me,[t(l,{modelValue:d(f),"onUpdate:modelValue":u[1]||(u[1]=g=>z(f)?f.value=g:null),width:"30rem",placeholder:"".concat(d(i)==="dir"?"目录名":"文件名")},null,8,["modelValue","placeholder"]),t(n,{type:"primary",onClick:K},{default:E(()=>[...u[2]||(u[2]=[e("添加",-1)])]),_:1})])]),"header-right":E(()=>[t(o,{onRefresh:_})]),content:E(()=>[O(t(w,{ref_key:"whiteTableRef",ref:q,column:d(W),maxHeight:350,data:d(C)},null,8,["column","data"]),[[v,d(Q)]])]),"footer-left":E(()=>[t(r,{"table-ref":d(q),options:d(H)},null,8,["table-ref","options"])]),"footer-right":E(()=>[...u[3]||(u[3]=[])]),_:1}),t(h,{options:d(Z),class:"ml-2rem mt-2rem tamper-help-info leading-2rem"},null,8,["options"])])),[[v,d(B)],[v,"正在获取站点防篡改信息,请稍侯","title"]])}}}),Ye=ce(Re,[["__scopeId","data-v-77447fa2"]]);export{Ye as default};