add display

This commit is contained in:
jxxghp 2023-06-12 22:54:31 +08:00
parent 04c7c071a3
commit 21b1f1a9c1
6 changed files with 60 additions and 34 deletions

View File

@ -29,7 +29,18 @@ class Command(metaclass=Singleton):
全局命令管理消费事件 全局命令管理消费事件
""" """
# 内建命令 # 内建命令
_commands = { _commands = {}
# 退出事件
_event = Event()
def __init__(self):
# 事件管理器
self.eventmanager = EventManager()
# 插件管理器
self.pluginmanager = PluginManager()
# 汇总插件命令
self._commands = {
"/cookiecloud": { "/cookiecloud": {
"func": CookieCloudChain().process, "func": CookieCloudChain().process,
"description": "同步站点Cookie", "description": "同步站点Cookie",
@ -58,16 +69,6 @@ class Command(metaclass=Singleton):
"data": {} "data": {}
} }
} }
# 退出事件
_event = Event()
def __init__(self):
# 事件管理器
self.eventmanager = EventManager()
# 插件管理器
self.pluginmanager = PluginManager()
# 汇总插件命令
plugin_commands = self.pluginmanager.get_plugin_commands() plugin_commands = self.pluginmanager.get_plugin_commands()
for command in plugin_commands: for command in plugin_commands:
self.register( self.register(

19
app/helper/display.py Normal file
View File

@ -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()

Binary file not shown.

View File

@ -8,6 +8,7 @@ from app.core.config import settings
from app.core.module import ModuleManager from app.core.module import ModuleManager
from app.core.plugin import PluginManager from app.core.plugin import PluginManager
from app.db.init import init_db, update_db from app.db.init import init_db, update_db
from app.helper.display import DisplayHelper
from app.helper.sites import SitesHelper from app.helper.sites import SitesHelper
from app.scheduler import Scheduler from app.scheduler import Scheduler
@ -35,6 +36,8 @@ def shutdown_server():
ModuleManager().stop() ModuleManager().stop()
# 停止事件消费 # 停止事件消费
Command().stop() Command().stop()
# 停止虚拟显示
DisplayHelper().stop()
@App.on_event("startup") @App.on_event("startup")
@ -42,18 +45,18 @@ def start_module():
""" """
启动模块 启动模块
""" """
# 虚伪显示
DisplayHelper()
# 加载模块 # 加载模块
ModuleManager() ModuleManager()
# 加载插件 # 加载插件
PluginManager() PluginManager()
# 加载站点
SitesHelper()
# 启动定时服务 # 启动定时服务
Scheduler() Scheduler()
# 启动事件消费 # 启动事件消费
Command() Command()
# 用户认证 # 站点管理
SitesHelper().check_user() SitesHelper()
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -39,3 +39,6 @@ torrentool~=1.2.0
slack_bolt~=1.18.0 slack_bolt~=1.18.0
slack_sdk~=3.21.3 slack_sdk~=3.21.3
chardet~=4.0.0 chardet~=4.0.0
starlette~=0.27.0
PyVirtualDisplay~=3.0
Cython~=0.29.35