网关列表添加操作重建端口池 & 重建代理链
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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">
|
||||
@@ -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>
|
||||
),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user