← Back
Editing: files-path.js
import{c as e,r as l,k as a,w as t,p as s,a5 as i,q as o,v as n,y as r,J as u,H as c,bq 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,aR as b,aw as C,br as P}from"./base-lib.js?v=1765440387";import{ag as _}from"./files.js?v=1765440387";import{bT as x,q as F,b as j,e as q}from"./utils-lib.js?v=1765440387";const M=["id"],R={class:"path-input"},U={class:"fold-dir-list"},L=["onClick"],T=["onClick"],W={class:"path-name"},A=["onClick"],B={class:"fold-dir-list"},I=["onClick"],z=q(e({__name:"files-path",props:{initialPath:{default:"/www/wwwroot"}},emits:["pathChange","refresh"],setup(e,{expose:q,emit:z}){const E=e,K=z,S=j(),$=l(x(10,"letter")),D=l(E.initialPath),G=l(),H=l(!0),J=l([]),O=l(0),Q=l(!1),V=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 S.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?(S.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(()=>{V.list=[],V.showMore=!1;const e=document.querySelectorAll("#".concat($.value," .path-group-item")),l=document.querySelector("#".concat($.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,V.showMore=!0,V.list=J.value.slice(t+1));V.showMore&&(J.value[0].show=!1,V.list=J.value.slice(1))}},100)})):J.value=[{name:"根目录",path:"/",show:!0,list:[]}]},le=()=>{if(Q.value)return;if(Q.value=!0,"/"===D.value)return Q.value=!1,S.error("当前目录为根目录");let e=D.value.split("/");e.pop();let l=e.join("/");""===l&&(l="/"),Y(l),setTimeout(()=>{Q.value=!1},500)},ae=()=>{V.showUl=!1,J.value[O.value]&&(J.value=J.value.map(e=>({...e,showFold:!1}))),window.removeEventListener("click",ae)},te=async()=>{if(!Q.value){Q.value=!0;try{K("refresh")}catch(e){S.error("刷新失败")}finally{setTimeout(()=>{Q.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()}),q({dirPath:D,refreshList:te,goBack:le,cutDirPath:X,getPathListGroup:ee}),(e,l)=>{const a=b,t=C,s=P;return o(),n("div",{class:"nav-path",id:$.value},[r("div",{class:"back rounded-l-[1rem] relative",onClick:le},[r("i",{class:u(["svgtofont-el-back",{disabledBack:Q.value}])},null,2)]),r("div",R,[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=>V.showUl=!0,["stop"]))},[c(r("ul",U,[(o(!0),n(f,null,m(V.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,L)]),_:2},1032,["content"])]))),128))],512),[[v,V.showUl]])],512),[[v,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",W,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 _({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",B,[(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,I)]),_:2},1032,["content"])]))),128)),c(g(t,{"image-size":60,description:"暂无数据"},null,512),[[v,!e.list.length]])])),[[v,e.showFold],[s,e.loading]])],8,A)],8,T)),[[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":!Q.value,"svgtofont-el-loading cursor-not-allowed animate-spin":Q.value})},null,2)])],8,M)}}}),[["__scopeId","data-v-088794d2"]]);export{z as F};
Save File
Cancel