From bc29a025b0fbcf39a0de723c2fa01451e33b6ce0 Mon Sep 17 00:00:00 2001 From: Eamon <17516219072@163.com> Date: Fri, 8 May 2026 17:47:42 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BD=91=E5=85=B3=E5=88=97=E8=A1=A8=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=B8=85=E7=90=86=E8=BF=87=E6=9C=9F=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/actions/gateway.ts | 4 ++++ src/app/(root)/gateway/page.tsx | 42 +++++++++++++++++++++++++++------ src/lib/scopes.ts | 1 + 4 files changed, 41 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index b71a163..6d47d84 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lanhu-admin", - "version": "1.7.0", + "version": "1.8.0", "private": true, "scripts": { "dev": "next dev -H 0.0.0.0 -p 3001 --turbopack", diff --git a/src/actions/gateway.ts b/src/actions/gateway.ts index 7e28f27..25f3d0e 100644 --- a/src/actions/gateway.ts +++ b/src/actions/gateway.ts @@ -22,3 +22,7 @@ export async function createGateway(data: { export async function updateGateway(data: { id: number; status: number }) { return callByUser("/api/admin/proxy/update/status", data) } + +export async function clear(data: { proxy_id: number }) { + return callByUser("/api/admin/channel/sync/clear-expired", data) +} diff --git a/src/app/(root)/gateway/page.tsx b/src/app/(root)/gateway/page.tsx index 63d789c..26352a0 100644 --- a/src/app/(root)/gateway/page.tsx +++ b/src/app/(root)/gateway/page.tsx @@ -3,12 +3,12 @@ import { format } from "date-fns" import { Suspense, useCallback, useState } from "react" import { toast } from "sonner" -import { getGatewayPage, updateGateway } from "@/actions/gateway" +import { clear, getGatewayPage, updateGateway } from "@/actions/gateway" import { Auth } from "@/components/auth" import { DataTable, useDataTable } from "@/components/data-table" import { Page } from "@/components/page" import { Button } from "@/components/ui/button" -import { ScopeProxyWrite } from "@/lib/scopes" +import { ScopeChannelWriteClearExpired, ScopeProxyWrite } from "@/lib/scopes" import type { Gateway } from "@/models/gateway" import CreatePage from "./create" @@ -41,15 +41,38 @@ export default function GatewayPage() { setLoading(false) } } + + const clearExpired = async (val: Gateway) => { + setLoading(true) + try { + const result = await clear({ + proxy_id: val.id, + }) + + if (result.success) { + const count = + result.data && "count" in result.data ? result.data.count : 0 + toast.success(`清理过期连接成功,共 ${count} 条`) + } else { + toast.error(result.message || "清理过期连接失败,请稍后重试一下~") + } + } catch (error) { + const message = error instanceof Error ? error.message : error + toast.error(`清理过期连接失败: ${message}`) + } finally { + setLoading(false) + } + } + return ( - -
-
+
+
+ -
+
- +
{...table} @@ -101,6 +124,11 @@ export default function GatewayPage() { > {row.original.status === 0 ? "启用" : "停用"} + + +
), }, diff --git a/src/lib/scopes.ts b/src/lib/scopes.ts index 66fb4c7..8bf26ff 100644 --- a/src/lib/scopes.ts +++ b/src/lib/scopes.ts @@ -91,3 +91,4 @@ export const ScopeProxy = "proxy" export const ScopeProxyRead = "proxy:read" // 读取代理列表 export const ScopeProxyWrite = "proxy:write" // 写入代理 export const ScopeProxyWriteStatus = "proxy:write:status" // 更改代理状态 +export const ScopeChannelWriteClearExpired = "channel:write:clear_expired" //清理过期连接