From c49e2106971ca839260bcd96b4f4c6cdd9c10be6 Mon Sep 17 00:00:00 2001 From: InfinityPacer <160988576+InfinityPacer@users.noreply.github.com> Date: Tue, 13 Aug 2024 19:02:58 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat(CustomHosts):=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=86=99=E5=85=A5Hosts=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/customhosts/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/customhosts/__init__.py b/plugins/customhosts/__init__.py index 849159f..d776995 100644 --- a/plugins/customhosts/__init__.py +++ b/plugins/customhosts/__init__.py @@ -235,6 +235,12 @@ class CustomHosts(_PluginBase): for host in hosts: if not host: continue + host = host.strip() + if host.startswith('#'): # 检查是否为注释行 + host_entry = HostsEntry(entry_type='comment', comment=host) + new_entrys.append(host_entry) + continue + host_arr = str(host).split() try: host_entry = HostsEntry(entry_type='ipv4' if IpUtils.is_ipv4(str(host_arr[0])) else 'ipv6', From bf2a1ea6f0bf7439298c3dd850d3fc223beea197 Mon Sep 17 00:00:00 2001 From: InfinityPacer <160988576+InfinityPacer@users.noreply.github.com> Date: Tue, 13 Aug 2024 19:04:24 +0800 Subject: [PATCH 2/2] feat: CustomHosts v1.2 --- package.json | 3 ++- plugins/customhosts/__init__.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f3ecb75..9c8ba5c 100644 --- a/package.json +++ b/package.json @@ -161,11 +161,12 @@ "name": "自定义Hosts", "description": "修改系统hosts文件,加速网络访问。", "labels": "网络", - "version": "1.1", + "version": "1.2", "icon": "hosts.png", "author": "thsrite", "level": 1, "history": { + "v1.2": "支持写入注释", "v1.1": "关闭插件时自动恢复系统hosts" } }, diff --git a/plugins/customhosts/__init__.py b/plugins/customhosts/__init__.py index d776995..ae0fe6a 100644 --- a/plugins/customhosts/__init__.py +++ b/plugins/customhosts/__init__.py @@ -18,7 +18,7 @@ class CustomHosts(_PluginBase): # 插件图标 plugin_icon = "hosts.png" # 插件版本 - plugin_version = "1.1" + plugin_version = "1.2" # 插件作者 plugin_author = "thsrite" # 作者主页