diff --git a/src/actions/gateway.ts b/src/actions/gateway.ts index ed0f0aa..177a5c0 100644 --- a/src/actions/gateway.ts +++ b/src/actions/gateway.ts @@ -27,3 +27,9 @@ export async function updateGateway(data: { id: number; status: number }) { export async function clear(data: { proxy_id: number }) { return callByUser("/api/admin/channel/sync/clear-expired", data) } +export async function createProxyPort(data: { id: number }) { + return callByUser("/api/admin/proxy/sync/ports", data) +} +export async function createProxyChains(data: { id: number }) { + return callByUser("/api/admin/proxy/sync/chains", data) +} diff --git a/src/app/(root)/gateway/page.tsx b/src/app/(root)/gateway/page.tsx index 8aca882..66de8d6 100644 --- a/src/app/(root)/gateway/page.tsx +++ b/src/app/(root)/gateway/page.tsx @@ -3,7 +3,13 @@ import { format } from "date-fns" import { Suspense, useCallback, useState } from "react" import { toast } from "sonner" -import { clear, getGatewayPage, updateGateway } from "@/actions/gateway" +import { + clear, + createProxyChains, + createProxyPort, + getGatewayPage, + updateGateway, +} from "@/actions/gateway" import { Auth } from "@/components/auth" import { DataTable, useDataTable } from "@/components/data-table" import { Page } from "@/components/page" @@ -64,6 +70,46 @@ export default function GatewayPage() { } } + const createPort = async (val: Gateway) => { + setLoading(true) + try { + const result = await createProxyPort({ + id: val.id, + }) + + if (result.success) { + toast.success(`重建端口池成功!`) + } else { + toast.error(result.message || "请稍后重试一下~") + } + } catch (error) { + const message = error instanceof Error ? error.message : error + toast.error(`清理过期连接失败: ${message}`) + } finally { + setLoading(false) + } + } + + const createChains = async (val: Gateway) => { + setLoading(true) + try { + const result = await createProxyChains({ + id: val.id, + }) + + if (result.success) { + toast.success(`重建代理链成功!!!`) + } else { + toast.error(result.message || "请稍后重试一下~") + } + } catch (error) { + const message = error instanceof Error ? error.message : error + toast.error(`清理过期连接失败: ${message}`) + } finally { + setLoading(false) + } + } + return (
@@ -123,7 +169,7 @@ export default function GatewayPage() { meta: { pin: "right" }, header: "操作", cell: ({ row }) => ( -
+
+ + + +
), },