From a8e10d0d71ceb38c682e73478773c18889caa4c0 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Tue, 2 Jan 2024 17:22:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E7=AE=B1=20Hosts=20=E8=A7=A3=E6=9E=90=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=20(#3501)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs #3497 --- backend/app/service/device.go | 2 +- frontend/src/lang/modules/en.ts | 1 + frontend/src/lang/modules/tw.ts | 1 + frontend/src/lang/modules/zh.ts | 1 + frontend/src/views/toolbox/device/hosts/index.vue | 6 ++++++ 5 files changed, 10 insertions(+), 1 deletion(-) diff --git a/backend/app/service/device.go b/backend/app/service/device.go index 9441c776d..d71189fec 100644 --- a/backend/app/service/device.go +++ b/backend/app/service/device.go @@ -353,7 +353,7 @@ func loadHosts() []dto.HostHelper { lines := strings.Split(string(hostConf), "\n") for _, line := range lines { parts := strings.Fields(line) - if len(parts) < 2 { + if len(parts) < 2 || strings.HasPrefix(strings.TrimPrefix(line, " "), "#") { continue } list = append(list, dto.HostHelper{IP: parts[0], Host: strings.Join(parts[1:], " ")}) diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index f267b160b..9ccc67588 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -926,6 +926,7 @@ const message = { 'When there are multiple DNS entries, they should be displayed on new lines. e.g.\n114.114.114.114\n8.8.8.8', hostsHelper: 'Hostname Resolution', hosts: 'Domain', + hostAlert: 'Hidden commented records, please click the All configuration button to view or set', toolbox: 'Quick Setup', hostname: 'Hostname', passwd: 'System Password', diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index 83faf84e1..8a8f0d93c 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -881,6 +881,7 @@ const message = { dnsHelper1: '當存在多個DNS時,需換行顯示,例:\n114.114.114.114\n8.8.8.8', hostsHelper: '主機名解析', hosts: '域名', + hostAlert: '隱藏了已註釋的記錄,請點擊 全部配置 按鈕以查看或設置', toolbox: '快速設置', hostname: '主機名', passwd: '系統密碼', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 67f5d36b4..32ca4d837 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -882,6 +882,7 @@ const message = { dnsHelper1: '当存在多个 DNS 时,需换行显示,例:\n114.114.114.114\n8.8.8.8', hostsHelper: '主机名解析', hosts: '域名', + hostAlert: '隐藏了已注释的记录,请点击 全部配置 按钮以查看或设置', toolbox: '快速设置', hostname: '主机名', passwd: '系统密码', diff --git a/frontend/src/views/toolbox/device/hosts/index.vue b/frontend/src/views/toolbox/device/hosts/index.vue index 27357f4f4..7f7e3f6f4 100644 --- a/frontend/src/views/toolbox/device/hosts/index.vue +++ b/frontend/src/views/toolbox/device/hosts/index.vue @@ -7,6 +7,12 @@ + {{ $t('database.baseConf') }} {{ $t('database.allConf') }}