chore: 移除og支持
This commit is contained in:
@@ -1,80 +0,0 @@
|
||||
import { db } from "@/app/server/db"
|
||||
import { redPackets } from "@/app/server/schema/red-packet"
|
||||
import { ImageResponse } from "@vercel/og"
|
||||
import { eq } from "drizzle-orm"
|
||||
import { NextRequest } from "next/server"
|
||||
|
||||
export const runtime = "edge" // 使用 Edge Runtime 加快生成速度
|
||||
|
||||
export async function GET(req: NextRequest) {
|
||||
try {
|
||||
const { searchParams } = new URL(req.url)
|
||||
const id = searchParams.get("id")
|
||||
if (!id) return new Response("Missing red packet ID", { status: 400 })
|
||||
|
||||
// 查询红包信息
|
||||
const packet = (await db
|
||||
.select()
|
||||
.from(redPackets)
|
||||
.where(eq(redPackets.id, id))
|
||||
.limit(1))[0]
|
||||
|
||||
if (!packet) return new Response("Red packet not found", { status: 404 })
|
||||
|
||||
// 生成规则文字
|
||||
let ruleText = ""
|
||||
const rule = packet.rule as any
|
||||
if (rule.type === "fixed") {
|
||||
ruleText = `固定金额 ${rule.singleAmount} ${packet.currencyName}`
|
||||
} else if (rule.type === "random") {
|
||||
ruleText = `随机金额 ${rule.min} ~ ${rule.max} ${packet.currencyName}`
|
||||
} else if (rule.type === "luck") {
|
||||
ruleText = `拼手气,总额 ${rule.total} ${packet.currencyName}`
|
||||
}
|
||||
|
||||
return new ImageResponse(
|
||||
(
|
||||
<div
|
||||
style={{
|
||||
width: "1200px",
|
||||
height: "630px",
|
||||
background: "linear-gradient(180deg, #FF4D4F 0%, #FF7875 100%)",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
fontFamily: "sans-serif",
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
fontSize: 80,
|
||||
color: "white",
|
||||
fontWeight: "bold",
|
||||
marginBottom: 20,
|
||||
}}
|
||||
>
|
||||
🎁 tonesc 红包
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
fontSize: 40,
|
||||
color: "#FFD666",
|
||||
marginBottom: 40,
|
||||
}}
|
||||
>
|
||||
{ruleText}
|
||||
</div>
|
||||
{/* 卡通红包图标 */}
|
||||
<div style={{ fontSize: 120 }}>🧧</div>
|
||||
</div>
|
||||
),
|
||||
{
|
||||
width: 1200,
|
||||
height: 630,
|
||||
}
|
||||
)
|
||||
} catch (e) {
|
||||
return new Response("Failed to generate image", { status: 500 })
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user