网关列表添加操作重建端口池 & 重建代理链

This commit is contained in:
Eamon
2026-06-11 16:09:07 +08:00
parent 8e50a7264b
commit 7b7ba7d01d
2 changed files with 62 additions and 2 deletions

View File

@@ -27,3 +27,9 @@ export async function updateGateway(data: { id: number; status: number }) {
export async function clear(data: { proxy_id: number }) {
return callByUser<PageRecord>("/api/admin/channel/sync/clear-expired", data)
}
export async function createProxyPort(data: { id: number }) {
return callByUser<PageRecord>("/api/admin/proxy/sync/ports", data)
}
export async function createProxyChains(data: { id: number }) {
return callByUser<PageRecord>("/api/admin/proxy/sync/chains", data)
}

View File

@@ -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 (
<Page>
<div className="flex justify-between items-stretch">
@@ -123,7 +169,7 @@ export default function GatewayPage() {
meta: { pin: "right" },
header: "操作",
cell: ({ row }) => (
<div className="flex gap-2">
<div className="flex gap-2 ">
<Button
onClick={() =>
handleToggle(row.original.id, row.original.status)
@@ -140,6 +186,14 @@ export default function GatewayPage() {
</Button>
</Auth>
<Auth scope={ScopeProxyWrite}>
<Button onClick={() => createPort(row.original)}>
</Button>
<Button onClick={() => createChains(row.original)}>
</Button>
</Auth>
</div>
),
},