home/js/set.min.js
2022-05-04 17:19:19 +08:00

1 line
1.9 KiB
JavaScript

function setBgImg(a){return!!a&&(Cookies.set("bg_img",a,{expires:36500}),!0)}function getBgImg(){var a=Cookies.get("bg_img");return a&&"{}"!==a?JSON.parse(a):(setBgImg(bg_img_preinstall),bg_img_preinstall)}function setBgImgInit(){var a=getBgImg();switch($("input[name='wallpaper-type'][value="+a.type+"]").click(),a.type){case"1":var g=new Array;g[0]="./img/background1.webp",g[1]="./img/background2.webp",g[2]="./img/background3.webp",g[3]="./img/background4.webp",g[4]="./img/background5.webp",g[5]="./img/background6.webp",g[6]="./img/background7.webp",g[7]="./img/background8.webp",g[8]="./img/background9.webp",g[9]="./img/background10.webp";var i=Math.floor(10*Math.random());$("#bg").attr("src",g[i]);break;case"2":$("#bg").attr("src","https://api.dujin.org/bing/1920.php");break;case"3":$("#bg").attr("src","https://api.ixiaowai.cn/gqapi/gqapi.php");break;case"4":$("#bg").attr("src","https://api.ixiaowai.cn/api/api.php")}}var bg_img_preinstall={type:"1",path:""};$(document).ready(function(){setBgImgInit(),$("#wallpaper").on("click",".set-wallpaper",function(){var a=$(this).val(),g=getBgImg();if(g.type=a,"1"===a){setBgImg(g);var i=new Array;i[0]="./img/background1.webp",i[1]="./img/background2.webp",i[2]="./img/background3.webp",i[3]="./img/background4.webp",i[4]="./img/background5.webp",i[5]="./img/background6.webp",i[6]="./img/background7.webp",i[7]="./img/background8.webp",i[8]="./img/background9.webp",i[9]="./img/background10.webp";var e=Math.floor(10*Math.random());$("#bg").attr("src",i[e]),iziToast.show({message:"壁纸设置成功"})}"2"===a&&(setBgImg(g),$("#bg").attr("src","https://api.dujin.org/bing/1920.php"),iziToast.show({message:"壁纸设置成功"})),"3"===a&&(setBgImg(g),$("#bg").attr("src","https://api.ixiaowai.cn/gqapi/gqapi.php"),iziToast.show({message:"壁纸设置成功"})),"4"===a&&(setBgImg(g),$("#bg").attr("src","https://api.ixiaowai.cn/api/api.php"),iziToast.show({message:"壁纸设置成功"}))})});