import{u as te,r as v,s as le,A as $,n as p,b as m,d as ne,h as oe,o as re,e as ae,f as l,w as o,g as y,t as g,j as W,G as se,i as ie,q as ue}from"./index.js";import{c as de,t as pe,r as ce}from"./common.js";import{U as fe}from"./constants.js";import{_ as me}from"./_plugin-vue_export-helper.js";const ge=["element-loading-text","element-loading-background"],_e={__name:"WebLink",props:{isupload:{type:Number,default:!1},domain:{type:String,default:""}},setup(K){const u=K,{t:_}=te({useScope:"global"}),w=v(!1),A=v(null),I=v([]),C=v(""),k=v(null),L=v(1),x=v(1);let r="order by f_id desc",D=" 1=1 ",R="",b="";le(()=>{h(1),z()});function z(){w.value=!0,$.post("service_get_weblink_baseurl.html",`domain=${u.domain}&r=${Math.random()}`).then(({data:{code:e,data:t,error:n}})=>{e==0?b=t:e===-1?(p({message:n,grouping:!0,type:"error"}),$.logout()):p({message:n,grouping:!0,type:"error"})}).catch(e=>{p({message:e.message,grouping:!0,type:"error"})}).finally(()=>{w.value=!1})}function P(e){e.prop=="id"?e.order=="ascending"?r="order by f_id asc":r="order by f_id desc":e.prop=="weblink"?e.order=="ascending"?r="order by f_weblink asc":r="order by f_weblink desc":e.prop=="username"?e.order=="ascending"?r="order by f_username asc":r="order by f_username desc":e.prop=="time"?e.order=="ascending"?r="order by f_update_time asc":r="order by f_update_time desc":e.prop=="filename"?e.order=="ascending"?r="order by f_filename asc":r="order by f_filename desc":e.prop=="count"?e.order=="ascending"?r="order by f_count asc":r="order by f_count desc":e.prop=="expired"&&(e.order=="ascending"?r="order by f_expire_time asc":r="order by f_expire_time desc"),R=D+r,x.value=1,h(1)}function q(e){k.value=e}function F(e){w.value=!0,$.post("service_delete_weblink.html",`weblinks=${encodeURIComponent(e)}&is_uplink=${u.isupload}&r=${Math.random()}`).then(({data:{code:t,data:n,error:d}})=>{t==0?h(1):t===-1?(p({message:d,grouping:!0,type:"error"}),$.logout()):p({message:d,grouping:!0,type:"error"})}).catch(t=>{p({message:t.message,grouping:!0,type:"error"})}).finally(()=>{w.value=!1}),M()}function G(){let e="";if(A.value.getSelectionRows().forEach(t=>{e!=""&&(e+="||"),e+=t.weblink}),e==""&&k.value!=null&&(e=k.value.weblink),e==""){p({message:_("str_norow_tip"),grouping:!0,type:"error"});return}ue.confirm(_("str_delweblinks_tip"),"",{confirmButtonText:_("button_submit"),cancelButtonText:_("button_cancel"),type:"warning"}).then(()=>{F(e)}).catch(()=>{})}function M(){x.value=1,h(1)}function j(e){e.code==="Enter"&&O()}function O(){let e=pe(C.value.replace(/\'/g,"").replace(/\"/g,"").replace(/\*/g,"%"));if(e!=""){u.isupload=="1"&&e.charAt(0)=="/"&&(e=e.substr(1));var t=C.value.charAt(0),n=ce(C.value,1);(t=="'"||t=='"')&&(n=="'"||n=='"')?D=" 1=1 and (f_weblink = '"+e+"' or f_filename = '"+e+"' or f_username = '"+e+"') ":D=" 1=1 and (f_weblink like '%"+e+"%' or f_filename like '%"+e+"%' or f_username like '%"+e+"%') "}else D=" 1=1 ";R=D+r,x.value=1,h(1)}function H(){A.value.toggleAllSelection()}function Q(){let e="";if(window.location.hostname!="127.0.0.1"&&b.lastIndexOf("127.0.0.1")!=-1&&(b=b.replace(/127.0.0.1/g,window.location.hostname)),A.value.getSelectionRows().forEach(n=>{e!=""&&(e+=`
`),u.isupload=="1"?e+=b+"uploadlink.html?linkid="+n.weblink:e+=b+"main.html?download&weblink="+n.weblink}),e==""&&k.value!=null&&(u.isupload=="1"?e+=b+"uploadlink.html?linkid="+k.value.weblink:e+=b+"main.html?download&weblink="+k.value.weblink),e==""){p({message:_("str_norow_tip"),grouping:!0,type:"error"});return}if(window.clipboardData)window.clipboardData.setData("Text",e);else if(navigator.userAgent.indexOf("Safari")&&navigator.userAgent.indexOf("Chrome")==-1){let n=document.createElement("input");n.setAttribute("readonly","readonly"),n.setAttribute("value",e),document.body.appendChild(n),n.select(),document.execCommand("copy")&&document.execCommand("copy"),document.body.removeChild(n)}else{var t=function(n){n.preventDefault(),n.clipboardData&&n.clipboardData.setData("text/plain",e)};window.addEventListener("copy",t),document.execCommand("copy"),window.removeEventListener("copy",t)}}function h(e){w.value=!0,$.post("service_get_weblink.html",`domain=${u.domain}&page=${e}&filters=${encodeURIComponent(R)}&is_uplink=${u.isupload}&r=${Math.random()}`).then(({data:{code:t,data:n,error:d}})=>{if(t==0){let S=[],f=n.split(`
`);L.value=parseInt(f[0]);let U=parseInt(f[1]);for(var c=2;c<f.length;c++)if(f[c]!=""&&f[c]!=" "){let i=f[c].split("||"),T=i[0],a=i[1],J=i[3],X=i[6],Z=i[7],B=i[8],ee=i[9];u.isupload=="1"&&B.substr(0,1)!="/"&&(B="/"+i[8]);let E="",N="";try{var s=i[13].replace("|","");s!="-1"&&(N=_("str_expire_on")+": "+de(new Date(s*1e3+new Date().getTimezoneOffset()*60*1e3)),s<U?E=_("str_yes"):E=_("str_no"))}catch{}S.push({id:T,weblink:a,username:J,time:X,filename:B,filepath:ee,count:Z,expired:E,expiretime:N})}I.value=S}else t===-1&&(p({message:d,grouping:!0,type:"error"}),$.logout())}).catch(t=>{p({message:t.message,grouping:!0,type:"error"})}).finally(()=>{w.value=!1})}function Y(e){h(e)}return(e,t)=>{const n=m("el-button"),d=m("el-col"),c=m("el-row"),s=m("el-table-column"),S=m("el-text"),f=m("el-popover"),U=m("el-table"),V=m("el-pagination"),i=m("el-input"),T=ne("loading");return oe((re(),ae("div",{"element-loading-text":e.$t("title_updating"),"element-loading-background":ie(fe)},[l(c,{gutter:5},{default:o(()=>[l(d,{xs:12,sm:7,class:"mb-10"},{default:o(()=>[l(n,{type:"primary",class:"w-100",onClick:t[0]||(t[0]=a=>H())},{default:o(()=>[y(g(e.$t("str_chkbox_select")),1)]),_:1})]),_:1}),l(d,{xs:12,sm:5,class:"mb-10"},{default:o(()=>[l(n,{type:"primary",class:"w-100",onClick:t[1]||(t[1]=a=>G())},{default:o(()=>[y(g(e.$t("button_delete")),1)]),_:1})]),_:1}),l(d,{xs:12,sm:5,class:"mb-10"},{default:o(()=>[l(n,{type:"primary",class:"w-100",onClick:t[2]||(t[2]=a=>M())},{default:o(()=>[y(g(e.$t("button_refresh")),1)]),_:1})]),_:1}),l(d,{xs:12,sm:5,class:"mb-10"},{default:o(()=>[l(n,{type:"primary",class:"w-100",onClick:t[3]||(t[3]=a=>Q())},{default:o(()=>[y(g(e.$t("button_copy")),1)]),_:1})]),_:1})]),_:1}),l(U,{class:"weblink_table_container",border:"",data:I.value,"table-layout":"auto",onSortChange:P,"highlight-current-row":"",onCurrentChange:q,ref_key:"tableRef",ref:A},{default:o(()=>[l(s,{fixed:"",type:"selection"}),l(s,{prop:"id",label:e.$t("title_id"),sortable:"custom","sort-orders":["ascending","descending"]},null,8,["label"]),l(s,{prop:"weblink",label:e.$t("str_weblink"),sortable:"custom","sort-orders":["ascending","descending"]},null,8,["label"]),l(s,{prop:"username",label:e.$t("title_username"),sortable:"custom","sort-orders":["ascending","descending"]},null,8,["label"]),l(s,{prop:"time",label:e.$t("str_modify_date"),sortable:"custom","sort-orders":["ascending","descending"]},null,8,["label"]),l(s,{prop:"filename",label:u.isupload=="1"?e.$t("title_directory"):e.$t("str_filename"),sortable:"custom","sort-orders":["ascending","descending"]},{default:o(a=>[l(f,{effect:"light",trigger:"hover",placement:"top",width:"auto"},{default:o(()=>[W("div",null,g(a.row.filepath),1)]),reference:o(()=>[l(S,null,{default:o(()=>[y(g(a.row.filename),1)]),_:2},1024)]),_:2},1024)]),_:1},8,["label"]),l(s,{prop:"count",label:u.isupload=="1"?e.$t("str_total_upload"):e.$t("str_total_download"),sortable:"custom","sort-orders":["ascending","descending"]},null,8,["label"]),l(s,{prop:"expired",label:e.$t("str_expired"),sortable:"custom","sort-orders":["ascending","descending"]},{default:o(a=>[l(f,{effect:"light",trigger:"hover",placement:"top",width:"auto"},{default:o(()=>[W("div",null,g(a.row.expiretime),1)]),reference:o(()=>[l(S,null,{default:o(()=>[y(g(a.row.expired),1)]),_:2},1024)]),_:2},1024)]),_:1},8,["label"])]),_:1},8,["data"]),l(c,null,{default:o(()=>[l(V,{class:"mt-10 horizontal-center","page-size":50,"page-count":L.value,"current-page":x.value,"onUpdate:currentPage":t[4]||(t[4]=a=>x.value=a),onCurrentChange:Y,layout:"prev, pager, next"},null,8,["page-count","current-page"])]),_:1}),l(c,{class:"ml-10",gutter:5},{default:o(()=>[l(d,{sm:12,class:"mb-10"},{default:o(()=>[l(i,{modelValue:C.value,"onUpdate:modelValue":t[6]||(t[6]=a=>C.value=a),clearable:"",onKeydown:se(j,["enter"])},{append:o(()=>[l(n,{onClick:t[5]||(t[5]=a=>O())},{default:o(()=>[y(g(e.$t("button_search")),1)]),_:1})]),_:1},8,["modelValue"])]),_:1})]),_:1})],8,ge)),[[T,w.value]])}}},he=me(_e,[["__scopeId","data-v-fd71483a"]]);export{he as W};
