PDF需求全面修复 - v1.15
## 后端 1. 数据概览改为从API获取真实用户/订单数 2. 提现API增加容错和withdrawals表自动创建 ## 小程序 1. 设置页:去掉支付宝,微信号直接输入 2. 我的页面:优先显示微信号 3. 找伙伴-资源对接:新增三项填写(能帮到什么/需要什么/擅长什么) ## 部署配置 - 更新为小型宝塔 42.194.232.22
This commit is contained in:
@@ -3,22 +3,39 @@
|
||||
import { useState, useEffect } from "react"
|
||||
import { useRouter } from "next/navigation"
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
|
||||
import { useStore } from "@/lib/store"
|
||||
import { Users, BookOpen, ShoppingBag, TrendingUp, RefreshCw, ChevronRight } from "lucide-react"
|
||||
|
||||
export default function AdminDashboard() {
|
||||
const router = useRouter()
|
||||
const { getAllUsers, getAllPurchases } = useStore()
|
||||
const [mounted, setMounted] = useState(false)
|
||||
const [users, setUsers] = useState<any[]>([])
|
||||
const [purchases, setPurchases] = useState<any[]>([])
|
||||
|
||||
// 从API获取数据
|
||||
async function loadData() {
|
||||
try {
|
||||
// 获取用户数据
|
||||
const usersRes = await fetch('/api/db/users')
|
||||
const usersData = await usersRes.json()
|
||||
if (usersData.success && usersData.users) {
|
||||
setUsers(usersData.users)
|
||||
}
|
||||
|
||||
// 获取订单数据
|
||||
const ordersRes = await fetch('/api/orders')
|
||||
const ordersData = await ordersRes.json()
|
||||
if (ordersData.success && ordersData.orders) {
|
||||
setPurchases(ordersData.orders)
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('加载数据失败', e)
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
setMounted(true)
|
||||
// 客户端加载数据
|
||||
setUsers(getAllUsers())
|
||||
setPurchases(getAllPurchases())
|
||||
}, [getAllUsers, getAllPurchases])
|
||||
loadData()
|
||||
}, [])
|
||||
|
||||
// 防止Hydration错误:服务端渲染时显示加载状态
|
||||
if (!mounted) {
|
||||
|
||||
Reference in New Issue
Block a user