refactor: Consolidate configuration management with Zustand store

This commit is contained in:
beilunyang
2025-03-01 10:29:50 +08:00
parent b1d898e298
commit ea7fd5490c
12 changed files with 110 additions and 129 deletions

View File

@@ -1,12 +0,0 @@
import { getRequestContext } from "@cloudflare/next-on-pages"
export const runtime = "edge"
export async function GET() {
const env = getRequestContext().env
const adminContact = await env.SITE_CONFIG.get("ADMIN_CONTACT")
return Response.json({
adminContact: adminContact || ""
})
}

View File

@@ -15,7 +15,7 @@ export async function GET() {
return Response.json({
defaultRole: defaultRole || ROLES.CIVILIAN,
emailDomains: emailDomains || "",
emailDomains: emailDomains || "moemail.app",
adminContact: adminContact || "",
maxEmails: maxEmails || EMAIL_CONFIG.MAX_ACTIVE_EMAILS.toString()
})

View File

@@ -1,18 +0,0 @@
import { getRequestContext } from "@cloudflare/next-on-pages"
import { NextResponse } from "next/server"
export const runtime = "edge"
export async function GET() {
try {
const domainString = await getRequestContext().env.SITE_CONFIG.get("EMAIL_DOMAINS")
return NextResponse.json({ domains: domainString ? domainString.split(',') : ["moemail.app"] })
} catch (error) {
console.error('Failed to fetch domains:', error)
return NextResponse.json(
{ error: "获取域名列表失败" },
{ status: 500 }
)
}
}