import{d as M,s as E,a as q,b as B,l as I,c as O}from"./admin-storage.1997580a.js";import{S as P}from"./sortable.esm.a99254e8.js";import{u as T}from"./useCommon.eb7f3fe8.js";import{r as n,c as A}from"./index.965ac11d.js";import{u as D}from"./storage-copy.93e6ed15.js";import{E as l}from"./index.0f169a7e.js";import{E as o}from"./request.2ccc188b.js";const{isMobile:_}=T();let C=n(!1),S=n(),i=n(!1),t=n([]),s=n("");const{openDialog:F}=D();function J(r){const v=()=>{r.push("/admin/storage-edit")},u=e=>{r.push("/admin/storage-edit/"+e.id)},d=e=>{l.confirm("\u662F\u5426\u786E\u8BA4\u5220\u9664\uFF1F","\u63D0\u793A",{confirmButtonText:"\u786E\u5B9A",cancelButtonText:"\u53D6\u6D88",type:"warning",callback:a=>{a==="confirm"&&M(e.id).then(c=>{o.success("\u5220\u9664\u6210\u529F"),w()})}})},m=e=>{l.confirm("\u662F\u5426\u786E\u8BA4\u5173\u95ED\uFF1F\u5173\u95ED\u540E\u586B\u5199\u7684\u6570\u636E\u4E0D\u4F1A\u4FDD\u7559\u3002",{type:"warning"}).then(a=>{e()}).catch(a=>{})},g=e=>{r.push("/admin/storage-filter/"+e.id)},h=e=>{r.push("/admin/storage-readme/"+e.id)},f=e=>{r.push("/admin/storage-password/"+e.id)},p=e=>{l.confirm(`\u662F\u5426\u786E\u8BA4${e.enable?"\u505C\u6B62":"\u542F\u7528"}\u5B58\u50A8\u6E90\u3002`,"\u63D0\u793A",{confirmButtonText:"\u786E\u5B9A",cancelButtonText:"\u53D6\u6D88",type:"warning",callback:a=>{if(a==="confirm"){let c=e.enable?"disable":"enable";E(e.id,c).then(()=>{o.success((e.enable?"\u505C\u6B62":"\u542F\u7528")+"\u6210\u529F"),e.enable=!e.enable})}}})},x=e=>{let a=e.enableCache?"enable":"disable";q(e.id,a).then(()=>{o.success("\u4FEE\u6539\u6210\u529F")})},y=e=>{let a=e.autoRefreshCache?"start":"stop";B(e.id,a).then(()=>{o.success("\u4FEE\u6539\u6210\u529F")})},b=e=>{S.value=e.id,C.value=!0},k=e=>{switch(e.operator){case"edit":u(e.storage);break;case"enable":p(e.storage);break;case"readmeManager":h(e.storage);break;case"cacheManager":b(e.storage);break;case"filterManager":g(e.storage);break;case"pwdManager":f(e.storage);break;case"delete":d(e.storage);break;case"copy":F(e.storage);break}},L=()=>{const e=document.querySelector(".storage-container");P.create(e,{draggable:".storage-item",filter:".add-storage-btn",delay:_.value?300:0,onEnd:a=>{if(a.oldIndex===a.newIndex)return;const c=t.value.splice(a.oldIndex,1)[0];t.value.splice(a.newIndex,0,c),O(t.value).then(()=>{o.success("\u8C03\u6574\u6392\u5E8F\u6210\u529F")})}})},w=()=>{i.value=!0,I().then(e=>{t.value=e.data,L(),i.value=!1})},R=A(()=>s.value===""?t.value:t.value.filter(e=>!!(e.name&&e.name.toLowerCase().indexOf(s.value.toLowerCase())!==-1||e.remark&&e.remark.toLowerCase().indexOf(s.value.toLowerCase())!==-1||e.type&&e.type.description.toLowerCase().indexOf(s.value.toLowerCase())!==-1||e.type&&e.type.key.toLowerCase().indexOf(s.value.toLowerCase())!==-1)));return{init:w,loading:i,searchKey:s,storageListSearchResult:R,handleOperator:k,addStorage:v,editStorage:u,deleteStorage:d,handleClose:m,showFilterPage:g,showReadmePage:h,showPasswordPage:f,switchEnableStatus:p,cacheManageVisible:C,currentCacheManageId:S,switchCacheEnableStatus:x,switchCacheAutoRefreshStatus:y,cacheManage:b}}export{J as u};
