更新资源列表接口,调整相关数据结构,优化页面布局和样式

This commit is contained in:
2025-05-19 11:04:40 +08:00
parent 52c0184482
commit 9652181fe4
14 changed files with 105 additions and 230 deletions

View File

@@ -15,7 +15,7 @@ import actionBill from './_assets/action-bill.webp'
import actionBuy from './_assets/action-buy.webp'
import actionLogout from './_assets/action-logout.webp'
import Link from 'next/link'
import { listAnnouncements } from '@/actions/announcement'
import {listAnnouncements} from '@/actions/announcement'
import DashboardChart from './_client/chart'
export type DashboardPageProps = {}
@@ -115,7 +115,7 @@ async function Charts() {
return (
<Card className={`col-start-1 row-start-3 col-span-3 row-span-2`}>
<CardContent className={`overflow-hidden`}>
<Tabs defaultValue={`dynamic`} className='h-full gap-4'>
<Tabs defaultValue={`dynamic`} className="h-full gap-4">
<TabsList>
<TabsTrigger value={`dynamic`} className={`data-[state=active]:text-primary`}> IP </TabsTrigger>
<TabsTrigger value={`static`} className={`data-[state=active]:text-primary`}> IP </TabsTrigger>
@@ -191,11 +191,11 @@ async function UserCenter() {
<Image alt={`bill icon`} src={actionBill} height={48}/>
<span className={`text-sm text-weak`}></span>
</Link>
<Link href='/admin/purchase' className={merge(buttonVariants({variant: `ghost`}), `flex flex-col gap-2 py-2 px-3 h-auto`)}>
<Link href="/admin/purchase" className={merge(buttonVariants({variant: `ghost`}), `flex flex-col gap-2 py-2 px-3 h-auto`)}>
<Image alt={`buy icon`} src={actionBuy} height={48}/>
<span className={`text-sm text-weak`}></span>
</Link>
<Link href='/admin/profile' className={merge(buttonVariants({variant: `ghost`}), `flex flex-col gap-2 py-2 px-3 h-auto`)}>
<Link href="/admin/profile" className={merge(buttonVariants({variant: `ghost`}), `flex flex-col gap-2 py-2 px-3 h-auto`)}>
<Image alt={`logout icon`} src={actionLogout} height={48}/>
<span className={`text-sm text-weak`}></span>
</Link>
@@ -249,4 +249,4 @@ async function Announcements() {
</CardContent>
</Card>
)
}
}

View File

@@ -8,7 +8,7 @@ import {Box, Eraser, Search, Timer} from 'lucide-react'
import {Select, SelectContent, SelectItem, SelectTrigger, SelectValue} from '@/components/ui/select'
import {Button} from '@/components/ui/button'
import DataTable from '@/components/data-table'
import {format, intlFormatDistance, isAfter, isEqual, parse} from 'date-fns'
import {format, intlFormatDistance, isAfter} from 'date-fns'
import DatePicker from '@/components/date-picker'
import {Form, FormField} from '@/components/ui/form'
import {useForm} from 'react-hook-form'
@@ -133,7 +133,7 @@ export default function ResourcesPage(props: ResourcesPageProps) {
)}
</FormField>
<FormField name={`type`} label={<span className={`text-sm`}></span>}>
{({id, field}) => (
{({field}) => (
<Select value={field.value} onValueChange={field.onChange}>
<SelectTrigger className={`w-24 h-9`}>
<SelectValue placeholder={`选择套餐类型`}/>
@@ -240,13 +240,13 @@ export default function ResourcesPage(props: ResourcesPageProps) {
{
accessorKey: 'type', header: `类型`, cell: ({row}) => (
<div className={`flex gap-2 items-center`}>
{row.original.pss.type === 1 && (
{row.original.short.type === 1 && (
<div className={`flex gap-2 items-center bg-green-50 w-fit px-2 py-1 rounded-md`}>
<Timer size={20}/>
<span></span>
</div>
)}
{row.original.pss.type === 2 && (
{row.original.short.type === 2 && (
<div className={`flex gap-2 items-center bg-blue-50 w-fit px-2 py-1 rounded-md`}>
<Box size={20}/>
<span></span>
@@ -258,30 +258,30 @@ export default function ResourcesPage(props: ResourcesPageProps) {
{
accessorKey: 'live', header: `IP 时效`, cell: ({row}) => (
<span>
{row.original.pss.live / 60}
</span>
{row.original.short.live / 60}
</span>
),
},
{
accessorKey: 'expire', header: `使用情况`, cell: ({row}) => (
<div className={`flex gap-1`}>
{row.original.pss.type === 1 ? (
{row.original.short.type === 1 ? (
<div className={`flex gap-1`}>
{isAfter(row.original.pss.expire, new Date())
{isAfter(row.original.short.expire, new Date())
? <span className={`text-green-500`}></span>
: <span className={`text-red-500`}></span>}
<span>|</span>
<span>{row.original.pss.daily_used} / {row.original.pss.daily_limit}</span>
<span>{row.original.short.daily_used} / {row.original.short.daily_limit}</span>
<span>|</span>
<span>{intlFormatDistance(row.original.pss.expire, new Date())} </span>
<span>{intlFormatDistance(row.original.short.expire, new Date())} </span>
</div>
) : row.original.pss.type === 2 ? (
) : row.original.short.type === 2 ? (
<div className={`flex gap-1`}>
{row.original.pss.used < row.original.pss.quota
{row.original.short.used < row.original.short.quota
? <span className={`text-green-500`}></span>
: <span className={`text-red-500`}></span>}
<span>|</span>
<span>{row.original.pss.used} / {row.original.pss.quota}</span>
<span>{row.original.short.used} / {row.original.short.quota}</span>
</div>
) : (
<span>-</span>
@@ -292,9 +292,9 @@ export default function ResourcesPage(props: ResourcesPageProps) {
{
accessorKey: 'daily_last', header: '最近使用时间', cell: ({row}) => {
return (
format(row.original.pss.daily_last, "yyyy-MM-dd") === "0001-01-01"
format(row.original.short.daily_last, 'yyyy-MM-dd') === '0001-01-01'
? '-'
: format(row.original.pss.daily_last, 'yyyy-MM-dd HH:mm')
: format(row.original.short.daily_last, 'yyyy-MM-dd HH:mm')
)
},
},