From f3d97d5b08425fe6d88572f81e5fb5bae3188a80 Mon Sep 17 00:00:00 2001 From: lijun Date: Fri, 30 Jan 2026 22:03:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=B7=E6=96=B0=E5=9C=A8?= =?UTF-8?q?=E7=BA=BF=E7=94=A8=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components.d.ts | 5 ++++ src/views/system/vpn-server-online-user.vue | 29 ++++++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/components.d.ts b/components.d.ts index 64d4079..7df6600 100644 --- a/components.d.ts +++ b/components.d.ts @@ -29,6 +29,8 @@ declare module '@vue/runtime-core' { ElDialog: typeof import('element-plus/es')['ElDialog'] ElDivider: typeof import('element-plus/es')['ElDivider'] ElDropdown: typeof import('element-plus/es')['ElDropdown'] + ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem'] + ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu'] ElEmpty: typeof import('element-plus/es')['ElEmpty'] ElForm: typeof import('element-plus/es')['ElForm'] ElFormItem: typeof import('element-plus/es')['ElFormItem'] @@ -37,6 +39,8 @@ declare module '@vue/runtime-core' { ElInput: typeof import('element-plus/es')['ElInput'] ElInputNumber: typeof import('element-plus/es')['ElInputNumber'] ElLink: typeof import('element-plus/es')['ElLink'] + ElMenu: typeof import('element-plus/es')['ElMenu'] + ElMenuItem: typeof import('element-plus/es')['ElMenuItem'] ElOption: typeof import('element-plus/es')['ElOption'] ElPagination: typeof import('element-plus/es')['ElPagination'] ElProgress: typeof import('element-plus/es')['ElProgress'] @@ -53,6 +57,7 @@ declare module '@vue/runtime-core' { ElStatistic: typeof import('element-plus/es')['ElStatistic'] ElStep: typeof import('element-plus/es')['ElStep'] ElSteps: typeof import('element-plus/es')['ElSteps'] + ElSubMenu: typeof import('element-plus/es')['ElSubMenu'] ElSwitch: typeof import('element-plus/es')['ElSwitch'] ElTable: typeof import('element-plus/es')['ElTable'] ElTableColumn: typeof import('element-plus/es')['ElTableColumn'] diff --git a/src/views/system/vpn-server-online-user.vue b/src/views/system/vpn-server-online-user.vue index c72cede..589c1c9 100644 --- a/src/views/system/vpn-server-online-user.vue +++ b/src/views/system/vpn-server-online-user.vue @@ -50,7 +50,6 @@ style="width: 100%" v-loading="loading" stripe - border > @@ -224,6 +223,30 @@ const getOnlineUsers = async (serverId: string) => { } }; +const getOnlineUsers2 = async (serverId: string) => { + if (!serverId) return; + + //loading.value = true; + try { + const response = await GetServerOnlineUsers(serverId); + if (response["code"] === 0) { + if(response.data){ + onlineUsers.value = response.data; + }else{ + onlineUsers.value = []; + } + } else { + ElMessage.error(response["message"]); + } + } catch (error) { + console.error('获取在线用户失败:', error); + ElMessage.error('获取在线用户失败'); + onlineUsers.value = []; + } finally { + loading.value = false; + } +}; + // 刷新在线用户 const refreshOnlineUsers = () => { if (selectedServer.value) { @@ -261,9 +284,9 @@ const startOnlineStatusTimer = () => { }, 10000); timer2 = window.setInterval(() => { if (selectedServer.value){ - GetServerOnlineUsers(selectedServer.value.server_id); + getOnlineUsers2(selectedServer.value.server_id); } - }, 2000); + }, 3000); }; // 停止定时查询