import{r as l,u as e,a,b as t,c as s,d as o,F as c,f as i,g as u,h as r,n,x as d,T as m,k as f,j as v,H as p,p as g,q as b,m as h,av as y,aY as x,J as k,a1 as w,L as _,B as j}from"./index.51eb0e02.1749480002384.js";const C={class:"background-addBox"},W={class:"bg-left flex flex-col relative"},z={class:"netBG space-y-3 pr-1 pl-4 pb-4 overflow-y-scroll relative h-full w-full"},B=["onClick"],F={key:0,class:"flex-1 p-4 pt-0 grid grid-cols-1 xs:grid-cols-4 gap-3",style:{"grid-template-rows":"max-content"}},H={style:{"aspect-ratio":"16 / 10"},class:"relative overflow-hidden rounded-md"},I=["onLoad","src"],L={class:"absolute rounded-lg opacity-0 transition-all hover:opacity-100 inset-0 w-full h-full flex justify-center items-center",style:{"background-color":"rgba(0, 0, 0, 0.178)"}},V=["onClick"],S={key:0,class:"absolute z-10 right-0 bottom-0 w-full h-8 flex"},T=["href"],q={key:2,class:"absolute inset-0 w-full h-full z-10 bg-white bg-opacity-20 flex justify-center items-center text-white"},G={key:1,class:"flex align-center justify-center"},J={class:"p-4 pt-0"},M={class:"flex gap-x-4 msm:flex-col msm:gap-y-3"},U={key:0,class:"mt-4"},Y=["src"],A={__name:"index",setup(A){const D=l(""),E=l(!1),K=l([]),N=e(),O=l([]),P=l(),Q=l=>{E.value=!1,P.value=l.id,Z=0,R=!1,O.value=[],tl()};let R=!1;const X=l=>{N.state.config.theme.backgroundImage=l.url,N.state.config.theme.backgroundMime=l.mime,N.commit("updateConfig")};let Z=0;const $=l=>{const{target:e}=l;R||e.scrollTop+e.clientHeight>=e.scrollHeight-100&&(R=!0,Z+=1,tl())},ll=l=>{1===l.code?D.value=l.data.url:_.warning(l.msg)},el=()=>{X({url:D.value,mime:0})},al=l(!1),tl=async()=>{al.value=!0;try{const l=await j({url:"/Wallpaper/getFolderWallpaperClient",method:"post",data:{id:P.value,offset:Z}});if(al.value=!1,1===l.code){if(0===l.data.length)return void(R=!0);O.value.push(...l.data)}}catch(l){}R=!1};return(async()=>{const l=await j({url:"/Wallpaper/getFolderClient"});1===l.code&&(K.value=l.data,K.value.length>0&&Q(K.value[0]))})(),(l,e)=>{const _=a("el-icon"),j=a("el-empty"),A=a("el-input"),R=a("el-button"),Z=a("el-upload");return t(),s("div",C,[o("div",W,[e[3]||(e[3]=o("div",{class:"mt-3 mb-1"},null,-1)),o("div",z,[(t(!0),s(c,null,i(K.value,((l,e)=>(t(),u(m,{key:e},{default:r((()=>[o("div",{onClick:e=>Q(l),class:n({selectWallpaperItem:P.value===l.id&&!E.value})},[o("span",null,d(l.name),1)],10,B)])),_:2},1024)))),128))]),o("div",{class:n(["custom absolute text-black flex items-center cursor-pointer bottom-4 left-4",{selectWallpaperItem:E.value}]),onClick:e[0]||(e[0]=l=>E.value=!0)},[f(_,null,{default:r((()=>[f(v(p))])),_:1}),e[2]||(e[2]=o("span",{class:"ml-1 text-xs"},"自定义壁纸",-1))],2)]),E.value?h("",!0):(t(),s("div",{key:0,class:"bg-right overflow-scroll",onScroll:$},[O.value.length?(t(),s("div",F,[(t(!0),s(c,null,i(O.value,(l=>(t(),u(m,null,{default:r((()=>[o("div",H,[[0,1].includes(l.mime)?(t(),s("img",{key:0,style:g({opacity:l.load?1:0,transition:"opacity 0.5s"}),class:"rounded-md w-full h-full object-cover",onLoad:e=>l.load=!0,src:v(b)(l.cover),alt:""},null,44,I)):h("",!0),2===l.mime?(t(),s("div",{key:1,class:"rounded-lg object-cover w-full h-full bg-gray-200",style:g({background:l.url})},null,4)):h("",!0),o("div",L,[o("div",{onClick:e=>X(l),class:"transition-all cursor-pointer bg-black bg-opacity-40 hover:opacity-100 hover:bg-blue-500 rounded-full flex justify-center items-center w-10 h-10"},[f(_,{size:"28px",color:"#fff"},{default:r((()=>[f(v(y))])),_:1})],8,V),[0,1].includes(l.mime)?(t(),s("div",S,[o("a",{target:"_blank",download:"background",href:v(b)(l.url),class:"ml-auto transition-all cursor-pointer mr-2 hover:bg-blue-500 rounded-full w-6 mb-2 flex justify-center items-center"},[f(_,{size:"18px",color:"#fff"},{default:r((()=>[f(v(x))])),_:1})],8,T)])):h("",!0)]),!l.load&&[0,1].includes(l.mime)?(t(),s("div",q," 加载中 ")):h("",!0)])])),_:2},1024)))),256))])):h("",!0),al.value||0!==O.value.length?h("",!0):(t(),s("div",G,[f(j,{class:"m-20"})]))],32)),E.value?(t(),s("div",{key:1,class:"bg-right overflow-scroll",onScroll:$},[o("div",J,[e[7]||(e[7]=o("div",{class:"text-base text-black"},"使用在线图片链接地址",-1)),e[8]||(e[8]=o("div",{class:"text-sm mt-2 mb-4"},"没有登录或有条件的用户请选择使用图床作为壁纸储存",-1)),o("div",M,[f(A,{modelValue:D.value,"onUpdate:modelValue":e[1]||(e[1]=l=>D.value=l),placeholder:"请粘贴/填写网络图片地址"},null,8,["modelValue"]),f(Z,{class:"upload-demo msm:w-full","show-file-list":!1,"on-success":ll,headers:l.head,action:v(w)+v(N).state.site.upload},{default:r((()=>[f(R,{type:"danger",class:"msm:w-full"},{default:r((()=>e[4]||(e[4]=[k("手动上传")]))),_:1})])),_:1},8,["headers","action"])]),f(R,{class:"mt-4 w-full",type:"primary",onClick:el},{default:r((()=>e[5]||(e[5]=[k("保存")]))),_:1}),D.value?(t(),s("div",U,[e[6]||(e[6]=o("div",null,"壁纸预览",-1)),o("img",{class:"mt-2",src:v(b)(D.value),style:{"max-height":"400px","max-width":"500px","border-radius":"12px","object-fit":"cover"}},null,8,Y)])):h("",!0)])],32)):h("",!0)])}}};export{A as default};
