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 }) => (
- - +
), },