diff --git a/app/command.py b/app/command.py index 41c9cd6e..67a0ab34 100644 --- a/app/command.py +++ b/app/command.py @@ -29,35 +29,7 @@ class Command(metaclass=Singleton): 全局命令管理,消费事件 """ # 内建命令 - _commands = { - "/cookiecloud": { - "func": CookieCloudChain().process, - "description": "同步站点Cookie", - "data": {} - }, - "/douban_sync": { - "func": DoubanSyncChain().process, - "description": "同步豆瓣想看", - "data": {} - }, - "/subscribe_refresh": { - "func": SubscribeChain().refresh, - "description": "刷新订阅", - "data": {} - }, - "/subscribe_search": { - "func": SubscribeChain().search, - "description": "搜索订阅", - "data": { - 'state': 'R', - } - }, - "/transfer": { - "func": TransferChain().process, - "description": "下载文件整理", - "data": {} - } - } + _commands = {} # 退出事件 _event = Event() @@ -68,6 +40,35 @@ class Command(metaclass=Singleton): # 插件管理器 self.pluginmanager = PluginManager() # 汇总插件命令 + self._commands = { + "/cookiecloud": { + "func": CookieCloudChain().process, + "description": "同步站点Cookie", + "data": {} + }, + "/douban_sync": { + "func": DoubanSyncChain().process, + "description": "同步豆瓣想看", + "data": {} + }, + "/subscribe_refresh": { + "func": SubscribeChain().refresh, + "description": "刷新订阅", + "data": {} + }, + "/subscribe_search": { + "func": SubscribeChain().search, + "description": "搜索订阅", + "data": { + 'state': 'R', + } + }, + "/transfer": { + "func": TransferChain().process, + "description": "下载文件整理", + "data": {} + } + } plugin_commands = self.pluginmanager.get_plugin_commands() for command in plugin_commands: self.register( diff --git a/app/helper/display.py b/app/helper/display.py new file mode 100644 index 00000000..1ae6504a --- /dev/null +++ b/app/helper/display.py @@ -0,0 +1,19 @@ +from pyvirtualdisplay import Display + +from app.log import logger +from app.utils.singleton import Singleton + + +class DisplayHelper(metaclass=Singleton): + _display: Display = None + + def __init__(self): + try: + self._display = Display(visible=False, size=(1024, 768)) + self._display.start() + except Exception as err: + logger.error(f"DisplayHelper init error: {err}") + + def stop(self): + if self._display: + self._display.stop() diff --git a/app/helper/sites.cp310-win_amd64.pyd b/app/helper/sites.cp310-win_amd64.pyd index 7eac4a07..b7237775 100644 Binary files a/app/helper/sites.cp310-win_amd64.pyd and b/app/helper/sites.cp310-win_amd64.pyd differ diff --git a/app/helper/sites.cpython-310-x86_64-linux-gnu.so b/app/helper/sites.cpython-310-x86_64-linux-gnu.so index 717aaf16..1210f9a9 100644 Binary files a/app/helper/sites.cpython-310-x86_64-linux-gnu.so and b/app/helper/sites.cpython-310-x86_64-linux-gnu.so differ diff --git a/app/main.py b/app/main.py index 4d839fab..7365e2f8 100644 --- a/app/main.py +++ b/app/main.py @@ -8,6 +8,7 @@ from app.core.config import settings from app.core.module import ModuleManager from app.core.plugin import PluginManager from app.db.init import init_db, update_db +from app.helper.display import DisplayHelper from app.helper.sites import SitesHelper from app.scheduler import Scheduler @@ -35,6 +36,8 @@ def shutdown_server(): ModuleManager().stop() # 停止事件消费 Command().stop() + # 停止虚拟显示 + DisplayHelper().stop() @App.on_event("startup") @@ -42,18 +45,18 @@ def start_module(): """ 启动模块 """ + # 虚伪显示 + DisplayHelper() # 加载模块 ModuleManager() # 加载插件 PluginManager() - # 加载站点 - SitesHelper() # 启动定时服务 Scheduler() # 启动事件消费 Command() - # 用户认证 - SitesHelper().check_user() + # 站点管理 + SitesHelper() if __name__ == '__main__': diff --git a/requirements.txt b/requirements.txt index cd955986..25d8c1a0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -38,4 +38,7 @@ cf_clearance~=0.29.2 torrentool~=1.2.0 slack_bolt~=1.18.0 slack_sdk~=3.21.3 -chardet~=4.0.0 \ No newline at end of file +chardet~=4.0.0 +starlette~=0.27.0 +PyVirtualDisplay~=3.0 +Cython~=0.29.35 \ No newline at end of file