随机背景 API

Cloudflare Pages 随机背景接口。上传图片后先用 `build.py` 生成序号 `.webp`,然后可通过 `/api/random` 和 `/api/list` 调用。

竖屏:mobile-image 横屏:desketop-image 返回:302 / JSON 组件:widget.js

API 调用

随机图片
默认 302 跳转到随机图片。
GET /api/random
返回 JSON
适合前端自己处理图片地址。
GET /api/random?format=json
强制竖屏
GET /api/random?mode=mobile
强制横屏
GET /api/random?mode=desktop

支持参数:`mode=auto|mobile|desktop`、`orientation=portrait|landscape`、`device=mobile|desktop`、`format=redirect|json`。

在线预览

随机背景预览
{}

嵌入组件

直接引用
<script src="https://random-background-api.pages.dev/widget.js"></script>
<random-background-widget
  src="https://random-background-api.pages.dev"
  blur="12"
  radius="16px"
  height="260px">
</random-background-widget>
说明
组件只读静态 `manifest.json` 和图片,不消耗 Functions 额度;`blur` 控制高斯模糊像素值。