From 4b1d87bb1425038c18e2de9aa63bf4a060179145 Mon Sep 17 00:00:00 2001 From: Eamon <17516219072@163.com> Date: Tue, 21 Apr 2026 17:05:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=A1=B5=E9=9D=A2=E9=87=8D?= =?UTF-8?q?=E5=8F=A0=E7=9A=84=E9=97=AE=E9=A2=98=20&=20=E7=BD=91=E5=85=B3?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/actions/gateway.ts | 11 +++++---- src/app/(root)/appbar.tsx | 4 ++-- src/app/(root)/gateway/create.tsx | 6 ++--- src/app/(root)/gateway/page.tsx | 40 +++++++++++++++++++++++++------ 4 files changed, 44 insertions(+), 17 deletions(-) diff --git a/src/actions/gateway.ts b/src/actions/gateway.ts index 34dadb1..3fe01a5 100644 --- a/src/actions/gateway.ts +++ b/src/actions/gateway.ts @@ -19,8 +19,11 @@ export async function createGateway(data: { return callByUser("/api/admin/proxy/create", data) } -export async function deletegateway(id: number) { - return callByUser("/api/admin/proxy/remove", { - id, - }) +export async function updateGateway(data:{ + id: number, + status: number} + ) { + return callByUser("/api/admin/proxy/update/status", + data + ) } diff --git a/src/app/(root)/appbar.tsx b/src/app/(root)/appbar.tsx index 14a6e95..889a649 100644 --- a/src/app/(root)/appbar.tsx +++ b/src/app/(root)/appbar.tsx @@ -104,7 +104,7 @@ export default function Appbar(props: { admin: Admin }) { } return ( -
+
{/* 面包屑导航 */}
{breadcrumbs.map((crumb, index) => ( @@ -194,7 +194,7 @@ export default function Appbar(props: { admin: Admin }) {
)} -
+
void }) { name="mac" render={({ field, fieldState }) => ( - MAC地址: + 标识: getGatewayPage({ page, size })) +const getGatewayPageWrapper = useCallback((page: number, size: number) => { + return getGatewayPage({ page, size }) +}, []) +const table = useDataTable(getGatewayPageWrapper) + + const handleToggle = async (id: number, status: number) => { + setLoading(true) + try { + const result = await updateGateway({ + id:id, + status: status === 0 ? 1 : 0 + }) + if (result.success) { + toast.success(status === 0 ? "启用成功" : "停用成功") + table.refresh() + } else { + toast.error(result.message || "操作失败") + } + } catch (error) { + toast.error("操作失败") + } finally { + setLoading(false) + } + } return ( @@ -62,10 +85,13 @@ export default function GatewayPage() { header: "操作", cell: ({ row }) => (
- - +
), },