This repository has been archived on 2025-11-03. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
api/app/random-410/route.ts
2025-04-04 13:18:17 +08:00

26 lines
758 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { type NextRequest, NextResponse } from "next/server"
export async function GET(request: NextRequest) {
// 随机选择图片源
const isSourceOne = Math.random() < 0.5 // 50% 概率选择第一个图片源
let randomId: number
let randomImageUrl: string
if (isSourceOne) {
// 第一个图片源,随机数范围为 0-60含60
randomId = Math.floor(Math.random() * 61)
randomImageUrl = `https://zh.yuazhi.cn/at410/random/${randomId}.jpg`
} else {
// 第二个图片源,随机数范围为 0-40含40
randomId = Math.floor(Math.random() * 41)
randomImageUrl = `https://zh.yuazhi.cn/at410/random/2-${randomId}.jpg`
}
// 重定向到随机图片
return NextResponse.redirect(randomImageUrl)
}