This commit is contained in:
thsrite
2024-04-13 16:49:49 +08:00
parent 9caac0c04b
commit 6972cc4fd4

View File

@@ -51,13 +51,11 @@ class PluginAutoUpdate(_PluginBase):
# 定时器
_scheduler: Optional[BackgroundScheduler] = None
_plugin_manager: PluginManager = None
_plugin_version = {}
def init_plugin(self, config: dict = None):
# 停止现有任务
self.stop_service()
self._plugin_manager = PluginManager()
if config:
self._enabled = config.get("enabled")
@@ -130,7 +128,7 @@ class PluginAutoUpdate(_PluginBase):
install_plugins = SystemConfigOper().get(SystemConfigKey.UserInstalledPlugins) or []
# 在线插件
online_plugins = self._plugin_manager.get_online_plugins()
online_plugins = PluginManager().get_online_plugins()
if not online_plugins:
logger.error("未获取到在线插件,停止运行")
return
@@ -188,7 +186,7 @@ class PluginAutoUpdate(_PluginBase):
# 统计
PluginHelper().install_reg(plugin.id)
# 加载插件到内存
self._plugin_manager.reload_plugin(plugin.id)
PluginManager().reload_plugin(plugin.id)
# 注册插件服务
Scheduler().update_plugin_job(plugin.id)
else:
@@ -228,7 +226,7 @@ class PluginAutoUpdate(_PluginBase):
获取已安装插件版本
"""
# 本地插件
local_plugins = self._plugin_manager.get_local_plugins()
local_plugins = PluginManager().get_local_plugins()
for plugin in local_plugins:
self._plugin_version[plugin.id] = plugin.plugin_version
@@ -286,7 +284,7 @@ class PluginAutoUpdate(_PluginBase):
# 编历 local_plugins生成插件类型选项
pluginOptions = []
# 本地插件
local_plugins = self._plugin_manager.get_local_plugins()
local_plugins = PluginManager().get_local_plugins()
for plugin in local_plugins:
pluginOptions.append({
"title": f"{plugin.plugin_name} v{plugin.plugin_version}",