网关列表添加操作重建端口池 & 重建代理链
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 }) {
|
export async function clear(data: { proxy_id: number }) {
|
||||||
return callByUser<PageRecord>("/api/admin/channel/sync/clear-expired", data)
|
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 { format } from "date-fns"
|
||||||
import { Suspense, useCallback, useState } from "react"
|
import { Suspense, useCallback, useState } from "react"
|
||||||
import { toast } from "sonner"
|
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 { Auth } from "@/components/auth"
|
||||||
import { DataTable, useDataTable } from "@/components/data-table"
|
import { DataTable, useDataTable } from "@/components/data-table"
|
||||||
import { Page } from "@/components/page"
|
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 (
|
return (
|
||||||
<Page>
|
<Page>
|
||||||
<div className="flex justify-between items-stretch">
|
<div className="flex justify-between items-stretch">
|
||||||
@@ -123,7 +169,7 @@ export default function GatewayPage() {
|
|||||||
meta: { pin: "right" },
|
meta: { pin: "right" },
|
||||||
header: "操作",
|
header: "操作",
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2 ">
|
||||||
<Button
|
<Button
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
handleToggle(row.original.id, row.original.status)
|
handleToggle(row.original.id, row.original.status)
|
||||||
@@ -140,6 +186,14 @@ export default function GatewayPage() {
|
|||||||
清理过期连接
|
清理过期连接
|
||||||
</Button>
|
</Button>
|
||||||
</Auth>
|
</Auth>
|
||||||
|
<Auth scope={ScopeProxyWrite}>
|
||||||
|
<Button onClick={() => createPort(row.original)}>
|
||||||
|
重建端口池
|
||||||
|
</Button>
|
||||||
|
<Button onClick={() => createChains(row.original)}>
|
||||||
|
重建代理链
|
||||||
|
</Button>
|
||||||
|
</Auth>
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user