← Back
Editing: files-path.js
import{c as e,r as l,k as a,w as t,p as s,a4 as i,q as o,v as n,y as r,J as u,H as c,bp as h,I as v,Q as d,O as p,F as f,a_ as m,n as w,e as g,A as k,z as y,aQ as b,av as C,bq as _}from"./base-lib.js?v=VERSION_NUMBER";import{ag as P}from"./files.js?v=VERSION_NUMBER";import{bU as x,t as F,b as U,e as j}from"./utils-lib.js?v=VERSION_NUMBER";const M=["id"],q={class:"path-input"},L={class:"fold-dir-list"},R=["onClick"],W=["onClick"],A={class:"path-name"},B=["onClick"],I={class:"fold-dir-list"},T=["onClick"],z=j(e({__name:"files-path",props:{initialPath:{default:"/www/wwwroot"}},emits:["pathChange","refresh"],setup(e,{expose:j,emit:z}){const E=e,K=z,Q=U(),S=l(x(10,"letter")),D=l(E.initialPath),G=l(),H=l(!0),J=l([]),O=l(0),V=l(!1),$=a({showMore:!1,showUl:!1,list:[]}),N=async e=>{if(H.value=e,e){if(D.value===E.initialPath)return;const e=D.value;if(e.length>0&&!e.includes("/"))return Q.error("路径输入不符合规则"),void(D.value=E.initialPath);if(0===e.length)return void(D.value=E.initialPath);try{const l=await Y(e);D.value=l||e}catch(l){D.value=E.initialPath}}else F(G.value)},X=(e,l)=>{var a;""===e&&(D.value="/"),null==(a=G.value)||a.blur(),l||Y(e)},Y=async e=>{const l=e.replace(/\/+$/,"")||"/",a=Z(l);return"/.Recycle_bin"===e||"/www/.Recycle_bin"===e?(Q.error("此为回收站目录,请在右上角按【回收站】按钮打开"),!1):(D.value=a,K("pathChange",a),a)},Z=e=>{let l=e;return l=l.replace(/(\\\/|\/\\)/g,"/"),l=l.replace(/\\\\+/g,"/"),l=l.replace(/\/+/g,"/"),l},ee=e=>{if(!e)return;const l=e.split("/");"/"!==e?(J.value=l.map(((e,a)=>({name:""===e?"根目录":e,path:""===e?"/":l.slice(0,a+1).join("/"),show:!0,showFold:!1,loading:!1,list:[]}))),ae(),w((()=>{$.list=[],$.showMore=!1;const e=document.querySelectorAll("#".concat(S.value," .path-group-item")),l=document.querySelector("#".concat(S.value," .path-list-group")),a=Array.from(e).reduce(((e,l)=>e+l.clientWidth+4),0);setTimeout((()=>{if(a>((null==l?void 0:l.clientWidth)||400)){let a=20;for(let t=e.length-1;t>=0;t--)a+=e[t].clientWidth,a>((null==l?void 0:l.clientWidth)||0)&&(J.value[t].show=!1,$.showMore=!0,$.list=J.value.slice(t+1));$.showMore&&(J.value[0].show=!1,$.list=J.value.slice(1))}}),100)}))):J.value=[{name:"根目录",path:"/",show:!0,list:[]}]},le=()=>{if(V.value)return;if(V.value=!0,"/"===D.value)return V.value=!1,Q.error("当前目录为根目录");let e=D.value.split("/");e.pop();let l=e.join("/");""===l&&(l="/"),Y(l),setTimeout((()=>{V.value=!1}),500)},ae=()=>{$.showUl=!1,J.value[O.value]&&(J.value=J.value.map((e=>({...e,showFold:!1})))),window.removeEventListener("click",ae)},te=async()=>{if(!V.value){V.value=!0;try{K("refresh")}catch(e){Q.error("刷新失败")}finally{setTimeout((()=>{V.value=!1}),500)}}};return t((()=>D.value),(e=>{ee(e)}),{immediate:!0}),t((()=>H.value),(()=>{H.value||w((()=>{var e;null==(e=G.value)||e.select()}))})),t((()=>E.initialPath),(e=>{D.value=e})),s((()=>{ee(D.value)})),i((()=>{ae()})),j({dirPath:D,refreshList:te,goBack:le,cutDirPath:X,getPathListGroup:ee}),(e,l)=>{const a=b,t=C,s=_;return o(),n("div",{class:"nav-path",id:S.value},[r("div",{class:"back rounded-l-[1rem] relative",onClick:le},[r("i",{class:u(["svgtofont-el-back",{disabledBack:V.value}])},null,2)]),r("div",q,[c(r("input",{"onUpdate:modelValue":l[0]||(l[0]=e=>D.value=e),ref_key:"pathInputRef",ref:G,type:"text",class:"h-full w-full pl-8px",onBlur:l[1]||(l[1]=e=>N(!0)),onKeydown:l[2]||(l[2]=d((()=>{}),["stop"])),onKeyup:l[3]||(l[3]=p((e=>X(D.value,!0)),["enter"]))},null,544),[[h,D.value],[v,!H.value]]),c(r("div",{class:"path-list-group",onClick:l[5]||(l[5]=e=>N(!1))},[c(r("div",{class:"svgtofont-el-arrow-left font-bold px-[.2rem] h-full leading-[2.9rem] cursor-pointer border-l border-r border-white relative hover:border-#e1e1e1 hover:bg-[#f5f7fa]",onClick:l[4]||(l[4]=d((e=>$.showUl=!0),["stop"]))},[c(r("ul",L,[(o(!0),n(f,null,m($.list,((e,t)=>(o(),n("li",{class:"fold-dir-item",key:t},[g(a,{effect:"dark",content:e.path,placement:"right","show-after":500},{default:k((()=>[r("div",{class:"w-full flex items-center",onClick:d((l=>X(e.path)),["stop"])},[l[6]||(l[6]=r("span",{class:"dir-icon flex-shrink-0 !h-[1.6rem]"},null,-1)),r("span",null,y(e.name),1)],8,R)])),_:2},1032,["content"])])))),128))],512),[[v,$.showUl]])],512),[[v,$.showMore]]),(o(!0),n(f,null,m(J.value,((e,i)=>c((o(),n("div",{key:i,class:"path-group-item",onClick:d((l=>X(e.path)),["stop"])},[g(a,{effect:"dark",content:e.name,placement:"bottom","show-after":500},{default:k((()=>[r("span",A,y(e.name),1)])),_:2},1032,["content"]),r("div",{class:"svgtofont-el-arrow-right path-name-icon",onClick:d((l=>(async(e,l)=>{try{ae(),J.value[l].showFold=!0,J.value[l].loading=!0;const{data:{dir:a}}=await P({path:e,p:1,showRow:2e3});J.value[l].loading=!1,J.value[l].list=a.map((l=>({name:l.nm,path:"".concat(e,"/").concat(l.nm).replace(/\/+/g,"/")}))),O.value=l,window.addEventListener("click",ae)}catch(a){J.value[l].loading=!1}})(e.path,i)),["stop"])},[c((o(),n("ul",I,[(o(!0),n(f,null,m(e.list,((e,t)=>(o(),n("li",{class:"fold-dir-item",key:t},[g(a,{effect:"dark",content:e.path,placement:"right","show-after":500},{default:k((()=>[r("div",{class:"w-full flex items-center",onClick:d((l=>X(e.path)),["stop"])},[l[7]||(l[7]=r("span",{class:"dir-icon flex-shrink-0 !h-[1.6rem]"},null,-1)),r("span",null,y(e.name),1)],8,T)])),_:2},1032,["content"])])))),128)),c(g(t,{"image-size":60,description:"暂无数据"},null,512),[[v,!e.list.length]])])),[[v,e.showFold],[s,e.loading]])],8,B)],8,W)),[[v,e.show]]))),128))],512),[[v,H.value]])]),r("span",{class:"refresh rounded-r-[1rem]",onClick:te},[r("i",{class:u({"svgtofont-el-refresh-right":!V.value,"svgtofont-el-loading cursor-not-allowed animate-spin":V.value})},null,2)])],8,M)}}}),[["__scopeId","data-v-088794d2"]]);export{z as F};
Save File
Cancel