diff --git a/plugins/pluginautoupdate/__init__.py b/plugins/pluginautoupdate/__init__.py index 6af4d2e..d7c5340 100644 --- a/plugins/pluginautoupdate/__init__.py +++ b/plugins/pluginautoupdate/__init__.py @@ -14,14 +14,6 @@ from app.log import logger from app.schemas.types import SystemConfigKey from app.schemas import NotificationType from app.scheduler import Scheduler -from app.helper.sites import SitesHelper - - -class MyPluginManager(PluginManager): - def __init__(self): - self.siteshelper = SitesHelper() - self.pluginhelper = PluginHelper() - self.systemconfig = SystemConfigOper() class PluginAutoUpdate(_PluginBase): @@ -57,13 +49,11 @@ class PluginAutoUpdate(_PluginBase): # 定时器 _scheduler: Optional[BackgroundScheduler] = None - _pluginmanager: MyPluginManager = None _plugin_version = {} def init_plugin(self, config: dict = None): # 停止现有任务 self.stop_service() - self._pluginmanager = MyPluginManager() if config: self._enabled = config.get("enabled") @@ -121,7 +111,7 @@ class PluginAutoUpdate(_PluginBase): install_plugins = SystemConfigOper().get(SystemConfigKey.UserInstalledPlugins) or [] # 在线插件 - online_plugins = self._pluginmanager.get_online_plugins() + online_plugins = PluginManager().get_online_plugins() if not online_plugins: logger.error("未获取到在线插件,停止运行") return @@ -197,7 +187,7 @@ class PluginAutoUpdate(_PluginBase): if plugin_reload: if self._update: logger.info("开始插件重载") - self._pluginmanager.init_config() + PluginManager().init_config() else: logger.info("所有插件已是最新版本") @@ -206,7 +196,7 @@ class PluginAutoUpdate(_PluginBase): 获取已安装插件版本 """ # 本地插件 - local_plugins = self._pluginmanager.get_local_plugins() + local_plugins = PluginManager().get_local_plugins() for plugin in local_plugins: self._plugin_version[plugin.id] = plugin.plugin_version @@ -235,7 +225,7 @@ class PluginAutoUpdate(_PluginBase): # 编历 local_plugins,生成插件类型选项 pluginOptions = [] # 本地插件 - local_plugins = self._pluginmanager.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}", diff --git a/plugins/pluginreinstall/__init__.py b/plugins/pluginreinstall/__init__.py index 00833f4..6e59bad 100644 --- a/plugins/pluginreinstall/__init__.py +++ b/plugins/pluginreinstall/__init__.py @@ -9,14 +9,6 @@ from typing import Any, List, Dict, Tuple, Optional from app.log import logger from app.schemas.types import SystemConfigKey from app.utils.string import StringUtils -from app.helper.sites import SitesHelper - - -class MyPluginManager(PluginManager): - def __init__(self): - self.siteshelper = SitesHelper() - self.pluginhelper = PluginHelper() - self.systemconfig = SystemConfigOper() class PluginReInstall(_PluginBase): @@ -43,7 +35,6 @@ class PluginReInstall(_PluginBase): _plugin_ids = [] _plugin_url = [] _base_url = "https://raw.githubusercontent.com/%s/%s/main/" - _pluginmanager: MyPluginManager = None def init_plugin(self, config: dict = None): if config: @@ -51,7 +42,6 @@ class PluginReInstall(_PluginBase): if not self._plugin_ids: return self._plugin_url = config.get("plugin_url") - self._pluginmanager = MyPluginManager() # 校验插件仓库格式 plugin_url = None @@ -95,7 +85,7 @@ class PluginReInstall(_PluginBase): # 重载插件管理器 if plugin_reload: logger.info("开始插件重载") - self._pluginmanager.init_config() + PluginManager().init_config() @staticmethod def get_repo_info(repo_url: str) -> Tuple[Optional[str], Optional[str]]: @@ -142,119 +132,119 @@ class PluginReInstall(_PluginBase): "value": local_plugin.get("id") }) return [ - { - 'component': 'VForm', - 'content': [ - { - 'component': 'VRow', - 'content': [ - { - 'component': 'VCol', - 'props': { - 'cols': 12, - 'md': 4 - }, - 'content': [ - { - 'component': 'VSelect', - 'props': { - 'multiple': True, - 'chips': True, - 'model': 'plugin_ids', - 'label': '重装插件', - 'items': pluginOptions - } - } - ] - }, - { - 'component': 'VCol', - 'props': { - 'cols': 12, - 'md': 8 - }, - 'content': [ - { - 'component': 'VTextField', - 'props': { - 'model': 'plugin_url', - 'label': '仓库地址', - 'placeholder': 'https://github.com/%s/%s/' - } - } - ] - } - ] - }, - { - 'component': 'VRow', - 'content': [ - { - 'component': 'VCol', - 'props': { - 'cols': 12, - }, - 'content': [ - { - 'component': 'VAlert', - 'props': { - 'type': 'info', - 'variant': 'tonal', - 'text': '选择已安装的本地插件,强制安装插件市场最新版本。' - } - } - ] - } - ] - }, - { - 'component': 'VRow', - 'content': [ - { - 'component': 'VCol', - 'props': { - 'cols': 12, - }, - 'content': [ - { - 'component': 'VAlert', - 'props': { - 'type': 'info', - 'variant': 'tonal', - 'text': '支持指定插件仓库地址(https://github.com/%s/%s/)' - } - } - ] - } - ] - }, - { - 'component': 'VRow', - 'content': [ - { - 'component': 'VCol', - 'props': { - 'cols': 12, - }, - 'content': [ - { - 'component': 'VAlert', - 'props': { - 'type': 'info', - 'variant': 'tonal', - 'text': '点击保存卡住请稍等一会,等其他线程执行完先。重载完有提示。' - } - } - ] - } - ] - } - ] - } - ], { - "plugin_ids": [], - "plugin_url": "" - } + { + 'component': 'VForm', + 'content': [ + { + 'component': 'VRow', + 'content': [ + { + 'component': 'VCol', + 'props': { + 'cols': 12, + 'md': 4 + }, + 'content': [ + { + 'component': 'VSelect', + 'props': { + 'multiple': True, + 'chips': True, + 'model': 'plugin_ids', + 'label': '重装插件', + 'items': pluginOptions + } + } + ] + }, + { + 'component': 'VCol', + 'props': { + 'cols': 12, + 'md': 8 + }, + 'content': [ + { + 'component': 'VTextField', + 'props': { + 'model': 'plugin_url', + 'label': '仓库地址', + 'placeholder': 'https://github.com/%s/%s/' + } + } + ] + } + ] + }, + { + 'component': 'VRow', + 'content': [ + { + 'component': 'VCol', + 'props': { + 'cols': 12, + }, + 'content': [ + { + 'component': 'VAlert', + 'props': { + 'type': 'info', + 'variant': 'tonal', + 'text': '选择已安装的本地插件,强制安装插件市场最新版本。' + } + } + ] + } + ] + }, + { + 'component': 'VRow', + 'content': [ + { + 'component': 'VCol', + 'props': { + 'cols': 12, + }, + 'content': [ + { + 'component': 'VAlert', + 'props': { + 'type': 'info', + 'variant': 'tonal', + 'text': '支持指定插件仓库地址(https://github.com/%s/%s/)' + } + } + ] + } + ] + }, + { + 'component': 'VRow', + 'content': [ + { + 'component': 'VCol', + 'props': { + 'cols': 12, + }, + 'content': [ + { + 'component': 'VAlert', + 'props': { + 'type': 'info', + 'variant': 'tonal', + 'text': '点击保存卡住请稍等一会,等其他线程执行完先。重载完有提示。' + } + } + ] + } + ] + } + ] + } + ], { + "plugin_ids": [], + "plugin_url": "" + } @staticmethod def get_local_plugins():