From b20ec85db9fb3f0a5f2a55f2ba0c560282e44b8c Mon Sep 17 00:00:00 2001 From: luorijun Date: Sat, 26 Apr 2025 17:56:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=A0=B7=E5=BC=8F=E5=8C=B9?= =?UTF-8?q?=E9=85=8D=E6=96=B0=E8=AE=BE=E8=AE=A1=E6=96=B9=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/admin/extract/page.tsx | 2 +- src/app/admin/resources/page.tsx | 3 - src/app/admin/whitelist/page.tsx | 129 +++++++------------ src/components/composites/extract/index.tsx | 4 - src/components/composites/purchase/index.tsx | 28 ++-- src/components/data-table.tsx | 4 +- src/components/ui/button.tsx | 2 +- src/components/ui/input.tsx | 4 +- src/components/ui/pagination.tsx | 1 + src/components/ui/select.tsx | 1 + 10 files changed, 66 insertions(+), 112 deletions(-) diff --git a/src/app/admin/extract/page.tsx b/src/app/admin/extract/page.tsx index 85785e1..beddd6f 100644 --- a/src/app/admin/extract/page.tsx +++ b/src/app/admin/extract/page.tsx @@ -5,7 +5,7 @@ export type ExtractPageProps = {} export default async function ExtractPage(props: ExtractPageProps) { return ( - + ) diff --git a/src/app/admin/resources/page.tsx b/src/app/admin/resources/page.tsx index be1b604..ecf8cbc 100644 --- a/src/app/admin/resources/page.tsx +++ b/src/app/admin/resources/page.tsx @@ -312,9 +312,6 @@ export default function ResourcesPage(props: ResourcesPageProps) { ), }, ]} - classNames={{ - dataRow: `h-14`, - }} /> ) diff --git a/src/app/admin/whitelist/page.tsx b/src/app/admin/whitelist/page.tsx index f2f8833..80c9de5 100644 --- a/src/app/admin/whitelist/page.tsx +++ b/src/app/admin/whitelist/page.tsx @@ -24,6 +24,7 @@ import { import {Pagination} from '@/components/ui/pagination' import {Checkbox} from '@/components/ui/checkbox' import Page from '@/components/page' +import DataTable from '@/components/data-table' const schema = z.object({ host: z.string().min(1, {message: 'IP地址不能为空'}), @@ -72,17 +73,6 @@ export default function WhitelistPage(props: WhitelistPageProps) { } } - - // 处理分页 - const changePage = (newPage: number) => { - refresh(newPage, data.size).then() - } - - // 处理每页数量变化 - const changeSize = (newSize: number) => { - refresh(1, newSize).then() - } - // ====================== // 弹窗 // ====================== @@ -254,80 +244,49 @@ export default function WhitelistPage(props: WhitelistPageProps) { {/* 数据表 */} -
- - - - - toggleSelectAll()}/> - - IP - 添加时间 - 备注 - 操作 - - - - - {wait && data.list.length === 0 ? ( - - - - - - ) : data.list.length === 0 ? ( - - - 暂无数据 - - - ) : ( - data.list.map(item => ( - - - toggleSelect(item.id)}/> - - {item.host} - {item.createdAt} - {item.remark || '无'} - -
- - -
-
-
- )) - )} -
-
-
- - {/* 分页器 */} - {data.total > 0 && ( - - )} + refresh(page, data.size), + onSizeChange: (size: number) => refresh(1, size), + }} + columns={[ + { + accessorKey: 'host', header: `IP 地址`, + }, { + accessorKey: 'createdAt', header: `添加时间`, + }, { + accessorKey: 'remark', header: `备注`, + }, { + id: 'actions', + header: `操作`, + cell: ({row}) => ( +
+ + +
+ ), + }, + ]} + /> {/* 编辑表单 */} diff --git a/src/components/composites/extract/index.tsx b/src/components/composites/extract/index.tsx index 14eff2b..b57e1b8 100644 --- a/src/components/composites/extract/index.tsx +++ b/src/components/composites/extract/index.tsx @@ -131,10 +131,6 @@ export default function Extract(props: ExtractProps) { // eslint-disable-next-line react-hooks/exhaustive-deps }, []) - // ====================== - // form 中间变量 - // ====================== - // ====================== // render // ====================== diff --git a/src/components/composites/purchase/index.tsx b/src/components/composites/purchase/index.tsx index c392362..f2adc58 100644 --- a/src/components/composites/purchase/index.tsx +++ b/src/components/composites/purchase/index.tsx @@ -6,20 +6,20 @@ export default async function Purchase(props: PurchaseProps) { return (
-
    -
  • - -
  • -
  • - -
  • -
  • - -
  • -
  • - -
  • -
+ {/*
    */} + {/*
  • */} + {/* */} + {/*
  • */} + {/*
  • */} + {/* */} + {/*
  • */} + {/*
  • */} + {/* */} + {/*
  • */} + {/*
  • */} + {/* */} + {/*
  • */} + {/*
*/}
) diff --git a/src/components/data-table.tsx b/src/components/data-table.tsx index 51b6b69..c60e539 100644 --- a/src/components/data-table.tsx +++ b/src/components/data-table.tsx @@ -35,7 +35,7 @@ export default function DataTable>(props: Data return (<> {/* 数据表*/} -
+
{table.getHeaderGroups().map(group => ( @@ -61,7 +61,7 @@ export default function DataTable>(props: Data 暂无数据 ) : table.getRowModel().rows.map(row => ( - + {row.getVisibleCells().map(cell => ( {flexRender( diff --git a/src/components/ui/button.tsx b/src/components/ui/button.tsx index 1830cbf..c20a3e4 100644 --- a/src/components/ui/button.tsx +++ b/src/components/ui/button.tsx @@ -12,7 +12,7 @@ const buttonVariants = cva( destructive: "bg-fail text-fail-foreground shadow-sm hover:bg-destructive/90", outline: - "border border-input bg-background shadow-sm hover:bg-secondary hover:text-secondary-foreground", + "border border-input shadow-sm hover:bg-secondary hover:text-secondary-foreground bg-card", secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80", ghost: "hover:bg-secondary hover:text-secondary-foreground", diff --git a/src/components/ui/input.tsx b/src/components/ui/input.tsx index a694db6..d9c0abb 100644 --- a/src/components/ui/input.tsx +++ b/src/components/ui/input.tsx @@ -8,11 +8,11 @@ function Input({className, type, ...props}: React.ComponentProps<'input'>) { type={type} data-slot="input" className={merge( - `transition-[color,box-shadow] duration-200 ease-in-out`, + `transition-[color] duration-200 ease-in-out`, `h-10 min-w-0 w-full`, 'placeholder:text-muted-foreground', 'selection:bg-primary selection:text-primary-foreground', - 'flex rounded-md border bg-transparent px-3 py-1 text-base shadow-xs', + 'flex rounded-md border bg-card px-3 py-1 text-base', 'outline-none focus-visible:ring-4 ring-ring/50', 'disabled:cursor-not-allowed disabled:opacity-50', 'aria-invalid:ring-fail/20 aria-invalid:border-fail dark:aria-invalid:ring-fail/40 dark:bg-input/30', diff --git a/src/components/ui/pagination.tsx b/src/components/ui/pagination.tsx index d6b7737..675e8c6 100644 --- a/src/components/ui/pagination.tsx +++ b/src/components/ui/pagination.tsx @@ -217,6 +217,7 @@ function PaginationLink({ data-active={isActive} className={merge( 'inline-flex items-center justify-center text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 h-9 w-9 rounded-md border border-input hover:bg-secondary hover:text-secondary-foreground', + `bg-card`, isActive && 'bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground', className, )} diff --git a/src/components/ui/select.tsx b/src/components/ui/select.tsx index b5bde22..5622b3c 100644 --- a/src/components/ui/select.tsx +++ b/src/components/ui/select.tsx @@ -42,6 +42,7 @@ function SelectTrigger({ 'aria-invalid:border-fail dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 ', 'rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap transition-[color] ', 'outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 ', + 'bg-card', { sm: 'h-9', default: 'h-10',