表格与页面样式调整
This commit is contained in:
@@ -4,6 +4,7 @@ import { Suspense, useState } from "react"
|
|||||||
import { toast } from "sonner"
|
import { toast } from "sonner"
|
||||||
import { deleteAdmin, getPageAdmin, updateAdmin } from "@/actions/admin"
|
import { deleteAdmin, getPageAdmin, updateAdmin } from "@/actions/admin"
|
||||||
import { DataTable, useDataTable } from "@/components/data-table"
|
import { DataTable, useDataTable } from "@/components/data-table"
|
||||||
|
import { Page } from "@/components/page"
|
||||||
import {
|
import {
|
||||||
AlertDialog,
|
AlertDialog,
|
||||||
AlertDialogAction,
|
AlertDialogAction,
|
||||||
@@ -38,7 +39,7 @@ export default function AdminPage() {
|
|||||||
console.log(table, "table")
|
console.log(table, "table")
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-3">
|
<Page>
|
||||||
{/* 操作栏 */}
|
{/* 操作栏 */}
|
||||||
<div className="flex justify-between items-stretch">
|
<div className="flex justify-between items-stretch">
|
||||||
<div className="flex gap-3">
|
<div className="flex gap-3">
|
||||||
@@ -129,7 +130,7 @@ export default function AdminPage() {
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</div>
|
</Page>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ export default function Appbar(props: { admin: Admin }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<header className="bg-white h-16 border-b border-gray-200 flex items-center justify-between px-6">
|
<header className="bg-white flex-none basis-16 border-b border-gray-200 flex items-center justify-between px-6">
|
||||||
{/* 面包屑导航 */}
|
{/* 面包屑导航 */}
|
||||||
<div className="flex items-center text-sm">
|
<div className="flex items-center text-sm">
|
||||||
{breadcrumbs.map((crumb, index) => (
|
{breadcrumbs.map((crumb, index) => (
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { Controller, useForm } from "react-hook-form"
|
|||||||
import z from "zod"
|
import z from "zod"
|
||||||
import { getPageBalance } from "@/actions/balance"
|
import { getPageBalance } from "@/actions/balance"
|
||||||
import { DataTable, useDataTable } from "@/components/data-table"
|
import { DataTable, useDataTable } from "@/components/data-table"
|
||||||
|
import { Page } from "@/components/page"
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import {
|
import {
|
||||||
Field,
|
Field,
|
||||||
@@ -14,7 +15,6 @@ import {
|
|||||||
FieldLabel,
|
FieldLabel,
|
||||||
} from "@/components/ui/field"
|
} from "@/components/ui/field"
|
||||||
import { Input } from "@/components/ui/input"
|
import { Input } from "@/components/ui/input"
|
||||||
|
|
||||||
import type { Balance } from "@/models/balance"
|
import type { Balance } from "@/models/balance"
|
||||||
|
|
||||||
type FilterValues = {
|
type FilterValues = {
|
||||||
@@ -84,8 +84,8 @@ export default function BalancePage() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-3">
|
<Page>
|
||||||
<form onSubmit={onFilter} className="bg-white p-4 rounded-lg">
|
<form onSubmit={onFilter} className="bg-card p-4 rounded-lg">
|
||||||
<div className="flex flex-wrap items-end gap-4">
|
<div className="flex flex-wrap items-end gap-4">
|
||||||
<Controller
|
<Controller
|
||||||
name="phone"
|
name="phone"
|
||||||
@@ -226,6 +226,6 @@ export default function BalancePage() {
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</div>
|
</Page>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { Controller, useForm } from "react-hook-form"
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
import { getPageBatch } from "@/actions/batch"
|
import { getPageBatch } from "@/actions/batch"
|
||||||
import { DataTable, useDataTable } from "@/components/data-table"
|
import { DataTable, useDataTable } from "@/components/data-table"
|
||||||
|
import { Page } from "@/components/page"
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import {
|
import {
|
||||||
Field,
|
Field,
|
||||||
@@ -100,9 +101,9 @@ export default function BatchPage() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-3">
|
<Page>
|
||||||
{/* 搜索表单 */}
|
{/* 搜索表单 */}
|
||||||
<form onSubmit={onFilter} className="bg-white p-4 rounded-lg">
|
<form onSubmit={onFilter} className="bg-card p-4 rounded-lg">
|
||||||
<div className="flex flex-wrap items-end gap-4">
|
<div className="flex flex-wrap items-end gap-4">
|
||||||
<Controller
|
<Controller
|
||||||
name="batch_no"
|
name="batch_no"
|
||||||
@@ -270,6 +271,6 @@ export default function BatchPage() {
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</div>
|
</Page>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { toast } from "sonner"
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
import { getPageBill, getSkuList } from "@/actions/bill"
|
import { getPageBill, getSkuList } from "@/actions/bill"
|
||||||
import { DataTable, useDataTable } from "@/components/data-table"
|
import { DataTable, useDataTable } from "@/components/data-table"
|
||||||
|
import { Page } from "@/components/page"
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import {
|
import {
|
||||||
Field,
|
Field,
|
||||||
@@ -150,8 +151,8 @@ export default function BillingPage() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-3">
|
<Page>
|
||||||
<form onSubmit={onFilter} className="bg-white p-4">
|
<form onSubmit={onFilter} className="bg-card p-4 rounded-lg">
|
||||||
<div className="flex flex-wrap items-end gap-4">
|
<div className="flex flex-wrap items-end gap-4">
|
||||||
<Controller
|
<Controller
|
||||||
name="phone"
|
name="phone"
|
||||||
@@ -454,6 +455,6 @@ export default function BillingPage() {
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</div>
|
</Page>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { Controller, useForm } from "react-hook-form"
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
import { getPageChannel } from "@/actions/channel"
|
import { getPageChannel } from "@/actions/channel"
|
||||||
import { DataTable, useDataTable } from "@/components/data-table"
|
import { DataTable, useDataTable } from "@/components/data-table"
|
||||||
|
import { Page } from "@/components/page"
|
||||||
import { Badge } from "@/components/ui/badge"
|
import { Badge } from "@/components/ui/badge"
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import {
|
import {
|
||||||
@@ -101,8 +102,8 @@ export default function ChannelPage() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-3">
|
<Page>
|
||||||
<form onSubmit={onFilter} className="bg-white p-4 rounded-lg">
|
<form onSubmit={onFilter} className="bg-card p-4 rounded-lg">
|
||||||
<div className="flex flex-wrap items-end gap-4">
|
<div className="flex flex-wrap items-end gap-4">
|
||||||
<Controller
|
<Controller
|
||||||
name="batch_no"
|
name="batch_no"
|
||||||
@@ -322,6 +323,6 @@ export default function ChannelPage() {
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</div>
|
</Page>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { Controller, useForm } from "react-hook-form"
|
|||||||
import z from "zod"
|
import z from "zod"
|
||||||
import { getBalance } from "@/actions/balance"
|
import { getBalance } from "@/actions/balance"
|
||||||
import { DataTable, useDataTable } from "@/components/data-table"
|
import { DataTable, useDataTable } from "@/components/data-table"
|
||||||
|
import { Page } from "@/components/page"
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import {
|
import {
|
||||||
Field,
|
Field,
|
||||||
@@ -86,7 +87,7 @@ export default function BalancePage() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-3">
|
<Page>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
router.back()
|
router.back()
|
||||||
@@ -96,7 +97,7 @@ export default function BalancePage() {
|
|||||||
返回上一级
|
返回上一级
|
||||||
</Button>
|
</Button>
|
||||||
<span className="ml-2 text-gray-600">用户会员号: {userPhone}</span>
|
<span className="ml-2 text-gray-600">用户会员号: {userPhone}</span>
|
||||||
<form onSubmit={onFilter} className="bg-white p-4 rounded-lg">
|
<form onSubmit={onFilter} className="bg-card p-4 rounded-lg">
|
||||||
<div className="flex flex-wrap items-end gap-4">
|
<div className="flex flex-wrap items-end gap-4">
|
||||||
<Controller
|
<Controller
|
||||||
name="bill_id"
|
name="bill_id"
|
||||||
@@ -219,6 +220,6 @@ export default function BalancePage() {
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</div>
|
</Page>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { Controller, useForm } from "react-hook-form"
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
import { getBatch } from "@/actions/batch"
|
import { getBatch } from "@/actions/batch"
|
||||||
import { DataTable, useDataTable } from "@/components/data-table"
|
import { DataTable, useDataTable } from "@/components/data-table"
|
||||||
|
import { Page } from "@/components/page"
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import {
|
import {
|
||||||
Field,
|
Field,
|
||||||
@@ -105,18 +106,9 @@ export default function BatchPage() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-3">
|
<Page>
|
||||||
<Button
|
{/* 筛选表单 */}
|
||||||
onClick={() => {
|
<form onSubmit={onFilter} className="bg-card p-4 rounded-lg">
|
||||||
router.back()
|
|
||||||
}}
|
|
||||||
className="gap-2"
|
|
||||||
>
|
|
||||||
返回上一级
|
|
||||||
</Button>
|
|
||||||
<span className="ml-2 text-gray-600">用户会员号: {userPhone}</span>
|
|
||||||
|
|
||||||
<form onSubmit={onFilter} className="bg-white p-4 rounded-lg">
|
|
||||||
<div className="flex flex-wrap items-end gap-4">
|
<div className="flex flex-wrap items-end gap-4">
|
||||||
<Controller
|
<Controller
|
||||||
name="batch_no"
|
name="batch_no"
|
||||||
@@ -264,6 +256,6 @@ export default function BatchPage() {
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</div>
|
</Page>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { toast } from "sonner"
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
import { getBill, getSkuList } from "@/actions/bill"
|
import { getBill, getSkuList } from "@/actions/bill"
|
||||||
import { DataTable, useDataTable } from "@/components/data-table"
|
import { DataTable, useDataTable } from "@/components/data-table"
|
||||||
|
import { Page } from "@/components/page"
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import {
|
import {
|
||||||
Field,
|
Field,
|
||||||
@@ -155,17 +156,8 @@ export default function BillingPage() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-3">
|
<Page>
|
||||||
<Button
|
<form onSubmit={onFilter} className="bg-card p-4 rounded-lg">
|
||||||
onClick={() => {
|
|
||||||
router.back()
|
|
||||||
}}
|
|
||||||
className="gap-2"
|
|
||||||
>
|
|
||||||
返回上一级
|
|
||||||
</Button>
|
|
||||||
<span className="ml-2 text-gray-600">用户会员号: {userPhone}</span>
|
|
||||||
<form onSubmit={onFilter} className="bg-white p-4">
|
|
||||||
<div className="flex flex-wrap items-end gap-4">
|
<div className="flex flex-wrap items-end gap-4">
|
||||||
<Controller
|
<Controller
|
||||||
name="resource_no"
|
name="resource_no"
|
||||||
@@ -453,6 +445,6 @@ export default function BillingPage() {
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</div>
|
</Page>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { Controller, useForm } from "react-hook-form"
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
import { getChannel } from "@/actions/channel"
|
import { getChannel } from "@/actions/channel"
|
||||||
import { DataTable, useDataTable } from "@/components/data-table"
|
import { DataTable, useDataTable } from "@/components/data-table"
|
||||||
|
import { Page } from "@/components/page"
|
||||||
import { Badge } from "@/components/ui/badge"
|
import { Badge } from "@/components/ui/badge"
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import {
|
import {
|
||||||
@@ -105,18 +106,8 @@ export default function ChannelPage() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-3">
|
<Page>
|
||||||
<Button
|
<form onSubmit={onFilter} className="bg-card p-4 rounded-lg">
|
||||||
onClick={() => {
|
|
||||||
router.back()
|
|
||||||
}}
|
|
||||||
className="gap-2"
|
|
||||||
>
|
|
||||||
返回上一级
|
|
||||||
</Button>
|
|
||||||
<span className="ml-2 text-gray-600">用户会员号: {userPhone}</span>
|
|
||||||
|
|
||||||
<form onSubmit={onFilter} className="bg-white p-4 rounded-lg">
|
|
||||||
<div className="flex flex-wrap items-end gap-4">
|
<div className="flex flex-wrap items-end gap-4">
|
||||||
<Controller
|
<Controller
|
||||||
name="batch_no"
|
name="batch_no"
|
||||||
@@ -322,6 +313,6 @@ export default function ChannelPage() {
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</div>
|
</Page>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { getPageUser } from "@/actions/user"
|
|||||||
import { UpdateDialog } from "@/app/(root)/cust/update"
|
import { UpdateDialog } from "@/app/(root)/cust/update"
|
||||||
import { Auth } from "@/components/auth"
|
import { Auth } from "@/components/auth"
|
||||||
import { DataTable } from "@/components/data-table"
|
import { DataTable } from "@/components/data-table"
|
||||||
|
import { Page } from "@/components/page"
|
||||||
import { Badge } from "@/components/ui/badge"
|
import { Badge } from "@/components/ui/badge"
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import {
|
import {
|
||||||
@@ -53,10 +54,7 @@ type FormValues = z.infer<typeof filterSchema>
|
|||||||
export default function UserQueryPage() {
|
export default function UserQueryPage() {
|
||||||
const [userList, setUserList] = useState<User[]>([])
|
const [userList, setUserList] = useState<User[]>([])
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
const [isEditDialogOpen, setIsEditDialogOpen] = useState(false)
|
|
||||||
const [currentEditUser, setCurrentEditUser] = useState<User | null>(null)
|
|
||||||
const [currentFilters, setCurrentFilters] = useState<UserQueryParams>({})
|
const [currentFilters, setCurrentFilters] = useState<UserQueryParams>({})
|
||||||
const [isAddDialogOpen, setIsAddDialogOpen] = useState(false)
|
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const { control, handleSubmit, reset } = useForm<FormValues>({
|
const { control, handleSubmit, reset } = useForm<FormValues>({
|
||||||
@@ -111,8 +109,8 @@ export default function UserQueryPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-3">
|
<Page>
|
||||||
<form onSubmit={onFilter} className="bg-white p-4">
|
<form onSubmit={onFilter} className="bg-card p-4 rounded-lg">
|
||||||
<div className="flex flex-wrap items-end gap-4">
|
<div className="flex flex-wrap items-end gap-4">
|
||||||
<Controller
|
<Controller
|
||||||
name="phone"
|
name="phone"
|
||||||
@@ -147,9 +145,7 @@ export default function UserQueryPage() {
|
|||||||
|
|
||||||
<FieldGroup className="flex-row justify-start mt-4 gap-2">
|
<FieldGroup className="flex-row justify-start mt-4 gap-2">
|
||||||
<Auth scope={ScopeUserWrite}>
|
<Auth scope={ScopeUserWrite}>
|
||||||
<Button type="button" onClick={() => setIsAddDialogOpen(true)}>
|
<AddUserDialog onSuccess={refreshTable} />
|
||||||
添加用户
|
|
||||||
</Button>
|
|
||||||
</Auth>
|
</Auth>
|
||||||
<Button type="button" variant="outline" onClick={handleReset}>
|
<Button type="button" variant="outline" onClick={handleReset}>
|
||||||
重置
|
重置
|
||||||
@@ -249,17 +245,12 @@ export default function UserQueryPage() {
|
|||||||
header: "操作",
|
header: "操作",
|
||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
return (
|
return (
|
||||||
<div className="flex gap-2">
|
<div className="flex flex-wrap gap-2 w-75">
|
||||||
<Auth scope={ScopeUserWriteBalance}>
|
<Auth scope={ScopeUserWriteBalance}>
|
||||||
<Button
|
<UpdateDialog
|
||||||
size="sm"
|
user={row.original}
|
||||||
onClick={() => {
|
onSuccess={refreshTable}
|
||||||
setCurrentEditUser(row.original)
|
/>
|
||||||
setIsEditDialogOpen(true)
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
修改
|
|
||||||
</Button>
|
|
||||||
</Auth>
|
</Auth>
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
@@ -343,17 +334,6 @@ export default function UserQueryPage() {
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
<AddUserDialog
|
</Page>
|
||||||
open={isAddDialogOpen}
|
|
||||||
onOpenChange={setIsAddDialogOpen}
|
|
||||||
onSuccess={refreshTable}
|
|
||||||
/>
|
|
||||||
<UpdateDialog
|
|
||||||
open={isEditDialogOpen}
|
|
||||||
onOpenChange={setIsEditDialogOpen}
|
|
||||||
currentUser={currentEditUser}
|
|
||||||
onSuccess={refreshTable}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
updateResource,
|
updateResource,
|
||||||
} from "@/actions/resources"
|
} from "@/actions/resources"
|
||||||
import { DataTable, useDataTable } from "@/components/data-table"
|
import { DataTable, useDataTable } from "@/components/data-table"
|
||||||
|
import { Page } from "@/components/page"
|
||||||
import { Badge } from "@/components/ui/badge"
|
import { Badge } from "@/components/ui/badge"
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import {
|
import {
|
||||||
@@ -170,7 +171,7 @@ function getTodayUsage(lastAt: Date | null | undefined, daily: number) {
|
|||||||
|
|
||||||
export default function ResourcesPage() {
|
export default function ResourcesPage() {
|
||||||
return (
|
return (
|
||||||
<div>
|
<Page>
|
||||||
<Tabs defaultValue="short">
|
<Tabs defaultValue="short">
|
||||||
<TabsList className="bg-card p-1.5 rounded-lg">
|
<TabsList className="bg-card p-1.5 rounded-lg">
|
||||||
<TabsTrigger
|
<TabsTrigger
|
||||||
@@ -193,7 +194,7 @@ export default function ResourcesPage() {
|
|||||||
<ResourceList resourceType="long" />
|
<ResourceList resourceType="long" />
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</div>
|
</Page>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -425,17 +426,7 @@ function ResourceList({ resourceType }: ResourceListProps) {
|
|||||||
const userPhone = searchParams.get("phone")
|
const userPhone = searchParams.get("phone")
|
||||||
return (
|
return (
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
<Button
|
<form onSubmit={onFilter} className="bg-card p-4 rounded-lg">
|
||||||
onClick={() => {
|
|
||||||
router.back()
|
|
||||||
}}
|
|
||||||
className="gap-2"
|
|
||||||
>
|
|
||||||
返回上一级
|
|
||||||
</Button>
|
|
||||||
<span className="ml-2 text-gray-600">用户会员号: {userPhone}</span>
|
|
||||||
|
|
||||||
<form onSubmit={onFilter} className="bg-white p-4 rounded-lg">
|
|
||||||
<div className="flex flex-wrap items-end gap-4">
|
<div className="flex flex-wrap items-end gap-4">
|
||||||
<Controller
|
<Controller
|
||||||
name="user_phone"
|
name="user_phone"
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { Controller, useForm } from "react-hook-form"
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
import { getTrade } from "@/actions/trade"
|
import { getTrade } from "@/actions/trade"
|
||||||
import { DataTable, useDataTable } from "@/components/data-table"
|
import { DataTable, useDataTable } from "@/components/data-table"
|
||||||
|
import { Page } from "@/components/page"
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import {
|
import {
|
||||||
Field,
|
Field,
|
||||||
@@ -108,18 +109,9 @@ export default function TradePage() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-3">
|
<Page>
|
||||||
<Button
|
{/* 筛选表单 */}
|
||||||
onClick={() => {
|
<form onSubmit={onFilter} className="bg-card p-4 rounded-lg">
|
||||||
router.back()
|
|
||||||
}}
|
|
||||||
className="gap-2"
|
|
||||||
>
|
|
||||||
返回上一级
|
|
||||||
</Button>
|
|
||||||
<span className="ml-2 text-gray-600">用户会员号: {userPhone}</span>
|
|
||||||
|
|
||||||
<form onSubmit={onFilter} className="bg-white p-4">
|
|
||||||
<div className="flex flex-wrap items-end gap-4">
|
<div className="flex flex-wrap items-end gap-4">
|
||||||
<Controller
|
<Controller
|
||||||
name="inner_no"
|
name="inner_no"
|
||||||
@@ -356,6 +348,6 @@ export default function TradePage() {
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</div>
|
</Page>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { Suspense, useState } from "react"
|
|||||||
import { toast } from "sonner"
|
import { toast } from "sonner"
|
||||||
import { deleteCoupon, getPagCoupon } from "@/actions/coupon"
|
import { deleteCoupon, getPagCoupon } from "@/actions/coupon"
|
||||||
import { DataTable, useDataTable } from "@/components/data-table"
|
import { DataTable, useDataTable } from "@/components/data-table"
|
||||||
|
import { Page } from "@/components/page"
|
||||||
import {
|
import {
|
||||||
AlertDialog,
|
AlertDialog,
|
||||||
AlertDialogAction,
|
AlertDialogAction,
|
||||||
@@ -24,7 +25,7 @@ export default function CouponPage() {
|
|||||||
const table = useDataTable((page, size) => getPagCoupon({ page, size }))
|
const table = useDataTable((page, size) => getPagCoupon({ page, size }))
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-3">
|
<Page>
|
||||||
<div className="flex justify-between items-stretch">
|
<div className="flex justify-between items-stretch">
|
||||||
<div className="flex gap-3">
|
<div className="flex gap-3">
|
||||||
<CreateDiscount onSuccess={table.refresh} />
|
<CreateDiscount onSuccess={table.refresh} />
|
||||||
@@ -92,7 +93,7 @@ export default function CouponPage() {
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</div>
|
</Page>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
DialogContent,
|
DialogContent,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
|
DialogTrigger,
|
||||||
} from "@/components/ui/dialog"
|
} from "@/components/ui/dialog"
|
||||||
import {
|
import {
|
||||||
Field,
|
Field,
|
||||||
@@ -72,16 +73,11 @@ const addUserSchema = z
|
|||||||
export type AddUserFormValues = z.infer<typeof addUserSchema>
|
export type AddUserFormValues = z.infer<typeof addUserSchema>
|
||||||
|
|
||||||
interface AddUserDialogProps {
|
interface AddUserDialogProps {
|
||||||
open: boolean
|
|
||||||
onOpenChange: (open: boolean) => void
|
|
||||||
onSuccess?: () => void
|
onSuccess?: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export function AddUserDialog({
|
export function AddUserDialog({ onSuccess }: AddUserDialogProps) {
|
||||||
open,
|
const [open, setOpen] = useState(false)
|
||||||
onOpenChange,
|
|
||||||
onSuccess,
|
|
||||||
}: AddUserDialogProps) {
|
|
||||||
const [isAdding, setIsAdding] = useState(false)
|
const [isAdding, setIsAdding] = useState(false)
|
||||||
const [discountList, setDiscountList] = useState<ProductDiscount[]>([])
|
const [discountList, setDiscountList] = useState<ProductDiscount[]>([])
|
||||||
const [isLoadingDiscount, setIsLoadingDiscount] = useState(false)
|
const [isLoadingDiscount, setIsLoadingDiscount] = useState(false)
|
||||||
@@ -176,7 +172,7 @@ export function AddUserDialog({
|
|||||||
const result = await createCust(payload)
|
const result = await createCust(payload)
|
||||||
if (result?.success) {
|
if (result?.success) {
|
||||||
toast.success("添加用户成功")
|
toast.success("添加用户成功")
|
||||||
onOpenChange(false)
|
setOpen(false)
|
||||||
resetAddForm()
|
resetAddForm()
|
||||||
onSuccess?.()
|
onSuccess?.()
|
||||||
} else {
|
} else {
|
||||||
@@ -194,11 +190,14 @@ export function AddUserDialog({
|
|||||||
if (!open) {
|
if (!open) {
|
||||||
resetAddForm()
|
resetAddForm()
|
||||||
}
|
}
|
||||||
onOpenChange(open)
|
setOpen(open)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={open} onOpenChange={handleOpenChange}>
|
<Dialog open={open} onOpenChange={handleOpenChange}>
|
||||||
|
<DialogTrigger asChild>
|
||||||
|
<Button type="button">添加用户</Button>
|
||||||
|
</DialogTrigger>
|
||||||
<DialogContent className="max-w-3xl max-h-[90vh] overflow-y-auto">
|
<DialogContent className="max-w-3xl max-h-[90vh] overflow-y-auto">
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle>添加用户</DialogTitle>
|
<DialogTitle>添加用户</DialogTitle>
|
||||||
@@ -396,7 +395,7 @@ export function AddUserDialog({
|
|||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
onClick={() => onOpenChange(false)}
|
onClick={() => setOpen(false)}
|
||||||
>
|
>
|
||||||
取消
|
取消
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
DialogFooter,
|
DialogFooter,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
|
DialogTrigger,
|
||||||
} from "@/components/ui/dialog"
|
} from "@/components/ui/dialog"
|
||||||
import { Field, FieldError, FieldLabel } from "@/components/ui/field"
|
import { Field, FieldError, FieldLabel } from "@/components/ui/field"
|
||||||
import { Input } from "@/components/ui/input"
|
import { Input } from "@/components/ui/input"
|
||||||
@@ -30,18 +31,15 @@ const Schema = z.object({
|
|||||||
type FormValues = z.infer<typeof Schema>
|
type FormValues = z.infer<typeof Schema>
|
||||||
|
|
||||||
interface UpdateDeductionDialogProps {
|
interface UpdateDeductionDialogProps {
|
||||||
open: boolean
|
user: User
|
||||||
onOpenChange: (open: boolean) => void
|
|
||||||
currentUser: User | null
|
|
||||||
onSuccess: () => void
|
onSuccess: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export function DeductionDialog({
|
export function DeductionDialog({
|
||||||
open,
|
user,
|
||||||
onOpenChange,
|
|
||||||
currentUser,
|
|
||||||
onSuccess,
|
onSuccess,
|
||||||
}: UpdateDeductionDialogProps) {
|
}: UpdateDeductionDialogProps) {
|
||||||
|
const [open, setOpen] = useState(false)
|
||||||
const [isLoading, setIsLoading] = useState(false)
|
const [isLoading, setIsLoading] = useState(false)
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@@ -58,17 +56,16 @@ export function DeductionDialog({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const onSubmit = async (data: FormValues) => {
|
const onSubmit = async (data: FormValues) => {
|
||||||
if (!currentUser) return
|
|
||||||
setIsLoading(true)
|
setIsLoading(true)
|
||||||
try {
|
try {
|
||||||
const result = await getDeduction({
|
const result = await getDeduction({
|
||||||
user_id: currentUser.id,
|
user_id: user.id,
|
||||||
amount: data.deduction,
|
amount: data.deduction,
|
||||||
})
|
})
|
||||||
|
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
toast.success("扣款成功")
|
toast.success("扣款成功")
|
||||||
onOpenChange(false)
|
setOpen(false)
|
||||||
reset()
|
reset()
|
||||||
onSuccess()
|
onSuccess()
|
||||||
} else {
|
} else {
|
||||||
@@ -86,16 +83,19 @@ export function DeductionDialog({
|
|||||||
if (!open) {
|
if (!open) {
|
||||||
reset()
|
reset()
|
||||||
}
|
}
|
||||||
onOpenChange(open)
|
setOpen(open)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={open} onOpenChange={handleOpenChange}>
|
<Dialog open={open} onOpenChange={handleOpenChange}>
|
||||||
|
<DialogTrigger asChild>
|
||||||
|
<Button size="sm">扣款</Button>
|
||||||
|
</DialogTrigger>
|
||||||
<DialogContent className="max-w-2xl max-h-[90vh] overflow-y-auto">
|
<DialogContent className="max-w-2xl max-h-[90vh] overflow-y-auto">
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle>扣款</DialogTitle>
|
<DialogTitle>扣款</DialogTitle>
|
||||||
<DialogDescription>
|
<DialogDescription>
|
||||||
扣减用户 {currentUser?.name || currentUser?.username} 的余额
|
扣减用户 {user.name || user.username} 的余额
|
||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
DialogFooter,
|
DialogFooter,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
|
DialogTrigger,
|
||||||
} from "@/components/ui/dialog"
|
} from "@/components/ui/dialog"
|
||||||
import { Field, FieldError, FieldLabel } from "@/components/ui/field"
|
import { Field, FieldError, FieldLabel } from "@/components/ui/field"
|
||||||
import { Input } from "@/components/ui/input"
|
import { Input } from "@/components/ui/input"
|
||||||
@@ -30,18 +31,12 @@ const Schema = z.object({
|
|||||||
type FormValues = z.infer<typeof Schema>
|
type FormValues = z.infer<typeof Schema>
|
||||||
|
|
||||||
interface UpdateDepositDialogProps {
|
interface UpdateDepositDialogProps {
|
||||||
open: boolean
|
user: User
|
||||||
onOpenChange: (open: boolean) => void
|
|
||||||
currentUser: User | null
|
|
||||||
onSuccess: () => void
|
onSuccess: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export function DepositDialog({
|
export function DepositDialog({ user, onSuccess }: UpdateDepositDialogProps) {
|
||||||
open,
|
const [open, setOpen] = useState(false)
|
||||||
onOpenChange,
|
|
||||||
currentUser,
|
|
||||||
onSuccess,
|
|
||||||
}: UpdateDepositDialogProps) {
|
|
||||||
const [isLoading, setIsLoading] = useState(false)
|
const [isLoading, setIsLoading] = useState(false)
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@@ -58,17 +53,16 @@ export function DepositDialog({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const onSubmit = async (data: FormValues) => {
|
const onSubmit = async (data: FormValues) => {
|
||||||
if (!currentUser) return
|
|
||||||
setIsLoading(true)
|
setIsLoading(true)
|
||||||
try {
|
try {
|
||||||
const result = await getDeposit({
|
const result = await getDeposit({
|
||||||
user_id: currentUser.id,
|
user_id: user.id,
|
||||||
amount: data.deposit,
|
amount: data.deposit,
|
||||||
})
|
})
|
||||||
|
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
toast.success("充值成功")
|
toast.success("充值成功")
|
||||||
onOpenChange(false)
|
setOpen(false)
|
||||||
reset()
|
reset()
|
||||||
onSuccess()
|
onSuccess()
|
||||||
} else {
|
} else {
|
||||||
@@ -86,16 +80,19 @@ export function DepositDialog({
|
|||||||
if (!open) {
|
if (!open) {
|
||||||
reset()
|
reset()
|
||||||
}
|
}
|
||||||
onOpenChange(open)
|
setOpen(open)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={open} onOpenChange={handleOpenChange}>
|
<Dialog open={open} onOpenChange={handleOpenChange}>
|
||||||
|
<DialogTrigger asChild>
|
||||||
|
<Button size="sm">充值</Button>
|
||||||
|
</DialogTrigger>
|
||||||
<DialogContent className="max-w-2xl max-h-[90vh] overflow-y-auto">
|
<DialogContent className="max-w-2xl max-h-[90vh] overflow-y-auto">
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle>充值</DialogTitle>
|
<DialogTitle>充值</DialogTitle>
|
||||||
<DialogDescription>
|
<DialogDescription>
|
||||||
充值用户 {currentUser?.name || currentUser?.username} 的余额
|
充值用户 {user?.name || user?.username} 的余额
|
||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { z } from "zod"
|
|||||||
import { getPageCusts } from "@/actions/cust"
|
import { getPageCusts } from "@/actions/cust"
|
||||||
import { Auth } from "@/components/auth"
|
import { Auth } from "@/components/auth"
|
||||||
import { DataTable, useDataTable } from "@/components/data-table"
|
import { DataTable, useDataTable } from "@/components/data-table"
|
||||||
|
import { Page } from "@/components/page"
|
||||||
import { Badge } from "@/components/ui/badge"
|
import { Badge } from "@/components/ui/badge"
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import {
|
import {
|
||||||
@@ -86,14 +87,7 @@ type FormValues = z.infer<typeof filterSchema>
|
|||||||
|
|
||||||
export default function CustPage() {
|
export default function CustPage() {
|
||||||
const [filters, setFilters] = useState<FilterValues>({})
|
const [filters, setFilters] = useState<FilterValues>({})
|
||||||
const [isAddDialogOpen, setIsAddDialogOpen] = useState(false)
|
|
||||||
const [isEditDialogOpen, setIsEditDialogOpen] = useState(false)
|
|
||||||
const [currentEditUser, setCurrentEditUser] = useState<User | null>(null)
|
|
||||||
const [depositDialog, setDepositDialog] = useState(false)
|
|
||||||
const [deposit, setDeposit] = useState<User | null>(null)
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const [deductionDialog, setDeductionDialog] = useState(false)
|
|
||||||
const [deduction, setDeduction] = useState<User | null>(null)
|
|
||||||
const { control, handleSubmit, reset } = useForm<FormValues>({
|
const { control, handleSubmit, reset } = useForm<FormValues>({
|
||||||
resolver: zodResolver(filterSchema),
|
resolver: zodResolver(filterSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
@@ -130,8 +124,8 @@ export default function CustPage() {
|
|||||||
}, [table])
|
}, [table])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-3">
|
<Page>
|
||||||
<form onSubmit={onFilter} className="bg-white p-4">
|
<form onSubmit={onFilter} className="bg-card p-4 rounded-lg">
|
||||||
<div className="flex flex-wrap items-end gap-4">
|
<div className="flex flex-wrap items-end gap-4">
|
||||||
<Controller
|
<Controller
|
||||||
name="account"
|
name="account"
|
||||||
@@ -204,6 +198,7 @@ export default function CustPage() {
|
|||||||
</Field>
|
</Field>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Controller
|
<Controller
|
||||||
name="created_at_start"
|
name="created_at_start"
|
||||||
control={control}
|
control={control}
|
||||||
@@ -237,9 +232,7 @@ export default function CustPage() {
|
|||||||
|
|
||||||
<FieldGroup className="flex-row justify-start mt-4 gap-2">
|
<FieldGroup className="flex-row justify-start mt-4 gap-2">
|
||||||
<Auth scope={ScopeUserWrite}>
|
<Auth scope={ScopeUserWrite}>
|
||||||
<Button type="button" onClick={() => setIsAddDialogOpen(true)}>
|
<AddUserDialog onSuccess={refreshTable} />
|
||||||
添加用户
|
|
||||||
</Button>
|
|
||||||
</Auth>
|
</Auth>
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
@@ -259,6 +252,7 @@ export default function CustPage() {
|
|||||||
<Suspense>
|
<Suspense>
|
||||||
<DataTable<User>
|
<DataTable<User>
|
||||||
{...table}
|
{...table}
|
||||||
|
classNames={{ root: "flex-auto overflow-hidden" }}
|
||||||
columns={[
|
columns={[
|
||||||
{ header: "手机", accessorKey: "phone" },
|
{ header: "手机", accessorKey: "phone" },
|
||||||
{
|
{
|
||||||
@@ -371,39 +365,24 @@ export default function CustPage() {
|
|||||||
return (
|
return (
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<Auth scope={ScopeUserWriteBalanceInc}>
|
<Auth scope={ScopeUserWriteBalanceInc}>
|
||||||
<Button
|
<DepositDialog
|
||||||
size="sm"
|
user={row.original}
|
||||||
onClick={() => {
|
onSuccess={refreshTable}
|
||||||
setDeposit(user)
|
/>
|
||||||
setDepositDialog(true)
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
充值
|
|
||||||
</Button>
|
|
||||||
</Auth>
|
</Auth>
|
||||||
|
|
||||||
<Auth scope={ScopeUserWriteBalanceDec}>
|
<Auth scope={ScopeUserWriteBalanceDec}>
|
||||||
<Button
|
<DeductionDialog
|
||||||
size="sm"
|
user={row.original}
|
||||||
onClick={() => {
|
onSuccess={refreshTable}
|
||||||
setDeduction(user)
|
/>
|
||||||
setDeductionDialog(true)
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
扣款
|
|
||||||
</Button>
|
|
||||||
</Auth>
|
</Auth>
|
||||||
|
|
||||||
<Auth scope={ScopeUserWriteBalance}>
|
<Auth scope={ScopeUserWriteBalance}>
|
||||||
<Button
|
<UpdateDialog
|
||||||
size="sm"
|
user={row.original}
|
||||||
onClick={() => {
|
onSuccess={refreshTable}
|
||||||
setCurrentEditUser(user)
|
/>
|
||||||
setIsEditDialogOpen(true)
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
修改
|
|
||||||
</Button>
|
|
||||||
</Auth>
|
</Auth>
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
@@ -492,32 +471,6 @@ export default function CustPage() {
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
|
</Page>
|
||||||
<AddUserDialog
|
|
||||||
open={isAddDialogOpen}
|
|
||||||
onOpenChange={setIsAddDialogOpen}
|
|
||||||
onSuccess={refreshTable}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<UpdateDialog
|
|
||||||
open={isEditDialogOpen}
|
|
||||||
onOpenChange={setIsEditDialogOpen}
|
|
||||||
currentUser={currentEditUser}
|
|
||||||
onSuccess={refreshTable}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<DepositDialog
|
|
||||||
open={depositDialog}
|
|
||||||
onOpenChange={setDepositDialog}
|
|
||||||
currentUser={deposit}
|
|
||||||
onSuccess={refreshTable}
|
|
||||||
/>
|
|
||||||
<DeductionDialog
|
|
||||||
open={deductionDialog}
|
|
||||||
onOpenChange={setDeductionDialog}
|
|
||||||
currentUser={deduction}
|
|
||||||
onSuccess={refreshTable}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
DialogContent,
|
DialogContent,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
|
DialogTrigger,
|
||||||
} from "@/components/ui/dialog"
|
} from "@/components/ui/dialog"
|
||||||
import {
|
import {
|
||||||
Field,
|
Field,
|
||||||
@@ -30,8 +31,8 @@ import {
|
|||||||
SelectValue,
|
SelectValue,
|
||||||
} from "@/components/ui/select"
|
} from "@/components/ui/select"
|
||||||
import type { Admin } from "@/models/admin"
|
import type { Admin } from "@/models/admin"
|
||||||
import type { User } from "@/models/user"
|
|
||||||
import type { ProductDiscount } from "@/models/product_discount"
|
import type { ProductDiscount } from "@/models/product_discount"
|
||||||
|
import type { User } from "@/models/user"
|
||||||
|
|
||||||
// 表单验证规则
|
// 表单验证规则
|
||||||
const editUserSchema = z
|
const editUserSchema = z
|
||||||
@@ -67,18 +68,12 @@ const editUserSchema = z
|
|||||||
export type EditUserFormValues = z.infer<typeof editUserSchema>
|
export type EditUserFormValues = z.infer<typeof editUserSchema>
|
||||||
|
|
||||||
interface EditUserDialogProps {
|
interface EditUserDialogProps {
|
||||||
open: boolean
|
user: User
|
||||||
onOpenChange: (open: boolean) => void
|
|
||||||
currentUser: User | null
|
|
||||||
onSuccess: () => void
|
onSuccess: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export function UpdateDialog({
|
export function UpdateDialog({ user, onSuccess }: EditUserDialogProps) {
|
||||||
open,
|
const [open, setOpen] = useState(false)
|
||||||
onOpenChange,
|
|
||||||
currentUser,
|
|
||||||
onSuccess,
|
|
||||||
}: EditUserDialogProps) {
|
|
||||||
const [admins, setAdmins] = useState<Admin[]>([])
|
const [admins, setAdmins] = useState<Admin[]>([])
|
||||||
const [discounts, setDiscounts] = useState<ProductDiscount[]>([])
|
const [discounts, setDiscounts] = useState<ProductDiscount[]>([])
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false)
|
const [isSubmitting, setIsSubmitting] = useState(false)
|
||||||
@@ -133,24 +128,21 @@ export function UpdateDialog({
|
|||||||
}, [open])
|
}, [open])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (currentUser) {
|
if (open) {
|
||||||
reset({
|
reset({
|
||||||
id: currentUser.id,
|
id: user.id,
|
||||||
username: currentUser.username,
|
username: user.username,
|
||||||
email: currentUser.email || "",
|
email: user.email || "",
|
||||||
password: "",
|
password: "",
|
||||||
confirmPassword: "",
|
confirmPassword: "",
|
||||||
admin_id: currentUser.admin_id ? String(currentUser.admin_id) : "",
|
admin_id: user.admin_id ? String(user.admin_id) : "",
|
||||||
discount_id: currentUser.discount_id
|
discount_id: user.discount_id ? String(user.discount_id) : "",
|
||||||
? String(currentUser.discount_id)
|
status: user.status !== undefined ? String(user.status) : "",
|
||||||
: "",
|
contact_qq: user.contact_qq || "",
|
||||||
status:
|
contact_wechat: user.contact_wechat || "",
|
||||||
currentUser.status !== undefined ? String(currentUser.status) : "",
|
|
||||||
contact_qq: currentUser.contact_qq || "",
|
|
||||||
contact_wechat: currentUser.contact_wechat || "",
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}, [currentUser, reset])
|
}, [open, user, reset])
|
||||||
|
|
||||||
const onSubmit = async (data: EditUserFormValues) => {
|
const onSubmit = async (data: EditUserFormValues) => {
|
||||||
setIsSubmitting(true)
|
setIsSubmitting(true)
|
||||||
@@ -194,7 +186,7 @@ export function UpdateDialog({
|
|||||||
const result = await updateCust(updateData)
|
const result = await updateCust(updateData)
|
||||||
if (result?.success) {
|
if (result?.success) {
|
||||||
toast.success("修改成功")
|
toast.success("修改成功")
|
||||||
onOpenChange(false)
|
setOpen(false)
|
||||||
onSuccess()
|
onSuccess()
|
||||||
} else {
|
} else {
|
||||||
toast.error(result?.message || "修改失败")
|
toast.error(result?.message || "修改失败")
|
||||||
@@ -213,11 +205,14 @@ export function UpdateDialog({
|
|||||||
if (!open) {
|
if (!open) {
|
||||||
reset()
|
reset()
|
||||||
}
|
}
|
||||||
onOpenChange(open)
|
setOpen(open)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={open} onOpenChange={handleOpenChange}>
|
<Dialog open={open} onOpenChange={handleOpenChange}>
|
||||||
|
<DialogTrigger asChild>
|
||||||
|
<Button size="sm">修改</Button>
|
||||||
|
</DialogTrigger>
|
||||||
<DialogContent className="max-w-2xl max-h-[90vh] overflow-y-auto">
|
<DialogContent className="max-w-2xl max-h-[90vh] overflow-y-auto">
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle>修改用户</DialogTitle>
|
<DialogTitle>修改用户</DialogTitle>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
getPageProductDiscount,
|
getPageProductDiscount,
|
||||||
} from "@/actions/product_discount"
|
} from "@/actions/product_discount"
|
||||||
import { DataTable, useDataTable } from "@/components/data-table"
|
import { DataTable, useDataTable } from "@/components/data-table"
|
||||||
|
import { Page } from "@/components/page"
|
||||||
import {
|
import {
|
||||||
AlertDialog,
|
AlertDialog,
|
||||||
AlertDialogAction,
|
AlertDialogAction,
|
||||||
@@ -29,7 +30,7 @@ export default function DiscountPage() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-3">
|
<Page>
|
||||||
{/* 操作栏 */}
|
{/* 操作栏 */}
|
||||||
<div className="flex justify-between items-stretch">
|
<div className="flex justify-between items-stretch">
|
||||||
<div className="flex gap-3">
|
<div className="flex gap-3">
|
||||||
@@ -76,7 +77,7 @@ export default function DiscountPage() {
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</div>
|
</Page>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ async function Layout(props: { children: ReactNode }) {
|
|||||||
<Appbar admin={profile.data} />
|
<Appbar admin={profile.data} />
|
||||||
|
|
||||||
{/* 内容区域 */}
|
{/* 内容区域 */}
|
||||||
<main className="flex-1 overflow-auto p-6">{props.children}</main>
|
<main className="flex-auto overflow-hidden">{props.children}</main>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { Copy } from "lucide-react"
|
|||||||
import { Suspense, useCallback, useEffect, useState } from "react"
|
import { Suspense, useCallback, useEffect, useState } from "react"
|
||||||
import { toast } from "sonner"
|
import { toast } from "sonner"
|
||||||
import { getAllPermissions } from "@/actions/permission"
|
import { getAllPermissions } from "@/actions/permission"
|
||||||
|
import { Page } from "@/components/page"
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import {
|
import {
|
||||||
Table,
|
Table,
|
||||||
@@ -57,9 +58,11 @@ function generateScopeCode(roots: Node[]): string {
|
|||||||
|
|
||||||
export default function PermissionsPage() {
|
export default function PermissionsPage() {
|
||||||
return (
|
return (
|
||||||
|
<Page>
|
||||||
<Suspense>
|
<Suspense>
|
||||||
<PermissionTable />
|
<PermissionTable />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
|
</Page>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,7 +148,7 @@ function PermissionTable() {
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<Table className="bg-background rounded-lg">
|
<Table>
|
||||||
<TableHeader>
|
<TableHeader>
|
||||||
<TableRow className="h-10">
|
<TableRow className="h-10">
|
||||||
<TableHead>编码</TableHead>
|
<TableHead>编码</TableHead>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
getPageProductSku,
|
getPageProductSku,
|
||||||
} from "@/actions/product"
|
} from "@/actions/product"
|
||||||
import { DataTable, useDataTable } from "@/components/data-table"
|
import { DataTable, useDataTable } from "@/components/data-table"
|
||||||
|
import { Page } from "@/components/page"
|
||||||
import { SkuCodeBadge } from "@/components/products/format"
|
import { SkuCodeBadge } from "@/components/products/format"
|
||||||
import { Badge } from "@/components/ui/badge"
|
import { Badge } from "@/components/ui/badge"
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
@@ -28,10 +29,10 @@ export default function ProductPage() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="size-full flex gap-6 items-stretch">
|
<Page className="flex-row items-stretch">
|
||||||
<Products selected={selected} onSelect={setSelected} />
|
<Products selected={selected} onSelect={setSelected} />
|
||||||
<ProductSkus selected={selected} />
|
<ProductSkus selected={selected} />
|
||||||
</div>
|
</Page>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,625 +0,0 @@
|
|||||||
"use client"
|
|
||||||
import Link from "next/link"
|
|
||||||
import { useEffect, useState } from "react"
|
|
||||||
|
|
||||||
// 定义节点数据接口
|
|
||||||
interface ProxyNode {
|
|
||||||
id: string
|
|
||||||
ipAddress: string
|
|
||||||
location: {
|
|
||||||
country: string
|
|
||||||
region: string
|
|
||||||
}
|
|
||||||
type: string
|
|
||||||
status: "online" | "offline" | "warning"
|
|
||||||
responseTime: number
|
|
||||||
lastCheckTime: string
|
|
||||||
pool: string
|
|
||||||
isStatic: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export type ProxyNodesPageProps = {}
|
|
||||||
|
|
||||||
export default function ProxyNodesPage(props: ProxyNodesPageProps) {
|
|
||||||
const [loading, setLoading] = useState<boolean>(true)
|
|
||||||
|
|
||||||
const [nodes, setNodes] = useState<ProxyNode[]>([])
|
|
||||||
const [searchTerm, setSearchTerm] = useState<string>("")
|
|
||||||
const [filterStatus, setFilterStatus] = useState<string>("all")
|
|
||||||
const [filterType, setFilterType] = useState<string>("all")
|
|
||||||
const [filterPool, setFilterPool] = useState<string>("all")
|
|
||||||
|
|
||||||
// 模拟数据加载
|
|
||||||
useEffect(() => {
|
|
||||||
setTimeout(() => {
|
|
||||||
setNodes([
|
|
||||||
{
|
|
||||||
id: "ip-1",
|
|
||||||
ipAddress: "203.45.167.82",
|
|
||||||
location: { country: "美国", region: "纽约" },
|
|
||||||
type: "数据中心",
|
|
||||||
status: "online",
|
|
||||||
responseTime: 126,
|
|
||||||
lastCheckTime: "2024-05-10 15:30:22",
|
|
||||||
pool: "北美专用池",
|
|
||||||
isStatic: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "ip-2",
|
|
||||||
ipAddress: "185.72.193.54",
|
|
||||||
location: { country: "德国", region: "法兰克福" },
|
|
||||||
type: "住宅",
|
|
||||||
status: "online",
|
|
||||||
responseTime: 158,
|
|
||||||
lastCheckTime: "2024-05-10 15:28:45",
|
|
||||||
pool: "欧洲高速池",
|
|
||||||
isStatic: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "ip-3",
|
|
||||||
ipAddress: "118.96.244.105",
|
|
||||||
location: { country: "新加坡", region: "中心区" },
|
|
||||||
type: "移动",
|
|
||||||
status: "warning",
|
|
||||||
responseTime: 312,
|
|
||||||
lastCheckTime: "2024-05-10 15:25:12",
|
|
||||||
pool: "亚太地区池",
|
|
||||||
isStatic: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "ip-4",
|
|
||||||
ipAddress: "45.178.29.6",
|
|
||||||
location: { country: "加拿大", region: "多伦多" },
|
|
||||||
type: "数据中心",
|
|
||||||
status: "online",
|
|
||||||
responseTime: 143,
|
|
||||||
lastCheckTime: "2024-05-10 15:23:08",
|
|
||||||
pool: "北美专用池",
|
|
||||||
isStatic: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "ip-5",
|
|
||||||
ipAddress: "79.114.83.201",
|
|
||||||
location: { country: "英国", region: "伦敦" },
|
|
||||||
type: "住宅",
|
|
||||||
status: "offline",
|
|
||||||
responseTime: 0,
|
|
||||||
lastCheckTime: "2024-05-10 15:18:33",
|
|
||||||
pool: "欧洲高速池",
|
|
||||||
isStatic: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "ip-6",
|
|
||||||
ipAddress: "164.83.219.47",
|
|
||||||
location: { country: "日本", region: "东京" },
|
|
||||||
type: "住宅",
|
|
||||||
status: "online",
|
|
||||||
responseTime: 87,
|
|
||||||
lastCheckTime: "2024-05-10 15:15:21",
|
|
||||||
pool: "亚太地区池",
|
|
||||||
isStatic: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "ip-7",
|
|
||||||
ipAddress: "221.67.93.143",
|
|
||||||
location: { country: "中国", region: "上海" },
|
|
||||||
type: "移动",
|
|
||||||
status: "online",
|
|
||||||
responseTime: 104,
|
|
||||||
lastCheckTime: "2024-05-10 15:10:46",
|
|
||||||
pool: "亚太地区池",
|
|
||||||
isStatic: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "ip-8",
|
|
||||||
ipAddress: "37.209.148.72",
|
|
||||||
location: { country: "法国", region: "巴黎" },
|
|
||||||
type: "数据中心",
|
|
||||||
status: "warning",
|
|
||||||
responseTime: 276,
|
|
||||||
lastCheckTime: "2024-05-10 15:05:19",
|
|
||||||
pool: "欧洲高速池",
|
|
||||||
isStatic: false,
|
|
||||||
},
|
|
||||||
])
|
|
||||||
setLoading(false)
|
|
||||||
}, 800)
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
// 过滤节点数据
|
|
||||||
const filteredNodes = nodes.filter(node => {
|
|
||||||
return (
|
|
||||||
(searchTerm === "" ||
|
|
||||||
node.ipAddress.includes(searchTerm) ||
|
|
||||||
node.location.country.includes(searchTerm) ||
|
|
||||||
node.pool.includes(searchTerm)) &&
|
|
||||||
(filterStatus === "all" ||
|
|
||||||
(filterStatus === "online" && node.status === "online") ||
|
|
||||||
(filterStatus === "offline" && node.status === "offline") ||
|
|
||||||
(filterStatus === "warning" && node.status === "warning")) &&
|
|
||||||
(filterType === "all" || node.type === filterType) &&
|
|
||||||
(filterPool === "all" || node.pool === filterPool)
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="space-y-5">
|
|
||||||
{/* 概览区域 - 使用色块和留白风格 */}
|
|
||||||
<div className="border border-gray-200 rounded-lg overflow-hidden">
|
|
||||||
{/* 标题区域 - 简洁风格 */}
|
|
||||||
<div className="bg-white px-5 py-4">
|
|
||||||
<div className="flex justify-between items-center">
|
|
||||||
<h1 className="text-lg font-bold text-gray-900">节点列表</h1>
|
|
||||||
<div className="flex gap-2">
|
|
||||||
<button className="bg-gray-50 border border-gray-200 text-gray-700 px-3 py-1.5 rounded-md text-sm font-medium flex items-center hover:bg-gray-100">
|
|
||||||
<svg
|
|
||||||
className="w-4 h-4 mr-1"
|
|
||||||
fill="none"
|
|
||||||
stroke="currentColor"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
strokeLinecap="round"
|
|
||||||
strokeLinejoin="round"
|
|
||||||
strokeWidth={2}
|
|
||||||
d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
导出
|
|
||||||
</button>
|
|
||||||
<button className="bg-blue-600 hover:bg-blue-700 text-white px-3 py-1.5 rounded-md text-sm font-medium flex items-center">
|
|
||||||
<svg
|
|
||||||
className="w-4 h-4 mr-1"
|
|
||||||
fill="none"
|
|
||||||
stroke="currentColor"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
strokeLinecap="round"
|
|
||||||
strokeLinejoin="round"
|
|
||||||
strokeWidth={2}
|
|
||||||
d="M12 6v6m0 0v6m0-6h6m-6 0H6"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
添加节点
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<p className="mt-1 text-sm text-gray-500">
|
|
||||||
查看和管理所有代理IP资源,支持多维度筛选
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 统计信息区域 - 色块风格 */}
|
|
||||||
<div className="grid grid-cols-4 gap-px bg-gray-100">
|
|
||||||
{/* 总IP数量 */}
|
|
||||||
<div className="bg-white p-4">
|
|
||||||
<div className="flex items-center">
|
|
||||||
<div className="w-10 h-10 flex items-center justify-center bg-blue-50 rounded-md">
|
|
||||||
<svg
|
|
||||||
className="h-5 w-5 text-blue-600"
|
|
||||||
fill="none"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
stroke="currentColor"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
strokeLinecap="round"
|
|
||||||
strokeLinejoin="round"
|
|
||||||
strokeWidth={2}
|
|
||||||
d="M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
<div className="ml-3">
|
|
||||||
<p className="text-xs font-medium text-gray-500">总IP数量</p>
|
|
||||||
<div className="text-lg font-semibold text-gray-900">
|
|
||||||
152,487
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 在线IP */}
|
|
||||||
<div className="bg-white p-4">
|
|
||||||
<div className="flex items-center">
|
|
||||||
<div className="w-10 h-10 flex items-center justify-center bg-green-50 rounded-md">
|
|
||||||
<svg
|
|
||||||
className="h-5 w-5 text-green-600"
|
|
||||||
fill="none"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
stroke="currentColor"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
strokeLinecap="round"
|
|
||||||
strokeLinejoin="round"
|
|
||||||
strokeWidth={2}
|
|
||||||
d="M5 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
<div className="ml-3">
|
|
||||||
<div className="flex items-center">
|
|
||||||
<p className="text-xs font-medium text-gray-500">在线IP</p>
|
|
||||||
<span className="ml-2 text-xs font-medium text-green-600">
|
|
||||||
91%
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div className="text-lg font-semibold text-gray-900">
|
|
||||||
138,954
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* IP池分布 */}
|
|
||||||
<div className="bg-white p-4">
|
|
||||||
<div className="flex items-center">
|
|
||||||
<div className="w-10 h-10 flex items-center justify-center bg-indigo-50 rounded-md">
|
|
||||||
<svg
|
|
||||||
className="h-5 w-5 text-indigo-600"
|
|
||||||
fill="none"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
stroke="currentColor"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
strokeLinecap="round"
|
|
||||||
strokeLinejoin="round"
|
|
||||||
strokeWidth={2}
|
|
||||||
d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
<div className="ml-3">
|
|
||||||
<div className="flex items-center">
|
|
||||||
<p className="text-xs font-medium text-gray-500">IP池分布</p>
|
|
||||||
<span className="ml-2 text-xs font-medium text-gray-500">
|
|
||||||
5个地区
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div className="text-lg font-semibold text-gray-900">12</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 异常IP */}
|
|
||||||
<div className="bg-white p-4">
|
|
||||||
<div className="flex items-center">
|
|
||||||
<div className="w-10 h-10 flex items-center justify-center bg-red-50 rounded-md">
|
|
||||||
<svg
|
|
||||||
className="h-5 w-5 text-red-600"
|
|
||||||
fill="none"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
stroke="currentColor"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
strokeLinecap="round"
|
|
||||||
strokeLinejoin="round"
|
|
||||||
strokeWidth={2}
|
|
||||||
d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
<div className="ml-3">
|
|
||||||
<div className="flex items-center">
|
|
||||||
<p className="text-xs font-medium text-gray-500">异常IP</p>
|
|
||||||
<span className="ml-2 text-xs font-medium text-red-600">
|
|
||||||
需检查
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div className="text-lg font-semibold text-gray-900">1,205</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 数据展示 */}
|
|
||||||
<div className="border border-gray-200 rounded-lg overflow-hidden">
|
|
||||||
{/* 筛选搜索区域 */}
|
|
||||||
<div className="bg-white p-4 border-b border-gray-200">
|
|
||||||
<div className="grid grid-cols-1 gap-4 md:grid-cols-12">
|
|
||||||
{/* 搜索框 */}
|
|
||||||
<div className="relative md:col-span-5">
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
placeholder="搜索IP地址、地区或标签..."
|
|
||||||
className="w-full px-3 py-2 bg-gray-50 border border-gray-300 rounded-md focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-blue-500 text-sm"
|
|
||||||
/>
|
|
||||||
<svg
|
|
||||||
className="absolute right-3 top-2.5 h-4 w-4 text-gray-400"
|
|
||||||
fill="none"
|
|
||||||
stroke="currentColor"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
strokeLinecap="round"
|
|
||||||
strokeLinejoin="round"
|
|
||||||
strokeWidth={2}
|
|
||||||
d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 筛选区域 */}
|
|
||||||
<div className="flex space-x-3 md:col-span-7">
|
|
||||||
<select
|
|
||||||
className="px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-blue-500 text-sm bg-white text-gray-700 flex-1"
|
|
||||||
value={filterStatus}
|
|
||||||
onChange={e => setFilterStatus(e.target.value)}
|
|
||||||
>
|
|
||||||
<option value="all">全部状态</option>
|
|
||||||
<option value="online">在线</option>
|
|
||||||
<option value="offline">离线</option>
|
|
||||||
<option value="warning">异常</option>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select
|
|
||||||
className="px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-blue-500 text-sm bg-white text-gray-700 flex-1"
|
|
||||||
value={filterType}
|
|
||||||
onChange={e => setFilterType(e.target.value)}
|
|
||||||
>
|
|
||||||
<option value="all">全部类型</option>
|
|
||||||
<option value="数据中心">数据中心</option>
|
|
||||||
<option value="住宅">住宅</option>
|
|
||||||
<option value="移动">移动</option>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select
|
|
||||||
className="px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-blue-500 text-sm bg-white text-gray-700 flex-1"
|
|
||||||
value={filterPool}
|
|
||||||
onChange={e => setFilterPool(e.target.value)}
|
|
||||||
>
|
|
||||||
<option value="all">全部池</option>
|
|
||||||
<option value="北美专用池">北美专用池</option>
|
|
||||||
<option value="欧洲高速池">欧洲高速池</option>
|
|
||||||
<option value="亚太地区池">亚太地区池</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* IP表格区域 */}
|
|
||||||
{loading ? (
|
|
||||||
<div className="p-12 flex justify-center items-center bg-white">
|
|
||||||
<svg
|
|
||||||
className="animate-spin h-6 w-6 text-blue-600"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
fill="none"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
>
|
|
||||||
<circle
|
|
||||||
className="opacity-25"
|
|
||||||
cx="12"
|
|
||||||
cy="12"
|
|
||||||
r="10"
|
|
||||||
stroke="currentColor"
|
|
||||||
strokeWidth="4"
|
|
||||||
></circle>
|
|
||||||
<path
|
|
||||||
className="opacity-75"
|
|
||||||
fill="currentColor"
|
|
||||||
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
|
||||||
></path>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div className="overflow-x-auto bg-white">
|
|
||||||
<table className="min-w-full">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th
|
|
||||||
scope="col"
|
|
||||||
className="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider border-b border-gray-200 bg-gray-50"
|
|
||||||
>
|
|
||||||
IP地址
|
|
||||||
</th>
|
|
||||||
<th
|
|
||||||
scope="col"
|
|
||||||
className="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider border-b border-gray-200 bg-gray-50"
|
|
||||||
>
|
|
||||||
位置
|
|
||||||
</th>
|
|
||||||
<th
|
|
||||||
scope="col"
|
|
||||||
className="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider border-b border-gray-200 bg-gray-50"
|
|
||||||
>
|
|
||||||
类型
|
|
||||||
</th>
|
|
||||||
<th
|
|
||||||
scope="col"
|
|
||||||
className="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider border-b border-gray-200 bg-gray-50"
|
|
||||||
>
|
|
||||||
状态
|
|
||||||
</th>
|
|
||||||
<th
|
|
||||||
scope="col"
|
|
||||||
className="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider border-b border-gray-200 bg-gray-50"
|
|
||||||
>
|
|
||||||
响应时间
|
|
||||||
</th>
|
|
||||||
<th
|
|
||||||
scope="col"
|
|
||||||
className="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider border-b border-gray-200 bg-gray-50"
|
|
||||||
>
|
|
||||||
所属池
|
|
||||||
</th>
|
|
||||||
<th
|
|
||||||
scope="col"
|
|
||||||
className="px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider border-b border-gray-200 bg-gray-50"
|
|
||||||
>
|
|
||||||
操作
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody className="divide-y divide-gray-200">
|
|
||||||
{filteredNodes.map((node, index) => (
|
|
||||||
<tr
|
|
||||||
key={node.id}
|
|
||||||
className={index % 2 === 0 ? "bg-white" : "bg-gray-50"}
|
|
||||||
>
|
|
||||||
<td className="px-4 py-3 whitespace-nowrap text-sm">
|
|
||||||
<div className="flex items-center">
|
|
||||||
<span
|
|
||||||
className={`w-2 h-2 rounded-full mr-2 ${
|
|
||||||
node.status === "online"
|
|
||||||
? "bg-green-500"
|
|
||||||
: node.status === "offline"
|
|
||||||
? "bg-red-500"
|
|
||||||
: "bg-yellow-500"
|
|
||||||
}`}
|
|
||||||
></span>
|
|
||||||
<span className="font-medium text-gray-900">
|
|
||||||
{node.ipAddress}
|
|
||||||
</span>
|
|
||||||
{node.isStatic && (
|
|
||||||
<span className="ml-2 inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
|
|
||||||
静态
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td className="px-4 py-3 whitespace-nowrap text-sm">
|
|
||||||
<div className="text-gray-900">
|
|
||||||
{node.location.country}
|
|
||||||
</div>
|
|
||||||
<div className="text-xs text-gray-500">
|
|
||||||
{node.location.region}
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td className="px-4 py-3 whitespace-nowrap">
|
|
||||||
<span
|
|
||||||
className={`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${
|
|
||||||
node.type === "数据中心"
|
|
||||||
? "bg-purple-100 text-purple-800"
|
|
||||||
: node.type === "住宅"
|
|
||||||
? "bg-blue-100 text-blue-800"
|
|
||||||
: "bg-indigo-100 text-indigo-800"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
{node.type}
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td className="px-4 py-3 whitespace-nowrap text-sm">
|
|
||||||
<span
|
|
||||||
className={`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${
|
|
||||||
node.status === "online"
|
|
||||||
? "bg-green-100 text-green-800"
|
|
||||||
: node.status === "offline"
|
|
||||||
? "bg-red-100 text-red-800"
|
|
||||||
: "bg-yellow-100 text-yellow-800"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
{node.status === "online"
|
|
||||||
? "在线"
|
|
||||||
: node.status === "offline"
|
|
||||||
? "离线"
|
|
||||||
: "异常"}
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td className="px-4 py-3 whitespace-nowrap text-sm text-gray-500">
|
|
||||||
{node.responseTime > 0 ? (
|
|
||||||
<div className="flex items-center">
|
|
||||||
<span
|
|
||||||
className={`font-medium ${
|
|
||||||
node.responseTime < 150
|
|
||||||
? "text-green-600"
|
|
||||||
: node.responseTime < 250
|
|
||||||
? "text-yellow-600"
|
|
||||||
: "text-red-600"
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
{node.responseTime} ms
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<span className="text-gray-400">-</span>
|
|
||||||
)}
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td className="px-4 py-3 whitespace-nowrap text-sm text-gray-500">
|
|
||||||
{node.pool}
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td className="px-4 py-3 whitespace-nowrap text-right text-sm font-medium space-x-2">
|
|
||||||
<Link
|
|
||||||
href={`/proxy/nodes/${node.id}`}
|
|
||||||
className="text-blue-600 hover:text-blue-900"
|
|
||||||
>
|
|
||||||
详情
|
|
||||||
</Link>
|
|
||||||
<button className="text-gray-600 hover:text-gray-900">
|
|
||||||
编辑
|
|
||||||
</button>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
))}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* 分页控制 */}
|
|
||||||
<div className="bg-gray-50 px-5 py-3 border-t border-gray-200">
|
|
||||||
<div className="flex items-center justify-between">
|
|
||||||
<div className="text-sm text-gray-700">
|
|
||||||
显示 <span className="font-medium">1</span> 至{" "}
|
|
||||||
<span className="font-medium">8</span> 条,共{" "}
|
|
||||||
<span className="font-medium">152,487</span> 条结果
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<nav className="relative z-0 inline-flex -space-x-px">
|
|
||||||
<button className="relative inline-flex items-center px-2 py-1.5 rounded-l-md border border-gray-300 bg-white text-sm font-medium text-gray-500 hover:bg-gray-50">
|
|
||||||
<svg
|
|
||||||
className="h-4 w-4"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
viewBox="0 0 20 20"
|
|
||||||
fill="currentColor"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
fillRule="evenodd"
|
|
||||||
d="M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z"
|
|
||||||
clipRule="evenodd"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
<button className="relative inline-flex items-center px-3 py-1.5 border border-gray-300 bg-white text-sm font-medium hover:bg-gray-50 text-blue-600 bg-blue-50 border-blue-300">
|
|
||||||
1
|
|
||||||
</button>
|
|
||||||
<button className="relative inline-flex items-center px-3 py-1.5 border border-gray-300 bg-white text-sm font-medium text-gray-700 hover:bg-gray-50">
|
|
||||||
2
|
|
||||||
</button>
|
|
||||||
<button className="relative inline-flex items-center px-3 py-1.5 border border-gray-300 bg-white text-sm font-medium text-gray-700 hover:bg-gray-50">
|
|
||||||
3
|
|
||||||
</button>
|
|
||||||
<span className="relative inline-flex items-center px-3 py-1.5 border border-gray-300 bg-white text-sm font-medium text-gray-700">
|
|
||||||
...
|
|
||||||
</span>
|
|
||||||
<button className="relative inline-flex items-center px-3 py-1.5 border border-gray-300 bg-white text-sm font-medium text-gray-700 hover:bg-gray-50">
|
|
||||||
152
|
|
||||||
</button>
|
|
||||||
<button className="relative inline-flex items-center px-2 py-1.5 rounded-r-md border border-gray-300 bg-white text-sm font-medium text-gray-500 hover:bg-gray-50">
|
|
||||||
<svg
|
|
||||||
className="h-4 w-4"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
viewBox="0 0 20 20"
|
|
||||||
fill="currentColor"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
fillRule="evenodd"
|
|
||||||
d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z"
|
|
||||||
clipRule="evenodd"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -1,527 +0,0 @@
|
|||||||
"use client"
|
|
||||||
import Link from "next/link"
|
|
||||||
import { useEffect, useState } from "react"
|
|
||||||
|
|
||||||
export type ProxyPoolsPageProps = {}
|
|
||||||
|
|
||||||
// 定义IP池接口
|
|
||||||
interface ProxyPool {
|
|
||||||
id: string
|
|
||||||
name: string
|
|
||||||
description: string
|
|
||||||
ips: number
|
|
||||||
activeIps: number
|
|
||||||
region: string
|
|
||||||
type: string
|
|
||||||
createdAt: string
|
|
||||||
status: "active" | "inactive" | "maintenance"
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function ProxyPoolsPage(props: ProxyPoolsPageProps) {
|
|
||||||
const [pools, setPools] = useState<ProxyPool[]>([])
|
|
||||||
const [loading, setLoading] = useState<boolean>(true)
|
|
||||||
const [searchTerm, setSearchTerm] = useState<string>("")
|
|
||||||
const [filterStatus, setFilterStatus] = useState<string>("all")
|
|
||||||
const [filterRegion, setFilterRegion] = useState<string>("all")
|
|
||||||
|
|
||||||
// 模拟数据加载
|
|
||||||
useEffect(() => {
|
|
||||||
// 实际项目中替换为API调用
|
|
||||||
setTimeout(() => {
|
|
||||||
setPools([
|
|
||||||
{
|
|
||||||
id: "pool-1",
|
|
||||||
name: "全球通用池",
|
|
||||||
description: "包含全球多个地区的高质量IP",
|
|
||||||
ips: 5000,
|
|
||||||
activeIps: 4328,
|
|
||||||
region: "全球",
|
|
||||||
type: "住宅IP",
|
|
||||||
createdAt: "2023-10-15",
|
|
||||||
status: "active",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "pool-2",
|
|
||||||
name: "北美专用池",
|
|
||||||
description: "美国和加拿大地区专用IP池",
|
|
||||||
ips: 3200,
|
|
||||||
activeIps: 2950,
|
|
||||||
region: "北美",
|
|
||||||
type: "数据中心IP",
|
|
||||||
createdAt: "2023-11-02",
|
|
||||||
status: "active",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "pool-3",
|
|
||||||
name: "欧洲高速池",
|
|
||||||
description: "欧洲地区高速稳定IP",
|
|
||||||
ips: 2800,
|
|
||||||
activeIps: 2180,
|
|
||||||
region: "欧洲",
|
|
||||||
type: "住宅IP",
|
|
||||||
createdAt: "2023-09-28",
|
|
||||||
status: "active",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "pool-4",
|
|
||||||
name: "亚太地区池",
|
|
||||||
description: "亚洲和太平洋地区IP",
|
|
||||||
ips: 4200,
|
|
||||||
activeIps: 3890,
|
|
||||||
region: "亚太",
|
|
||||||
type: "移动IP",
|
|
||||||
createdAt: "2023-12-05",
|
|
||||||
status: "maintenance",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "pool-5",
|
|
||||||
name: "电商专用池",
|
|
||||||
description: "适用于电商平台的IP池",
|
|
||||||
ips: 1500,
|
|
||||||
activeIps: 1200,
|
|
||||||
region: "全球",
|
|
||||||
type: "住宅IP",
|
|
||||||
createdAt: "2024-01-10",
|
|
||||||
status: "inactive",
|
|
||||||
},
|
|
||||||
])
|
|
||||||
setLoading(false)
|
|
||||||
}, 800)
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
// 过滤IP池
|
|
||||||
const filteredPools = pools.filter(pool => {
|
|
||||||
return (
|
|
||||||
(searchTerm === "" ||
|
|
||||||
pool.name.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
|
||||||
pool.description.toLowerCase().includes(searchTerm.toLowerCase())) &&
|
|
||||||
(filterStatus === "all" || pool.status === filterStatus) &&
|
|
||||||
(filterRegion === "all" || pool.region === filterRegion)
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
// 获取状态颜色和文本
|
|
||||||
const getStatusInfo = (status: string) => {
|
|
||||||
switch (status) {
|
|
||||||
case "active":
|
|
||||||
return { color: "bg-green-100 text-green-800", text: "运行中" }
|
|
||||||
case "inactive":
|
|
||||||
return { color: "bg-gray-100 text-gray-800", text: "未启用" }
|
|
||||||
case "maintenance":
|
|
||||||
return { color: "bg-yellow-100 text-yellow-800", text: "维护中" }
|
|
||||||
default:
|
|
||||||
return { color: "bg-gray-100 text-gray-800", text: "未知" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="space-y-6">
|
|
||||||
{/* 页面标题 */}
|
|
||||||
<div className="flex justify-between items-center">
|
|
||||||
<div>
|
|
||||||
<h1 className="text-2xl font-bold text-gray-900">IP池管理</h1>
|
|
||||||
<p className="mt-1 text-sm text-gray-500">管理和配置代理IP池</p>
|
|
||||||
</div>
|
|
||||||
<button className="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-md text-sm font-medium flex items-center">
|
|
||||||
<svg
|
|
||||||
className="w-4 h-4 mr-2"
|
|
||||||
fill="none"
|
|
||||||
stroke="currentColor"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
strokeLinecap="round"
|
|
||||||
strokeLinejoin="round"
|
|
||||||
strokeWidth={2}
|
|
||||||
d="M12 6v6m0 0v6m0-6h6m-6 0H6"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
创建新IP池
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 筛选和搜索工具栏 */}
|
|
||||||
<div className="bg-white p-4 rounded-lg shadow-sm border border-gray-200">
|
|
||||||
<div className="grid grid-cols-1 gap-4 md:grid-cols-3">
|
|
||||||
<div className="relative">
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
placeholder="搜索IP池..."
|
|
||||||
className="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"
|
|
||||||
value={searchTerm}
|
|
||||||
onChange={e => setSearchTerm(e.target.value)}
|
|
||||||
/>
|
|
||||||
<svg
|
|
||||||
className="absolute right-3 top-2.5 h-5 w-5 text-gray-400"
|
|
||||||
fill="none"
|
|
||||||
stroke="currentColor"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
strokeLinecap="round"
|
|
||||||
strokeLinejoin="round"
|
|
||||||
strokeWidth={2}
|
|
||||||
d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex space-x-4">
|
|
||||||
<div className="w-full">
|
|
||||||
<label className="block text-sm font-medium text-gray-700 mb-1">
|
|
||||||
状态
|
|
||||||
</label>
|
|
||||||
<select
|
|
||||||
className="w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"
|
|
||||||
value={filterStatus}
|
|
||||||
onChange={e => setFilterStatus(e.target.value)}
|
|
||||||
>
|
|
||||||
<option value="all">全部状态</option>
|
|
||||||
<option value="active">运行中</option>
|
|
||||||
<option value="inactive">未启用</option>
|
|
||||||
<option value="maintenance">维护中</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="w-full">
|
|
||||||
<label className="block text-sm font-medium text-gray-700 mb-1">
|
|
||||||
地区
|
|
||||||
</label>
|
|
||||||
<select
|
|
||||||
className="w-full px-3 py-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500"
|
|
||||||
value={filterRegion}
|
|
||||||
onChange={e => setFilterRegion(e.target.value)}
|
|
||||||
>
|
|
||||||
<option value="all">全部地区</option>
|
|
||||||
<option value="全球">全球</option>
|
|
||||||
<option value="北美">北美</option>
|
|
||||||
<option value="欧洲">欧洲</option>
|
|
||||||
<option value="亚太">亚太</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* IP池列表 */}
|
|
||||||
<div className="bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden">
|
|
||||||
{loading ? (
|
|
||||||
<div className="p-8 flex justify-center">
|
|
||||||
<svg
|
|
||||||
className="animate-spin h-8 w-8 text-blue-600"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
fill="none"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
>
|
|
||||||
<circle
|
|
||||||
className="opacity-25"
|
|
||||||
cx="12"
|
|
||||||
cy="12"
|
|
||||||
r="10"
|
|
||||||
stroke="currentColor"
|
|
||||||
strokeWidth="4"
|
|
||||||
></circle>
|
|
||||||
<path
|
|
||||||
className="opacity-75"
|
|
||||||
fill="currentColor"
|
|
||||||
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
|
||||||
></path>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
) : filteredPools.length === 0 ? (
|
|
||||||
<div className="p-8 text-center">
|
|
||||||
<svg
|
|
||||||
className="mx-auto h-12 w-12 text-gray-400"
|
|
||||||
fill="none"
|
|
||||||
stroke="currentColor"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
strokeLinecap="round"
|
|
||||||
strokeLinejoin="round"
|
|
||||||
strokeWidth={1.5}
|
|
||||||
d="M9.172 16.172a4 4 0 015.656 0M9 10h.01M15 10h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
<p className="mt-4 text-gray-500 text-lg">没有找到匹配的IP池</p>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div className="overflow-x-auto">
|
|
||||||
<table className="min-w-full divide-y divide-gray-200">
|
|
||||||
<thead className="bg-gray-50">
|
|
||||||
<tr>
|
|
||||||
<th
|
|
||||||
scope="col"
|
|
||||||
className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
|
|
||||||
>
|
|
||||||
IP池名称
|
|
||||||
</th>
|
|
||||||
<th
|
|
||||||
scope="col"
|
|
||||||
className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
|
|
||||||
>
|
|
||||||
IP概况
|
|
||||||
</th>
|
|
||||||
<th
|
|
||||||
scope="col"
|
|
||||||
className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
|
|
||||||
>
|
|
||||||
地区
|
|
||||||
</th>
|
|
||||||
<th
|
|
||||||
scope="col"
|
|
||||||
className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
|
|
||||||
>
|
|
||||||
IP类型
|
|
||||||
</th>
|
|
||||||
<th
|
|
||||||
scope="col"
|
|
||||||
className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
|
|
||||||
>
|
|
||||||
状态
|
|
||||||
</th>
|
|
||||||
<th
|
|
||||||
scope="col"
|
|
||||||
className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
|
|
||||||
>
|
|
||||||
创建日期
|
|
||||||
</th>
|
|
||||||
<th
|
|
||||||
scope="col"
|
|
||||||
className="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider"
|
|
||||||
>
|
|
||||||
操作
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody className="bg-white divide-y divide-gray-200">
|
|
||||||
{filteredPools.map(pool => {
|
|
||||||
const statusInfo = getStatusInfo(pool.status)
|
|
||||||
return (
|
|
||||||
<tr key={pool.id} className="hover:bg-gray-50">
|
|
||||||
<td className="px-6 py-4 whitespace-nowrap">
|
|
||||||
<div className="flex items-center">
|
|
||||||
<div>
|
|
||||||
<div className="text-sm font-medium text-gray-900">
|
|
||||||
{pool.name}
|
|
||||||
</div>
|
|
||||||
<div className="text-sm text-gray-500 max-w-xs truncate">
|
|
||||||
{pool.description}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td className="px-6 py-4 whitespace-nowrap">
|
|
||||||
<div className="text-sm text-gray-900">
|
|
||||||
总IP: {pool.ips.toLocaleString()}
|
|
||||||
</div>
|
|
||||||
<div className="text-sm text-gray-500">
|
|
||||||
活跃IP: {pool.activeIps.toLocaleString()}
|
|
||||||
</div>
|
|
||||||
<div className="w-full bg-gray-200 rounded-full h-1.5 mt-1.5">
|
|
||||||
<div
|
|
||||||
className="bg-blue-600 h-1.5 rounded-full"
|
|
||||||
style={{
|
|
||||||
width: `${(pool.activeIps / pool.ips) * 100}%`,
|
|
||||||
}}
|
|
||||||
></div>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td className="px-6 py-4 whitespace-nowrap">
|
|
||||||
<div className="text-sm text-gray-900">
|
|
||||||
{pool.region}
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td className="px-6 py-4 whitespace-nowrap">
|
|
||||||
<div className="text-sm text-gray-900">{pool.type}</div>
|
|
||||||
</td>
|
|
||||||
<td className="px-6 py-4 whitespace-nowrap">
|
|
||||||
<span
|
|
||||||
className={`px-2 inline-flex text-xs leading-5 font-semibold rounded-full ${statusInfo.color}`}
|
|
||||||
>
|
|
||||||
{statusInfo.text}
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
|
||||||
{pool.createdAt}
|
|
||||||
</td>
|
|
||||||
<td className="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
|
|
||||||
<Link
|
|
||||||
href={`/proxy/pools/${pool.id}`}
|
|
||||||
className="text-blue-600 hover:text-blue-900 mr-4"
|
|
||||||
>
|
|
||||||
详情
|
|
||||||
</Link>
|
|
||||||
<Link
|
|
||||||
href={`/proxy/pools/${pool.id}/edit`}
|
|
||||||
className="text-indigo-600 hover:text-indigo-900 mr-4"
|
|
||||||
>
|
|
||||||
编辑
|
|
||||||
</Link>
|
|
||||||
<button className="text-red-600 hover:text-red-900">
|
|
||||||
删除
|
|
||||||
</button>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
)
|
|
||||||
})}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 数据卡片概览 */}
|
|
||||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-6">
|
|
||||||
<div className="bg-white p-6 rounded-lg shadow-sm border border-gray-200">
|
|
||||||
<div className="flex items-center">
|
|
||||||
<div className="p-3 rounded-full bg-blue-100 text-blue-600">
|
|
||||||
<svg
|
|
||||||
className="h-6 w-6"
|
|
||||||
fill="none"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
stroke="currentColor"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
strokeLinecap="round"
|
|
||||||
strokeLinejoin="round"
|
|
||||||
strokeWidth={2}
|
|
||||||
d="M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2m-2-4h.01M17 16h.01"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
<div className="ml-4">
|
|
||||||
<h3 className="text-lg font-medium text-gray-900">总IP池</h3>
|
|
||||||
<div className="mt-1 text-3xl font-semibold">{pools.length}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="mt-4">
|
|
||||||
<div className="flex justify-between text-sm">
|
|
||||||
<span className="text-gray-500">活跃IP池</span>
|
|
||||||
<span className="font-medium text-gray-900">
|
|
||||||
{pools.filter(p => p.status === "active").length}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="bg-white p-6 rounded-lg shadow-sm border border-gray-200">
|
|
||||||
<div className="flex items-center">
|
|
||||||
<div className="p-3 rounded-full bg-green-100 text-green-600">
|
|
||||||
<svg
|
|
||||||
className="h-6 w-6"
|
|
||||||
fill="none"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
stroke="currentColor"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
strokeLinecap="round"
|
|
||||||
strokeLinejoin="round"
|
|
||||||
strokeWidth={2}
|
|
||||||
d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
<div className="ml-4">
|
|
||||||
<h3 className="text-lg font-medium text-gray-900">总IP数量</h3>
|
|
||||||
<div className="mt-1 text-3xl font-semibold">
|
|
||||||
{pools
|
|
||||||
.reduce((sum, pool) => sum + pool.ips, 0)
|
|
||||||
.toLocaleString()}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="mt-4">
|
|
||||||
<div className="flex justify-between text-sm">
|
|
||||||
<span className="text-gray-500">活跃IP</span>
|
|
||||||
<span className="font-medium text-gray-900">
|
|
||||||
{pools
|
|
||||||
.reduce((sum, pool) => sum + pool.activeIps, 0)
|
|
||||||
.toLocaleString()}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="bg-white p-6 rounded-lg shadow-sm border border-gray-200">
|
|
||||||
<div className="flex items-center">
|
|
||||||
<div className="p-3 rounded-full bg-purple-100 text-purple-600">
|
|
||||||
<svg
|
|
||||||
className="h-6 w-6"
|
|
||||||
fill="none"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
stroke="currentColor"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
strokeLinecap="round"
|
|
||||||
strokeLinejoin="round"
|
|
||||||
strokeWidth={2}
|
|
||||||
d="M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
<div className="ml-4">
|
|
||||||
<h3 className="text-lg font-medium text-gray-900">IP利用率</h3>
|
|
||||||
<div className="mt-1 text-3xl font-semibold">
|
|
||||||
{Math.round(
|
|
||||||
(pools.reduce((sum, pool) => sum + pool.activeIps, 0) /
|
|
||||||
pools.reduce((sum, pool) => sum + pool.ips, 0)) *
|
|
||||||
100,
|
|
||||||
)}
|
|
||||||
%
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="mt-4">
|
|
||||||
<div className="w-full bg-gray-200 rounded-full h-2">
|
|
||||||
<div
|
|
||||||
className="bg-purple-600 h-2 rounded-full"
|
|
||||||
style={{
|
|
||||||
width: `${
|
|
||||||
(pools.reduce((sum, pool) => sum + pool.activeIps, 0) /
|
|
||||||
pools.reduce((sum, pool) => sum + pool.ips, 0)) *
|
|
||||||
100
|
|
||||||
}%`,
|
|
||||||
}}
|
|
||||||
></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* 操作指南 */}
|
|
||||||
<div className="bg-blue-50 p-4 rounded-lg border border-blue-200">
|
|
||||||
<div className="flex">
|
|
||||||
<div className="flex-shrink-0">
|
|
||||||
<svg
|
|
||||||
className="h-5 w-5 text-blue-600"
|
|
||||||
fill="none"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
stroke="currentColor"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
strokeLinecap="round"
|
|
||||||
strokeLinejoin="round"
|
|
||||||
strokeWidth={2}
|
|
||||||
d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
<div className="ml-3 flex-1 md:flex md:justify-between">
|
|
||||||
<p className="text-sm text-blue-700">
|
|
||||||
IP池是管理IP资源的基础单位。您可以创建不同用途的IP池,并为客户分配相应的访问权限。
|
|
||||||
</p>
|
|
||||||
<p className="mt-3 text-sm md:mt-0 md:ml-6">
|
|
||||||
<a
|
|
||||||
href="/help/proxy-pools"
|
|
||||||
className="whitespace-nowrap font-medium text-blue-700 hover:text-blue-600"
|
|
||||||
>
|
|
||||||
查看文档 <span aria-hidden="true">→</span>
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
updateResource,
|
updateResource,
|
||||||
} from "@/actions/resources"
|
} from "@/actions/resources"
|
||||||
import { DataTable, useDataTable } from "@/components/data-table"
|
import { DataTable, useDataTable } from "@/components/data-table"
|
||||||
|
import { Page } from "@/components/page"
|
||||||
import { Badge } from "@/components/ui/badge"
|
import { Badge } from "@/components/ui/badge"
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import {
|
import {
|
||||||
@@ -169,22 +170,17 @@ function getTodayUsage(lastAt: Date | null | undefined, daily: number) {
|
|||||||
|
|
||||||
export default function ResourcesPage() {
|
export default function ResourcesPage() {
|
||||||
return (
|
return (
|
||||||
<div>
|
<Page>
|
||||||
<Tabs defaultValue="short">
|
<Tabs defaultValue="short">
|
||||||
<TabsList className="bg-card p-1.5 rounded-lg">
|
<TabsList className="bg-card">
|
||||||
<TabsTrigger
|
<TabsTrigger value="short" className="h-10 px-4 shadow-none">
|
||||||
value="short"
|
|
||||||
className="w-30 h-9 data-[state=active]:bg-primary-muted text-base rounded-md"
|
|
||||||
>
|
|
||||||
短效套餐
|
短效套餐
|
||||||
</TabsTrigger>
|
</TabsTrigger>
|
||||||
<TabsTrigger
|
<TabsTrigger value="long" className="h-10 px-4 shadow-none">
|
||||||
value="long"
|
|
||||||
className="w-30 h-9 data-[state=active]:bg-primary-muted text-base rounded-md"
|
|
||||||
>
|
|
||||||
长效套餐
|
长效套餐
|
||||||
</TabsTrigger>
|
</TabsTrigger>
|
||||||
</TabsList>
|
</TabsList>
|
||||||
|
|
||||||
<TabsContent value="short" className="flex flex-col gap-4">
|
<TabsContent value="short" className="flex flex-col gap-4">
|
||||||
<ResourceList resourceType="short" />
|
<ResourceList resourceType="short" />
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
@@ -192,7 +188,7 @@ export default function ResourcesPage() {
|
|||||||
<ResourceList resourceType="long" />
|
<ResourceList resourceType="long" />
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</div>
|
</Page>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -422,7 +418,7 @@ function ResourceList({ resourceType }: ResourceListProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
<form onSubmit={onFilter} className="bg-white p-4 rounded-lg">
|
<form onSubmit={onFilter} className="bg-card p-4 rounded-lg">
|
||||||
<div className="flex flex-wrap items-end gap-4">
|
<div className="flex flex-wrap items-end gap-4">
|
||||||
<Controller
|
<Controller
|
||||||
name="user_phone"
|
name="user_phone"
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { Suspense, useState } from "react"
|
|||||||
import { toast } from "sonner"
|
import { toast } from "sonner"
|
||||||
import { deleteRole, getPageRole, updateRole } from "@/actions/role"
|
import { deleteRole, getPageRole, updateRole } from "@/actions/role"
|
||||||
import { DataTable, useDataTable } from "@/components/data-table"
|
import { DataTable, useDataTable } from "@/components/data-table"
|
||||||
|
import { Page } from "@/components/page"
|
||||||
import {
|
import {
|
||||||
AlertDialog,
|
AlertDialog,
|
||||||
AlertDialogAction,
|
AlertDialogAction,
|
||||||
@@ -31,7 +32,7 @@ export default function RolesPage() {
|
|||||||
const table = useDataTable((page, size) => getPageRole({ page, size }))
|
const table = useDataTable((page, size) => getPageRole({ page, size }))
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-3">
|
<Page>
|
||||||
{/* 操作栏 */}
|
{/* 操作栏 */}
|
||||||
<div className="flex justify-between items-stretch">
|
<div className="flex justify-between items-stretch">
|
||||||
<div className="flex gap-3">
|
<div className="flex gap-3">
|
||||||
@@ -78,7 +79,7 @@ export default function RolesPage() {
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</div>
|
</Page>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { Controller, useForm } from "react-hook-form"
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
import { getPageTrade } from "@/actions/trade"
|
import { getPageTrade } from "@/actions/trade"
|
||||||
import { DataTable, useDataTable } from "@/components/data-table"
|
import { DataTable, useDataTable } from "@/components/data-table"
|
||||||
|
import { Page } from "@/components/page"
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import {
|
import {
|
||||||
Field,
|
Field,
|
||||||
@@ -111,8 +112,9 @@ export default function TradePage() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-3">
|
<Page>
|
||||||
<form onSubmit={onFilter} className="bg-white p-4">
|
{/* 筛选表单 */}
|
||||||
|
<form onSubmit={onFilter} className="bg-card p-4 rounded-lg">
|
||||||
<div className="flex flex-wrap items-end gap-4">
|
<div className="flex flex-wrap items-end gap-4">
|
||||||
<Controller
|
<Controller
|
||||||
name="user_phone"
|
name="user_phone"
|
||||||
@@ -366,6 +368,6 @@ export default function TradePage() {
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</div>
|
</Page>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { z } from "zod"
|
|||||||
import { bindAdmin, getPageUserPage } from "@/actions/user"
|
import { bindAdmin, getPageUserPage } from "@/actions/user"
|
||||||
import { Auth } from "@/components/auth"
|
import { Auth } from "@/components/auth"
|
||||||
import { DataTable, useDataTable } from "@/components/data-table"
|
import { DataTable, useDataTable } from "@/components/data-table"
|
||||||
|
import { Page } from "@/components/page"
|
||||||
import { Badge } from "@/components/ui/badge"
|
import { Badge } from "@/components/ui/badge"
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import {
|
import {
|
||||||
@@ -60,8 +61,8 @@ export default function UserPage() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-3">
|
<Page>
|
||||||
<form onSubmit={onFilter} className="bg-white p-4">
|
<form onSubmit={onFilter} className="bg-card p-4 rounded-lg">
|
||||||
<div className="flex flex-wrap items-end gap-4">
|
<div className="flex flex-wrap items-end gap-4">
|
||||||
<Controller
|
<Controller
|
||||||
name="phone"
|
name="phone"
|
||||||
@@ -196,6 +197,6 @@ export default function UserPage() {
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</div>
|
</Page>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ import { Loader } from "lucide-react"
|
|||||||
import type { CSSProperties } from "react"
|
import type { CSSProperties } from "react"
|
||||||
import { Pagination, type PaginationProps } from "@/components/ui/pagination"
|
import { Pagination, type PaginationProps } from "@/components/ui/pagination"
|
||||||
import {
|
import {
|
||||||
|
Table,
|
||||||
TableBody,
|
TableBody,
|
||||||
TableCell,
|
TableCell,
|
||||||
TableHead,
|
TableHead,
|
||||||
TableHeader,
|
TableHeader,
|
||||||
Table as TableRoot,
|
|
||||||
TableRow,
|
TableRow,
|
||||||
} from "@/components/ui/table"
|
} from "@/components/ui/table"
|
||||||
import { cn } from "@/lib/utils"
|
import { cn } from "@/lib/utils"
|
||||||
@@ -75,31 +75,32 @@ export function DataTable<T extends Record<string, unknown>>(
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const pinStyle = (column: Column<T>) => {
|
const pinStyle = (column: Column<T>, header?: boolean) => {
|
||||||
const pinned = column.getIsPinned()
|
const pinned = column.getIsPinned()
|
||||||
if (!pinned) return {}
|
if (!pinned) return {}
|
||||||
return {
|
return {
|
||||||
position: pinned ? ("sticky" as const) : undefined,
|
|
||||||
backgroundColor: "white",
|
|
||||||
zIndex: 1,
|
|
||||||
...{
|
|
||||||
left: {
|
left: {
|
||||||
left: column.getStart(pinned),
|
left: column.getStart(pinned),
|
||||||
boxShadow: "inset 1px 0 var(--border)",
|
boxShadow: header
|
||||||
},
|
? "inset -1px -1px var(--border)"
|
||||||
|
: "inset -1px 0 var(--border)",
|
||||||
|
} as CSSProperties,
|
||||||
right: {
|
right: {
|
||||||
right: column.getAfter(pinned),
|
right: column.getAfter(pinned),
|
||||||
boxShadow: "inset 1px 0 var(--border)",
|
boxShadow: header
|
||||||
},
|
? "inset 1px -1px var(--border)"
|
||||||
}[pinned],
|
: "inset 1px 0 var(--border)",
|
||||||
} as CSSProperties
|
} as CSSProperties,
|
||||||
|
}[pinned]
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={cn("flex flex-col gap-3", props.classNames?.root)}>
|
<div
|
||||||
|
className={cn("flex-auto flex flex-col gap-3", props.classNames?.root)}
|
||||||
|
>
|
||||||
{/* 数据表 */}
|
{/* 数据表 */}
|
||||||
<div className="rounded-md relative bg-card">
|
<div className="flex-auto overflow-hidden relative">
|
||||||
<TableRoot>
|
<Table className="max-w-full max-h-full">
|
||||||
<TableHeader>
|
<TableHeader>
|
||||||
{table.getHeaderGroups().map(group => (
|
{table.getHeaderGroups().map(group => (
|
||||||
<TableRow key={group.id}>
|
<TableRow key={group.id}>
|
||||||
@@ -107,7 +108,8 @@ export function DataTable<T extends Record<string, unknown>>(
|
|||||||
<TableHead
|
<TableHead
|
||||||
key={header.id}
|
key={header.id}
|
||||||
colSpan={header.colSpan}
|
colSpan={header.colSpan}
|
||||||
style={pinStyle(header.column)}
|
className="sticky top-0 bg-card z-20 shadow-[inset_0_-1px_var(--border)]"
|
||||||
|
style={pinStyle(header.column, true)}
|
||||||
>
|
>
|
||||||
{header.isPlaceholder
|
{header.isPlaceholder
|
||||||
? null
|
? null
|
||||||
@@ -147,7 +149,11 @@ export function DataTable<T extends Record<string, unknown>>(
|
|||||||
className={cn("h-14", props.classNames?.dataRow)}
|
className={cn("h-14", props.classNames?.dataRow)}
|
||||||
>
|
>
|
||||||
{row.getVisibleCells().map(cell => (
|
{row.getVisibleCells().map(cell => (
|
||||||
<TableCell key={cell.id} style={pinStyle(cell.column)}>
|
<TableCell
|
||||||
|
key={cell.id}
|
||||||
|
className="sticky bg-card z-10"
|
||||||
|
style={pinStyle(cell.column)}
|
||||||
|
>
|
||||||
{flexRender(
|
{flexRender(
|
||||||
cell.column.columnDef.cell,
|
cell.column.columnDef.cell,
|
||||||
cell.getContext(),
|
cell.getContext(),
|
||||||
@@ -158,9 +164,9 @@ export function DataTable<T extends Record<string, unknown>>(
|
|||||||
))
|
))
|
||||||
)}
|
)}
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</TableRoot>
|
</Table>
|
||||||
{props.status === "load" && (
|
{props.status === "load" && (
|
||||||
<div className="absolute inset-0 bg-white/10 backdrop-blur-xs flex items-center justify-center gap-2 transition">
|
<div className="absolute inset-0 bg-white/10 backdrop-blur-xs flex items-center justify-center gap-2 transition z-50">
|
||||||
<Loader className="animate-spin" />
|
<Loader className="animate-spin" />
|
||||||
<span>加载中</span>
|
<span>加载中</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -168,7 +174,9 @@ export function DataTable<T extends Record<string, unknown>>(
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* 分页器 */}
|
{/* 分页器 */}
|
||||||
{props.pagination && <Pagination {...props.pagination} />}
|
{props.pagination && (
|
||||||
|
<Pagination {...props.pagination} className="flex-none self-center" />
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
import type { ReactNode } from "react"
|
import type { ReactNode } from "react"
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
export function Page(props: { children: ReactNode }) {
|
export function Page(props: { className?: string; children: ReactNode }) {
|
||||||
return <div className="flex flex-col">{props.children}</div>
|
return (
|
||||||
|
<div className={cn("h-full flex flex-col p-6 gap-4", props.className)}>
|
||||||
|
{props.children}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ function Table({ className, ...props }: React.ComponentProps<"table">) {
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
data-slot="table-container"
|
data-slot="table-container"
|
||||||
className="relative w-full overflow-x-auto"
|
className={cn("bg-card rounded-lg relative overflow-auto", className)}
|
||||||
>
|
>
|
||||||
<table
|
<table
|
||||||
data-slot="table"
|
data-slot="table"
|
||||||
className={cn("w-full caption-bottom text-sm", className)}
|
className="w-full caption-bottom text-sm"
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -23,7 +23,7 @@ function TableHeader({ className, ...props }: React.ComponentProps<"thead">) {
|
|||||||
return (
|
return (
|
||||||
<thead
|
<thead
|
||||||
data-slot="table-header"
|
data-slot="table-header"
|
||||||
className={cn("[&_tr]:border-b", className)}
|
className={cn("[&_tr]:border-b-0", className)}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,34 +1,56 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import * as TabsPrimitive from "@radix-ui/react-tabs"
|
import { cva, type VariantProps } from "class-variance-authority"
|
||||||
|
import { Tabs as TabsPrimitive } from "radix-ui"
|
||||||
import type * as React from "react"
|
import type * as React from "react"
|
||||||
|
|
||||||
import { cn } from "@/lib/utils"
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
function Tabs({
|
function Tabs({
|
||||||
className,
|
className,
|
||||||
|
orientation = "horizontal",
|
||||||
...props
|
...props
|
||||||
}: React.ComponentProps<typeof TabsPrimitive.Root>) {
|
}: React.ComponentProps<typeof TabsPrimitive.Root>) {
|
||||||
return (
|
return (
|
||||||
<TabsPrimitive.Root
|
<TabsPrimitive.Root
|
||||||
data-slot="tabs"
|
data-slot="tabs"
|
||||||
className={cn("flex flex-col gap-2", className)}
|
data-orientation={orientation}
|
||||||
|
orientation={orientation}
|
||||||
|
className={cn(
|
||||||
|
"group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",
|
||||||
|
className,
|
||||||
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const tabsListVariants = cva(
|
||||||
|
"group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none",
|
||||||
|
{
|
||||||
|
variants: {
|
||||||
|
variant: {
|
||||||
|
default: "bg-muted",
|
||||||
|
line: "gap-1 bg-transparent",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
defaultVariants: {
|
||||||
|
variant: "default",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
function TabsList({
|
function TabsList({
|
||||||
className,
|
className,
|
||||||
|
variant = "default",
|
||||||
...props
|
...props
|
||||||
}: React.ComponentProps<typeof TabsPrimitive.List>) {
|
}: React.ComponentProps<typeof TabsPrimitive.List> &
|
||||||
|
VariantProps<typeof tabsListVariants>) {
|
||||||
return (
|
return (
|
||||||
<TabsPrimitive.List
|
<TabsPrimitive.List
|
||||||
data-slot="tabs-list"
|
data-slot="tabs-list"
|
||||||
className={cn(
|
data-variant={variant}
|
||||||
"bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",
|
className={cn(tabsListVariants({ variant }), className)}
|
||||||
className,
|
|
||||||
)}
|
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
@@ -42,7 +64,10 @@ function TabsTrigger({
|
|||||||
<TabsPrimitive.Trigger
|
<TabsPrimitive.Trigger
|
||||||
data-slot="tabs-trigger"
|
data-slot="tabs-trigger"
|
||||||
className={cn(
|
className={cn(
|
||||||
"data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
"relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||||
|
"group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent",
|
||||||
|
"data-[state=active]:bg-background data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 dark:data-[state=active]:text-foreground",
|
||||||
|
"after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:-bottom-1.25 group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
@@ -63,4 +88,4 @@ function TabsContent({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export { Tabs, TabsList, TabsTrigger, TabsContent }
|
export { Tabs, TabsList, TabsTrigger, TabsContent, tabsListVariants }
|
||||||
|
|||||||
Reference in New Issue
Block a user