添加密码登录&调整接口数据展示&配置底部导航跳转
This commit is contained in:
@@ -12,7 +12,7 @@ import zod from 'zod'
|
||||
import {merge} from '@/lib/utils'
|
||||
import {Button} from '@/components/ui/button'
|
||||
import {useState} from 'react'
|
||||
import {listAccount} from '@/actions/dashboard'
|
||||
import {statisticsResourceUsage} from '@/actions/dashboard'
|
||||
import {ExtraResp} from '@/lib/api'
|
||||
import {toast} from 'sonner'
|
||||
import {addDays, format} from 'date-fns'
|
||||
@@ -20,19 +20,13 @@ import {Label} from '@/components/ui/label'
|
||||
import {ChartConfig, ChartContainer} from '@/components/ui/chart'
|
||||
import {CartesianGrid, XAxis, YAxis, Tooltip, Area, AreaChart, Legend} from 'recharts'
|
||||
|
||||
type ChartDataItem = {
|
||||
date: string
|
||||
count: number
|
||||
count2?: number
|
||||
}
|
||||
|
||||
type ChartsProps = {
|
||||
initialData?: ExtraResp<typeof listAccount>
|
||||
initialData?: ExtraResp<typeof statisticsResourceUsage>
|
||||
}
|
||||
|
||||
export default function Charts({initialData}: ChartsProps) {
|
||||
// const [submittedData, setSubmittedData] = useState<ExtraReq<typeof listAccount>>()
|
||||
const [submittedData, setSubmittedData] = useState<ExtraResp<typeof listAccount>>(initialData || [])
|
||||
const [submittedData, setSubmittedData] = useState<ExtraResp<typeof statisticsResourceUsage>>(initialData || [])
|
||||
const formSchema = zod.object({
|
||||
resource_no: zod.string().optional(),
|
||||
create_after: zod.date().optional(),
|
||||
@@ -58,7 +52,7 @@ export default function Charts({initialData}: ChartsProps) {
|
||||
create_before: value.create_before ?? today,
|
||||
}
|
||||
|
||||
const resp = await listAccount(res)
|
||||
const resp = await statisticsResourceUsage(res)
|
||||
if (!resp.success) {
|
||||
toast.error('接口请求失败:' + resp.message)
|
||||
return
|
||||
@@ -149,7 +143,7 @@ const config = {
|
||||
} satisfies ChartConfig
|
||||
|
||||
type DashboardChartProps = {
|
||||
data: ExtraResp<typeof listAccount>
|
||||
data: ExtraResp<typeof statisticsResourceUsage>
|
||||
}
|
||||
|
||||
function DashboardChart(props: DashboardChartProps) {
|
||||
|
||||
@@ -9,7 +9,7 @@ import Charts from './_client/charts'
|
||||
import UserCenter from './_client/userCenter'
|
||||
import soon from './_assets/coming-soon.svg'
|
||||
import mask from './_assets/Mask group.webp'
|
||||
import {Button} from '@/components/ui/button'
|
||||
import {ExtraResp} from '@/lib/api'
|
||||
|
||||
export type DashboardPageProps = {}
|
||||
|
||||
@@ -43,12 +43,7 @@ export default async function DashboardPage(props: DashboardPageProps) {
|
||||
|
||||
{/* 磁贴集 */}
|
||||
{initData && (
|
||||
<Pins
|
||||
short_term={String(initData.free.short.ResourceCount)}
|
||||
short_term_monthly={String(initData.free.short.ResourceQuotaSum)}
|
||||
long_term={String(initData.free.long.ResourceCount)}
|
||||
long_term_monthly={String(initData.free.long.ResourceDailyFreeSum)}
|
||||
/>
|
||||
<Pins {...initData.free}/>
|
||||
)}
|
||||
|
||||
{/* 图表 */}
|
||||
@@ -69,13 +64,9 @@ export default async function DashboardPage(props: DashboardPageProps) {
|
||||
</Page>
|
||||
)
|
||||
}
|
||||
type DashboardChartProps = {
|
||||
short_term: string
|
||||
short_term_monthly: string
|
||||
long_term: string
|
||||
long_term_monthly: string
|
||||
}
|
||||
function Pins(props: DashboardChartProps) {
|
||||
type DashboardPinsProps = ExtraResp<typeof listInitialization>['free']
|
||||
|
||||
function Pins(props: DashboardPinsProps) {
|
||||
return (
|
||||
<div className="flex md:row-start-2 md:col-start-1 md:col-span-3 gap-4 max-md:flex-col">
|
||||
{/* 短效 */}
|
||||
@@ -91,7 +82,7 @@ function Pins(props: DashboardChartProps) {
|
||||
<h4>包时</h4>
|
||||
<p className="flex flex-col items-end">
|
||||
<span className="text-sm text-weak">当日可提取数量</span>
|
||||
<span className="text-sm">{props.short_term}</span>
|
||||
<span className="text-sm">{props.short.resource_daily_free_sum}</span>
|
||||
</p>
|
||||
</div>
|
||||
<div className="border-b"></div>
|
||||
@@ -99,7 +90,7 @@ function Pins(props: DashboardChartProps) {
|
||||
<h4 className="text-balance">包量</h4>
|
||||
<p className="flex flex-col items-end">
|
||||
<span className="text-sm text-weak">剩余可提取数量</span>
|
||||
<span className="text-sm">{props.short_term_monthly}</span>
|
||||
<span className="text-sm">{props.short.resource_quota_sum}</span>
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
@@ -118,7 +109,7 @@ function Pins(props: DashboardChartProps) {
|
||||
<h4 className="text-balance">包时</h4>
|
||||
<p className="flex flex-col items-end">
|
||||
<span className="text-sm text-weak" >当日可提取数量</span>
|
||||
<span className="text-sm">{props.long_term}</span>
|
||||
<span className="text-sm">{props.long.resource_daily_free_sum}</span>
|
||||
</p>
|
||||
</div>
|
||||
<div className="border-b"></div>
|
||||
@@ -126,7 +117,7 @@ function Pins(props: DashboardChartProps) {
|
||||
<h4 className="text-balance">包量</h4>
|
||||
<p className="flex flex-col items-end">
|
||||
<span className="text-sm text-weak">剩余可提取数量</span>
|
||||
<span className="text-sm">{props.long_term_monthly}</span>
|
||||
<span className="text-sm">{props.long.resource_quota_sum}</span>
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
|
||||
Reference in New Issue
Block a user