File: /www/server/panel/BTPanel/static/js/index533.js
import{hJ as Pe,f as ue,cZ as ce,c as Fe,hK as Ee,R as Ne,hL as qe,b as Le,cO as Oe,c_ as Ae,d3 as ze,a as Ke}from"./utils-lib.js?v=1777008528";import{c as pe,r as a,I as fe,j as w,k as C,q as l,J as de,e as i,p as u,Q as G,P as me,v as I,x as V,L as Me,T as He,z as ve,V as ae,g as Je,a3 as ne,s as D,F as oe,B as ie,y as re}from"./base-lib.js?v=1777008528";import"./__commonjsHelpers__.js?v=1777008528";const je={class:"create-file-view flex"},Ue={class:"flex-1 flex items-center"},We=pe({__name:"create-file",props:{type:{default:"Dir"},path:{},filelist:{}},emits:["createStatus"],setup(T,{emit:H}){const{error:P}=ue(),q=H,g=T;let h=a("");const F=a(),L=async()=>{const b=F.value;if(!h.value){P("".concat(g.type==="Dir"?"文件夹":"文件","名称不能为空"));return}const c=await Pe({type:g.type,path:g.path+"/"+h.value});c.status?E():(P(c.msg),b.$el.querySelector("input").focus())},E=()=>{g.filelist.value.shift(),q("createStatus")},o=b=>{h.value=b,/(\\|\/|\<|\>|\"|\&|\;)/g.test(b)&&(P('名称不能含有 /\\<>"&;符号'),h.value=b.replace(/(\\|\/|\<|\>|\"|\&|\;)/g,""))};return(b,c)=>{const O=He,N=ve,A=fe("focus");return w(),C("div",je,[l("div",{class:Me(["flex","".concat(T.type==="Dir"?"bt-open-dir folder-open-icon":"bt-open-dir file-text-icon")])},[c[4]||(c[4]=l("i",{class:"icon"},null,-1)),l("div",Ue,[de(i(O,{class:"!w-[22rem] mr-[1.6rem]",clearable:"",modelValue:u(h),"onUpdate:modelValue":c[0]||(c[0]=$=>G(h)?h.value=$:h=$),ref_key:"createfile",ref:F,onInput:o,onKeyup:c[1]||(c[1]=me($=>$.target.blur(),["enter","native"]))},null,8,["modelValue"]),[[A]]),i(N,{type:"primary",class:"!mr-[.8rem]",onClick:L},{default:I(()=>[...c[2]||(c[2]=[V(" 创建 ",-1)])]),_:1}),i(N,{type:"default",onClick:E},{default:I(()=>[...c[3]||(c[3]=[V("取消",-1)])]),_:1})])],2)])}}}),Ge=ce(We,[["__scopeId","data-v-c17175a3"]]),Qe={class:"text-black text-base pl-[1.6rem] pt-[1.6rem]"},Ze={class:"p-[1.6rem] flex justify-between"},Xe={class:"file-selector-head"},Ye=["onClick"],et={class:"truncate max-w-[8rem]"},tt={class:"ml-[0.4rem] flex items-align"},lt={class:"ml-[1.6rem] mb-[1.6rem]"},st={class:"flex h-[48rem] file-selector-main"},at={class:"w-[16rem] h-full pt-[1.2rem] text-xl inline-block overflow-auto disk-list"},nt={class:"flex items-center flex-col"},ot=["onClick"],it=["title"],rt={class:"h-full w-full inline-block flex w-[59rem]"},ut={class:"flex justify-between bg-light p-[1.2rem] pr-[1.6rem] rounded-base"},ct={class:"ml-[9.6rem]"},pt={key:0,class:"flex align-middle items-center"},ft={class:"bg- rounded-large px-4 h-12 leading-[2.8rem] w-[30rem] inline-block border-light border-1 border-opacity-20 truncate"},dt={class:"flex"},mt=pe({__name:"index",props:{compData:{default:()=>({type:"all",path:"/www/wwwroot",change:()=>{},confirmText:"确认",disabledPath:"",customRequest:!1,disabledCreate:!1,customRequestApi:()=>Promise.resolve({status:!0,data:{}})})}},emits:["close"],setup(T,{expose:H,emit:P}){const q=P,g=T,{type:h,path:F,change:L,disabledCreate:E,disabledPath:o}=g.compData,{error:b,request:c}=ue(),{panel:O}=Fe(),N=a(),A=a(),$=a(0),Q=a(0),he=a(""),J=a(),x=a(h),j=a(!1),U=a(!0),R=a(!1),r=a(F||O.value.sitePath),k=a(F||O.value.sitePath),m=ae([]),z=ae([]),Z=a([]),S=a(""),p=a(),K=a(),X=Je(()=>x.value==="file"?"文件":x.value==="dir"?"文件夹":"文件/文件夹");ne(A,e=>{const t=e[0],{width:s}=t.contentRect;$.value=s}),ne(N,e=>{const t=e[0],{width:s}=t.contentRect;Q.value=s,Q.value>$.value&&(z.value=m.value.slice(-4))});const _e=a([{label:"名称",prop:"name",showOverflowTooltip:!1,render:e=>e.create&&B?i(Ge,{type:e.type,path:r.value,filelist:K,onCreateStatus:()=>{$e()}},null):i("span",{class:"bt-open-dir"},[i("i",{class:"svgtofont".concat(e.type==="dir"?"-icon-file_mode":"-file-text")},null),i("span",{onClick:t=>{e.type==="dir"&&te(e,t)}},[e.name])])},{label:"修改时间",width:160,prop:"mtime"},{label:"权限/所有者",width:125,prop:"accept"}]),ye=({row:e,column:t,rowIndex:s,columnIndex:f})=>{if(s===0&&e.create&&B)return[1,3]},ge=()=>{if(m.value.length===1)return;const e=m.value[m.value.length-2].path;o&&(o==null?void 0:o.indexOf(e))!==-1&&o!==e||(r.value=e,y())},be=()=>{U.value=!1,k.value=r.value},xe=()=>{U.value=!0,setTimeout(()=>{k.value=r.value},1500)},ke=e=>{r.value=k.value,y(),e.preventDefault(),e.target.blur()},we=e=>{r.value!==e&&(o&&(o==null?void 0:o.indexOf(e))!==-1&&o!==e||(r.value=e,k.value=e,y()))},Ce=e=>{e||(e=""),S.value=e,y(!0)};let B=a(!1);const Y=e=>{var t;if(B.value)return!1;B.value=!0,(t=K.value)==null||t.unshift({title:"",name:"",mtime:"",accept:"",type:e,path:"",create:!0})},$e=()=>{B.value=!1,y()},De=e=>{o&&(o==null?void 0:o.indexOf(e))!==-1&&o!==e||(r.value=e,y())},y=async e=>{var t,s;j.value=!0;try{const f=g.compData.customRequest?await((s=(t=g.compData).customRequestApi)==null?void 0:s.call(t,{path:r.value,disk:!0,search:e?S.value:""})):await Ee({path:r.value,disk:!0,search:e?S.value:""});if(p.value&&(p.value.path=r.value,p.value.title=r.value.split("/")[r.value.split("/").length-1]),!f.status)return p.value=void 0,c(f),!1;const{DIR:_,FILES:d,DISK:v,PATH:M}=f.data;Re(M),Z.value=v,K.value=[...ee(_,"dir"),...ee(d)],Be()}catch(f){}finally{j.value=!1}},Re=e=>{let t="";const s=e.replace(/\/*$/,"");if(r.value=s,k.value=s,m.value=[],s===""){m.value.push({title:"根目录",path:"/"}),z.value=m.value;return}s.split("/").forEach((f,_)=>{t+="".concat(_===1?"":"/").concat(f),m.value.push({title:f===""&&_===0?"根目录":f,path:t})}),z.value=m.value},ee=(e,t)=>{const s=[];e.forEach(_=>{const d=_.split(";");let v=d[0];v.length>30&&(v="".concat(v.slice(0,30),"...")),f(v)&&(v="".concat(v.slice(0,16),"...")),s.push({title:d[0],name:v,mtime:Ne(Number(d[2])*1e3,"yyyy/MM/dd HH:mm:ss"),accept:"".concat(d[3]," / ").concat(d[4]),type:t||"file",path:"".concat(r.value,"/").concat(d[0])})});function f(_){return/[\u4E00-\u9FA5\uF900-\uFA2D]/.test(_)}return s},Se=e=>{if(!(!e||e.create)){if(x.value==="all")p.value=e;else{if(e.type!=="dir"&&x.value==="dir"){b("请选择文件夹,否则将无法选择");return}if(e.type!=="file"&&x.value==="file")return;if(x.value!==e.type){p.value=void 0,qe(J.value).setCurrentRow();return}e!==null&&(p.value=e)}R.value=!0}},te=(e,t)=>{e.type!=="dir"||e.create||(x.value==="file"&&(R.value=!1),r.value=e.path,y(),t.stopPropagation&&t.stopPropagation())},Be=()=>{J.value.type==="file"&&(p.value=void 0,R.value=!1),B.value=!1},Ie=()=>{L&&L(p.value.path,p.value.type),he.value=p.value.path,q("close")},Ve=async()=>{await y(),x.value!=="file"&&(p.value=m.value[m.value.length-1],R.value=!0)};return H({onOpen:()=>Ve()}),(e,t)=>{var se;const s=Le,f=Oe,_=Ae,d=ve,v=ze,M=Ke,le=fe("bt-loading");return w(),C("section",null,[l("div",Qe,"选择"+D(u(X)),1),l("div",Ze,[l("div",Xe,[l("i",{title:"返回上一层",class:"bt-open-icon inline-block !rounded-tl-large !rounded-bl-large",onClick:ge},[i(s,{icon:"el-back",class:"leading-[2rem]"})]),l("div",{ref_key:"pathInputRef",ref:A,class:"file-selector-input overflow-hidden"},[u(U)?(w(),C("ul",{key:0,ref_key:"pathRef",ref:N,class:"absolute top-[1px] left-[1px] h-[28px] z-1 flex rounded-none bg-light"},[(w(!0),C(oe,null,ie(u(z),(n,W)=>(w(),C("li",{key:W,class:"flex items-center px-[1rem]",onClick:Te=>we(n.path)},[l("span",et,D(n.title),1),l("i",tt,[i(s,{icon:"el-arrow-right"})])],8,Ye))),128))],512)):re("",!0),i(f,{modelValue:u(k),"onUpdate:modelValue":t[0]||(t[0]=n=>G(k)?k.value=n:null),class:"!w-[400px]",onFocus:be,onBlur:xe,onKeyup:me(ke,["enter"])},null,8,["modelValue"])],512),l("i",{title:"刷新",class:"bt-open-icon inline-block !rounded-tr-large !rounded-br-large",onClick:t[1]||(t[1]=n=>y())},[i(s,{icon:"el-refresh-right",class:"leading-[2rem]"})])]),i(_,{modelValue:u(S),"onUpdate:modelValue":t[2]||(t[2]=n=>G(S)?S.value=n:null),placeholder:"搜索文件/目录",class:"!w-[220px]",onSearch:Ce},null,8,["modelValue"])]),l("div",lt,[i(d,{type:"default",disabled:u(E),onClick:t[3]||(t[3]=n=>Y("File"))},{default:I(()=>[...t[7]||(t[7]=[V("新建文件",-1)])]),_:1},8,["disabled"]),i(d,{type:"default",disabled:u(E),onClick:t[4]||(t[4]=n=>Y("Dir"))},{default:I(()=>[...t[8]||(t[8]=[V("新建文件夹",-1)])]),_:1},8,["disabled"])]),l("div",st,[l("div",at,[l("ul",nt,[(w(!0),C(oe,null,ie(u(Z),(n,W)=>(w(),C("li",{key:W,class:"flex p-[0.8rem] pl-[1.6rem] items-center w-full",onClick:Te=>De(n.path)},[t[9]||(t[9]=l("i",{class:"file-disk-icon mr-[0.8rem] text-base"},null,-1)),l("span",{class:"w-full truncate",title:n.path==="/"?"根目录":n.path},D(n.path==="/"?"根目录":n.path)+" ("+D(n.size[2])+") ",9,it)],8,ot))),128))])]),l("div",rt,[de(i(v,{ref_key:"tableRef",ref:J,"empty-text":"(空)","max-height":"480","highlight-current-row":"",class:"file-selector-table",column:u(_e),data:u(K),"span-method":ye,border:!1,onCurrentChange:Se,onRowDblclick:te},null,8,["column","data"]),[[le,u(j)],[le,"正在加载文件列表,请稍后...","title"]])])]),l("div",ut,[l("div",ct,[u(R)?(w(),C("div",pt,[l("span",null,"当前选中"+D(u(X))+":",1),l("span",ft,D((se=u(p))==null?void 0:se.title),1)])):re("",!0)]),l("span",dt,[i(M,{type:"default",class:"BtButton--cancel",onClick:t[5]||(t[5]=n=>q("close"))},{default:I(()=>[...t[10]||(t[10]=[V(" 取消 ",-1)])]),_:1}),i(M,{type:"primary",disabled:!u(R),onClick:t[6]||(t[6]=n=>Ie())},{default:I(()=>[V(D(T.compData.confirmText||"确认"),1)]),_:1},8,["disabled"])])])])}}}),yt=ce(mt,[["__scopeId","data-v-4cfbe4a0"]]);export{yt as default};