From ee006282dfe3352dd8a93e0664fe21e6cf49294d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=97=E5=AD=90?= Date: Sat, 10 Jan 2026 20:44:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=89=8D=E7=AB=AF=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/service/toolbox_system.go | 17 ++++++----------- web/src/views/database/DatabaseList.vue | 2 ++ web/src/views/toolbox/SystemView.vue | 4 ++-- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/internal/service/toolbox_system.go b/internal/service/toolbox_system.go index ce4c5028..2cf7f2a1 100644 --- a/internal/service/toolbox_system.go +++ b/internal/service/toolbox_system.go @@ -63,20 +63,14 @@ func (s *ToolboxSystemService) UpdateDNS(w http.ResponseWriter, r *http.Request) // GetSWAP 获取 SWAP 信息 func (s *ToolboxSystemService) GetSWAP(w http.ResponseWriter, r *http.Request) { - var total, used, free string - var size int64 + // total, used, free 系统给出的值,size 面板 swap 文件大小 + total, used, free := "0.00 B", "0.00 B", "0.00 B" + size := int64(0) if io.Exists(filepath.Join(app.Root, "swap")) { file, err := os.Stat(filepath.Join(app.Root, "swap")) - if err != nil { - Error(w, http.StatusInternalServerError, s.t.Get("failed to get SWAP: %v", err)) - return + if err == nil { + size = file.Size() / 1024 / 1024 } - - size = file.Size() / 1024 / 1024 - total = tools.FormatBytes(float64(file.Size())) - } else { - size = 0 - total = "0.00 B" } raw, err := shell.Execf("free | grep Swap") @@ -87,6 +81,7 @@ func (s *ToolboxSystemService) GetSWAP(w http.ResponseWriter, r *http.Request) { match := regexp.MustCompile(`Swap:\s+(\d+)\s+(\d+)\s+(\d+)`).FindStringSubmatch(raw) if len(match) >= 4 { + total = tools.FormatBytes(cast.ToFloat64(match[1]) * 1024) used = tools.FormatBytes(cast.ToFloat64(match[2]) * 1024) free = tools.FormatBytes(cast.ToFloat64(match[3]) * 1024) } diff --git a/web/src/views/database/DatabaseList.vue b/web/src/views/database/DatabaseList.vue index 6f34cf09..1ea39f66 100644 --- a/web/src/views/database/DatabaseList.vue +++ b/web/src/views/database/DatabaseList.vue @@ -62,6 +62,8 @@ const columns: any = [ return h(NInput, { size: 'small', value: row.comment, + // MySQL 不支持数据库备注 + disabled: row.type === 'mysql', onBlur: () => handleComment(row), onUpdateValue(v) { row.comment = v diff --git a/web/src/views/toolbox/SystemView.vue b/web/src/views/toolbox/SystemView.vue index bde1a491..5915e6c6 100644 --- a/web/src/views/toolbox/SystemView.vue +++ b/web/src/views/toolbox/SystemView.vue @@ -116,7 +116,7 @@ const handleSyncTime = () => { {{ - $gettext('Total %{ total }, used %{ used }, free %{ free }', { + $gettext('System total %{ total }, used %{ used }, free %{ free }', { total: swapTotal, used: swapUsed, free: swapFree @@ -124,7 +124,7 @@ const handleSyncTime = () => { }} - + MB