import Page from '@/components/page'
import Image from 'next/image'
import {Card, CardContent, CardHeader, CardTitle} from '@/components/ui/card'
import {format} from 'date-fns'
import {merge} from '@/lib/utils'
import banner from './_assets/banner.webp'
import {listInitialization} from '@/actions/dashboard'
import Charts from './_client/charts'
import UserCenter from './_client/userCenter'
import soon from './_assets/coming-soon.svg'
import mask from './_assets/Mask group.webp'
export type DashboardPageProps = {}
export default async function DashboardPage(props: DashboardPageProps) {
const resp = await listInitialization()
console.log(resp, 'respresprespresprespresp')
if (!resp.success) {
return (
获取公告数据失败
)
}
const initData = resp.data
// 添加模拟的 usage 数据(如果 API 返回的 usage 为 null)
// if (!initData.usage) {
// initData.usage = [
// {time: new Date('2025-03-01'), count: 100, count2: 80},
// {time: new Date('2025-03-02'), count: 150, count2: 120},
// {time: new Date('2025-03-03'), count: 80, count2: 64},
// {time: new Date('2025-03-04'), count: 200, count2: 160},
// {time: new Date('2025-03-05'), count: 120, count2: 96},
// ]
// }
return (
{/* banner */}
代理IP资源,先测后买
短效/长效/固定IP代理,一站式服务
{/* 磁贴集 */}
{initData && (
)}
{/* 图表 */}
{/* 信息 */}
{/* 通知 */}
)
}
type DashboardChartProps = {
short_term: string
short_term_monthly: string
long_term: string
long_term_monthly: string
}
function Pins(props: DashboardChartProps) {
return (
{/* 短效 */}
短效动态套餐
包时
当日可提取数量
{props.short_term}
包量
剩余可提取数量
{props.short_term_monthly}
{/* 长效 */}
长效动态套餐
包时
当日可提取数量
{props.long_term}
包量
剩余可提取数量
{props.long_term_monthly}
{/* 固定 */}
固定IP套餐
敬请期待
)
}
type Props = {
list: {
id: number
title: string
created_at: Date
} []
}
function Announcements(props: Props) {
return (
公告
查看更多
{!props.list.length
? (
)
: props.list.map(item => (
{item.title}
{format(item.created_at, 'yyyy-MM-dd HH:mm')}
))}
)
}