fix customHosts插件重载

This commit is contained in:
thsrite
2023-08-15 19:36:47 +08:00
parent b086bbf015
commit 45381d4449
3 changed files with 19 additions and 18 deletions

View File

@ -1,8 +1,11 @@
from typing import List, Tuple, Dict, Any
from python_hosts import Hosts, HostsEntry
from app.core.event import eventmanager
from app.log import logger
from app.plugins import _PluginBase
from app.schemas.types import EventType
from app.utils.ip import IpUtils
from app.utils.system import SystemUtils
@ -221,3 +224,15 @@ class CustomHosts(_PluginBase):
退出插件
"""
pass
@eventmanager.register(EventType.PluginReload)
def reload(self, event):
"""
响应插件重载事件
"""
plugin_id = event.event_data.get("plugin_id")
if not plugin_id:
return
if plugin_id != self.__class__.__name__:
return
return self.init_plugin(self.get_config())