feat: Implement OpenAPI with API Key authentication and role-based access control

This commit is contained in:
beilunyang
2025-02-10 11:25:25 +08:00
parent 1bc0369b83
commit 9ad3115833
28 changed files with 2339 additions and 144 deletions
+38
View File
@@ -0,0 +1,38 @@
"use client"
import { useState, useEffect } from "react"
import { useToast } from "@/components/ui/use-toast"
export function useAdminContact() {
const [adminContact, setAdminContact] = useState("")
const [loading, setLoading] = useState(true)
const { toast } = useToast()
const fetchAdminContact = async () => {
try {
const res = await fetch("/api/admin-contact")
if (!res.ok) throw new Error("获取管理员联系方式失败")
const data = await res.json() as { adminContact: string }
setAdminContact(data.adminContact)
} catch (error) {
console.error(error)
toast({
title: "获取失败",
description: "获取管理员联系方式失败",
variant: "destructive"
})
} finally {
setLoading(false)
}
}
useEffect(() => {
fetchAdminContact()
}, [])
return {
adminContact,
loading,
refreshAdminContact: fetchAdminContact
}
}