From 06dfcfaff3392fc53d122431ea4558a4625f66d4 Mon Sep 17 00:00:00 2001 From: Flik Date: Thu, 22 Jan 2026 19:10:20 +0800 Subject: [PATCH] =?UTF-8?q?feat(nav):=20=E6=9B=B4=E6=96=B0=E5=AF=BC?= =?UTF-8?q?=E8=88=AA=E8=8F=9C=E5=8D=95=E7=BB=93=E6=9E=84=E5=B9=B6=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=AE=A2=E6=88=B7=E7=AB=AF=E7=AE=A1=E7=90=86=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将插件页面替换为客户端管理页面 - 添加客户端管理视图组件,支持查看客户端列表和状态 - 集成服务器更新检查功能,在页脚显示版本和更新状态 - 添加桌面、服务器、勾选和箭头图标用于界面展示 - 实现客户端统计卡片显示在线和离线状态 - 优化路由配置,移除插件相关路由并添加客户端路由 - 更新DTO结构,分离OS和Arch字段替代平台字段 --- internal/server/router/dto/update.go | 3 +- internal/server/router/handler/update.go | 3 +- web/src/App.vue | 75 +++++- web/src/router/index.ts | 10 +- web/src/views/ClientsView.vue | 317 +++++++++++++++++++++++ 5 files changed, 394 insertions(+), 14 deletions(-) create mode 100644 web/src/views/ClientsView.vue diff --git a/internal/server/router/dto/update.go b/internal/server/router/dto/update.go index 3df3b41..39ab91c 100644 --- a/internal/server/router/dto/update.go +++ b/internal/server/router/dto/update.go @@ -39,7 +39,8 @@ type VersionInfo struct { GitCommit string `json:"git_commit,omitempty"` BuildTime string `json:"build_time,omitempty"` GoVersion string `json:"go_version,omitempty"` - Platform string `json:"platform,omitempty"` + OS string `json:"os,omitempty"` + Arch string `json:"arch,omitempty"` } // StatusResponse 服务器状态响应 diff --git a/internal/server/router/handler/update.go b/internal/server/router/handler/update.go index 8191dbb..def6fc9 100644 --- a/internal/server/router/handler/update.go +++ b/internal/server/router/handler/update.go @@ -127,6 +127,7 @@ func getVersionInfo() dto.VersionInfo { GitCommit: info.GitCommit, BuildTime: info.BuildTime, GoVersion: info.GoVersion, - Platform: info.OS + "/" + info.Arch, + OS: info.OS, + Arch: info.Arch, } } diff --git a/web/src/App.vue b/web/src/App.vue index 132c9bc..bffa69f 100644 --- a/web/src/App.vue +++ b/web/src/App.vue @@ -6,10 +6,10 @@ import { type GlobalThemeOverrides } from 'naive-ui' import { - HomeOutline, ExtensionPuzzleOutline, SettingsOutline, - PersonCircleOutline, LogOutOutline, LogoGithub + HomeOutline, DesktopOutline, SettingsOutline, + PersonCircleOutline, LogOutOutline, LogoGithub, ServerOutline, CheckmarkCircleOutline, ArrowUpCircleOutline } from '@vicons/ionicons5' -import { getServerStatus, getVersionInfo, removeToken, getToken } from './api' +import { getServerStatus, getVersionInfo, checkServerUpdate, removeToken, getToken, type UpdateInfo } from './api' const router = useRouter() const route = useRoute() @@ -17,20 +17,20 @@ const serverInfo = ref({ bind_addr: '', bind_port: 0 }) const clientCount = ref(0) const version = ref('') const showUserMenu = ref(false) +const updateInfo = ref(null) const isLoginPage = computed(() => route.path === '/login') const navItems = [ { key: 'home', label: '首页', icon: HomeOutline, path: '/' }, - { key: 'plugins', label: '插件', icon: ExtensionPuzzleOutline, path: '/plugins' }, + { key: 'clients', label: '客户端', icon: DesktopOutline, path: '/clients' }, { key: 'settings', label: '设置', icon: SettingsOutline, path: '/settings' } ] const activeNav = computed(() => { const path = route.path if (path === '/' || path === '/home') return 'home' - if (path.startsWith('/client')) return 'home' - if (path === '/plugins') return 'plugins' + if (path === '/clients' || path.startsWith('/client/')) return 'clients' if (path === '/settings') return 'settings' return 'home' }) @@ -56,16 +56,28 @@ const fetchVersion = async () => { } } +const checkUpdate = async () => { + if (isLoginPage.value || !getToken()) return + try { + const { data } = await checkServerUpdate() + updateInfo.value = data + } catch (e) { + console.error('Failed to check update', e) + } +} + watch(() => route.path, (newPath, oldPath) => { if (oldPath === '/login' && newPath !== '/login') { fetchServerStatus() fetchVersion() + checkUpdate() } }) onMounted(() => { fetchServerStatus() fetchVersion() + checkUpdate() }) const logout = () => { @@ -139,7 +151,20 @@ const themeOverrides: GlobalThemeOverrides = {