使用Cloudflare Workers搭建一个随机图片 建站/ 三月 08, 2022 DEMO站:pic.chzi.workers.devbing壁纸:下载榜 | 必应每日高清壁纸 https://bing.ioliu.cn/ranking必应壁纸|必应美图 https://www.todaybing.com/进入网站https://dash.cloudflare.com/部署 Workers代码(可把图片地址改为自己的) addEventListener('fetch', event => { event.respondWith(handleRequest(event.request)) }) async function handleRequest(request) { var background_urls = [ 'http://www.deskcar.com/desktop/fengjing/20171023164701/3.jpg', 'https://clubimg.club.vmall.com/data/attachment/forum/201904/28/004826yv5kwjmkuxjmvqtk.jpg', 'http://www.desktx.com/d/file/wallpaper/scenery/20161124/48f14418f4b9e5f8da850050bd78c6e3.jpg', 'http://i.52desktop.cn:81/upimg/allimg/20191204/2019124152146593778046.jpg', 'http://i.52desktop.cn:81/upimg/allimg/20170412/2017412134457671778035.jpg', 'https://uploadfile.bizhizu.cn/up/03/10/2b/03102b6dca75ddeca7af4f24d63b8fdc.jpg', 'https://uploadfile.bizhizu.cn/up/03/10/2b/03102b6dca75ddeca7af4f24d63b8fdc.jpg' /*需要随机到的图片的链接*/ ] var index = Math.floor((Math.random()*background_urls.length)); res = await fetch(background_urls[index]) return new Response(res.body, { headers: { 'content-type': 'image/jpeg' }, }) } Copy Facebook twitter Google 相关日志 Komentar di nonaktifkan Komentar membutuhkan javascript