From 3d5580ad9d22a77b5f1acca9dc2fe22c8eddbfea Mon Sep 17 00:00:00 2001
From: trom <107225647+see-more@users.noreply.github.com>
Date: Mon, 26 Aug 2024 11:25:03 +0800
Subject: [PATCH] =?UTF-8?q?feat:=E6=98=BE=E7=A4=BA=E5=BD=93=E5=89=8Dip,?=
=?UTF-8?q?=E7=B3=BB=E7=BB=9F=E7=BD=91=E7=BB=9C=E4=BB=A3=E7=90=86=E5=9C=B0?=
=?UTF-8?q?=E5=9D=80=20(#6235)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
backend/app/dto/dashboard.go | 3 ++-
backend/app/service/dashboard.go | 13 ++++++++++++-
frontend/src/api/interface/dashboard.ts | 4 +++-
frontend/src/lang/modules/en.ts | 2 ++
frontend/src/lang/modules/zh.ts | 2 ++
frontend/src/views/home/index.vue | 22 +++++++++++++++++++++-
6 files changed, 42 insertions(+), 4 deletions(-)
diff --git a/backend/app/dto/dashboard.go b/backend/app/dto/dashboard.go
index a7d3a5c95..363a9a804 100644
--- a/backend/app/dto/dashboard.go
+++ b/backend/app/dto/dashboard.go
@@ -16,7 +16,8 @@ type DashboardBase struct {
KernelArch string `json:"kernelArch"`
KernelVersion string `json:"kernelVersion"`
VirtualizationSystem string `json:"virtualizationSystem"`
-
+ IpV4Addr string `json:"ipV4Addr"`
+ SystemProxy string `json:"systemProxy"`
CPUCores int `json:"cpuCores"`
CPULogicalCores int `json:"cpuLogicalCores"`
CPUModelName string `json:"cpuModelName"`
diff --git a/backend/app/service/dashboard.go b/backend/app/service/dashboard.go
index 0ac4af844..60d43f8b3 100644
--- a/backend/app/service/dashboard.go
+++ b/backend/app/service/dashboard.go
@@ -1,8 +1,10 @@
package service
import (
+ "context"
"encoding/json"
"fmt"
+ "os"
"sort"
"strings"
"sync"
@@ -94,11 +96,20 @@ func (u *DashboardService) LoadBaseInfo(ioOption string, netOption string) (*dto
baseInfo.KernelVersion = hostInfo.KernelVersion
ss, _ := json.Marshal(hostInfo)
baseInfo.VirtualizationSystem = string(ss)
-
+ baseInfo.IpV4Addr=host.IpV4AddrWithContext(context.Background())
+ httpProxy := os.Getenv("http_proxy")
+ if httpProxy == "" {
+ httpProxy = os.Getenv("HTTP_PROXY") // 也检查大写的环境变量名
+ }
+ if httpProxy!=""{
+ baseInfo.SystemProxy=httpProxy
+ }
+ baseInfo.SystemProxy="noProxy"
appInstall, err := appInstallRepo.ListBy()
if err != nil {
return nil, err
}
+
baseInfo.AppInstalledNumber = len(appInstall)
postgresqlDbs, err := postgresqlRepo.List()
if err != nil {
diff --git a/frontend/src/api/interface/dashboard.ts b/frontend/src/api/interface/dashboard.ts
index e593f9e4e..bd8062809 100644
--- a/frontend/src/api/interface/dashboard.ts
+++ b/frontend/src/api/interface/dashboard.ts
@@ -22,7 +22,9 @@ export namespace Dashboard {
kernelArch: string;
kernelVersion: string;
virtualizationSystem: string;
-
+ IpV4Addr: string;
+ httpProxy: string;
+
cpuCores: number;
cpuLogicalCores: number;
cpuModelName: string;
diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts
index 95a87c2b1..bf7403424 100644
--- a/frontend/src/lang/modules/en.ts
+++ b/frontend/src/lang/modules/en.ts
@@ -344,6 +344,8 @@ const message = {
kernelArch: 'Kernel arch',
network: 'Network',
io: 'Disk IO',
+ ip: 'Ip Addr',
+ proxy: 'System Proxy',
baseInfo: 'Base info',
totalSend: 'Total send',
totalRecv: 'Total recv',
diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts
index c0b793617..fd7e43a4e 100644
--- a/frontend/src/lang/modules/zh.ts
+++ b/frontend/src/lang/modules/zh.ts
@@ -337,6 +337,8 @@ const message = {
kernelArch: '系统类型',
network: '流量',
io: '磁盘 IO',
+ ip: 'IP地址',
+ proxy: '系统代理',
baseInfo: '基本信息',
totalSend: '总发送',
totalRecv: '总接收',
diff --git a/frontend/src/views/home/index.vue b/frontend/src/views/home/index.vue
index 3e71bdedb..fda5256d8 100644
--- a/frontend/src/views/home/index.vue
+++ b/frontend/src/views/home/index.vue
@@ -225,6 +225,25 @@
{{ loadUpTime(currentInfo.uptime) }}
+
+
+
+ {{ $t('home.ip') }}
+
+ {{ baseInfo.IpV4Addr }}
+
+
+
+
+
+ {{ $t('home.proxy') }}
+
+ {{ baseInfo.httpProxy }}
+
+
@@ -303,7 +322,8 @@ const baseInfo = ref({
kernelArch: '',
kernelVersion: '',
virtualizationSystem: '',
-
+ IpV4Addr: '',
+ httpProxy: '',
cpuCores: 0,
cpuLogicalCores: 0,
cpuModelName: '',