feat(core): 启动时支持直接运行复数调度队列
This commit is contained in:
@@ -161,7 +161,7 @@ class AUTO_MAA(MSFluentWindow):
|
||||
# 开始任务菜单项
|
||||
self.tray_menu.addActions(
|
||||
[
|
||||
Action(FluentIcon.PLAY, "运行自动代理", triggered=self.start_main_task),
|
||||
Action(FluentIcon.PLAY, "运行启动时队列", triggered=self.start_up_task),
|
||||
Action(
|
||||
FluentIcon.PAUSE,
|
||||
"中止所有任务",
|
||||
@@ -385,11 +385,6 @@ class AUTO_MAA(MSFluentWindow):
|
||||
if Config.get(Config.function_HomeImageMode) == "主题图像":
|
||||
self.home.get_home_image()
|
||||
|
||||
# 直接运行主任务
|
||||
if Config.get(Config.start_IfRunDirectly):
|
||||
|
||||
self.start_main_task()
|
||||
|
||||
# 启动定时器
|
||||
MainTimer.start()
|
||||
|
||||
@@ -440,39 +435,27 @@ class AUTO_MAA(MSFluentWindow):
|
||||
)
|
||||
System.set_power("KillSelf")
|
||||
|
||||
elif Config.args.mode == "gui":
|
||||
|
||||
self.start_up_queue()
|
||||
|
||||
logger.success("启动时任务执行完成", module="主窗口")
|
||||
|
||||
def start_main_task(self) -> None:
|
||||
"""启动主任务"""
|
||||
def start_up_queue(self) -> None:
|
||||
"""启动时运行的调度队列"""
|
||||
|
||||
logger.info("正在启动主任务", module="主窗口")
|
||||
logger.info("开始调度启动时运行的调度队列", module="主窗口")
|
||||
|
||||
if "调度队列_1" in Config.queue_dict:
|
||||
for name, queue in Config.queue_dict.items():
|
||||
|
||||
logger.info("自动添加任务:调度队列_1", module="主窗口")
|
||||
TaskManager.add_task(
|
||||
"自动代理_主调度台",
|
||||
"调度队列_1",
|
||||
Config.queue_dict["调度队列_1"]["Config"].toDict(),
|
||||
)
|
||||
if queue["Config"].get(queue["Config"].QueueSet_StartUpEnabled):
|
||||
|
||||
elif "脚本_1" in Config.script_dict:
|
||||
logger.info(f"自动添加任务:{name}", module="主窗口")
|
||||
TaskManager.add_task(
|
||||
"自动代理_新调度台", name, queue["Config"].toDict()
|
||||
)
|
||||
|
||||
logger.info("自动添加任务:脚本_1", module="主窗口")
|
||||
TaskManager.add_task(
|
||||
"自动代理_主调度台", "自定义队列", {"Queue": {"Script_0": "脚本_1"}}
|
||||
)
|
||||
|
||||
else:
|
||||
|
||||
logger.warning(
|
||||
"启动主任务失败:未找到有效的主任务配置文件", module="主窗口"
|
||||
)
|
||||
MainInfoBar.push_info_bar(
|
||||
"warning", "启动主任务失败", "「调度队列_1」与「脚本_1」均不存在", -1
|
||||
)
|
||||
|
||||
logger.success("主任务启动完成", module="主窗口")
|
||||
logger.success("开始调度启动时运行的调度队列启动完成", module="主窗口")
|
||||
|
||||
def __currentChanged(self, index: int) -> None:
|
||||
"""切换界面时任务"""
|
||||
|
||||
@@ -402,10 +402,18 @@ class QueueManager(QWidget):
|
||||
configItem=self.config.QueueSet_Name,
|
||||
parent=self,
|
||||
)
|
||||
self.card_Enable = SwitchSettingCard(
|
||||
self.card_StartUpEnabled = SwitchSettingCard(
|
||||
icon=FluentIcon.CHECKBOX,
|
||||
title="启动时运行状态",
|
||||
content="调度队列启动时运行状态,启用后将在软件启动时自动运行本队列",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.QueueSet_StartUpEnabled,
|
||||
parent=self,
|
||||
)
|
||||
self.card_TimeEnable = SwitchSettingCard(
|
||||
icon=FluentIcon.CHECKBOX,
|
||||
title="定时运行状态",
|
||||
content="调度队列定时运行状态,仅启用时会执行定时任务",
|
||||
content="调度队列定时运行状态,启用时会执行定时任务",
|
||||
qconfig=self.config,
|
||||
configItem=self.config.QueueSet_TimeEnabled,
|
||||
parent=self,
|
||||
@@ -429,7 +437,8 @@ class QueueManager(QWidget):
|
||||
|
||||
Layout = QVBoxLayout()
|
||||
Layout.addWidget(self.card_Name)
|
||||
Layout.addWidget(self.card_Enable)
|
||||
Layout.addWidget(self.card_StartUpEnabled)
|
||||
Layout.addWidget(self.card_TimeEnable)
|
||||
Layout.addWidget(self.card_AfterAccomplish)
|
||||
|
||||
self.viewLayout.addLayout(Layout)
|
||||
|
||||
@@ -806,14 +806,6 @@ class StartSettingCard(HeaderCardWidget):
|
||||
configItem=Config.start_IfSelfStart,
|
||||
parent=self,
|
||||
)
|
||||
self.card_IfRunDirectly = SwitchSettingCard(
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="启动后直接运行主任务",
|
||||
content="启动AUTO_MAA后自动运行自动代理任务,优先级:调度队列 1 > 脚本 1",
|
||||
qconfig=Config,
|
||||
configItem=Config.start_IfRunDirectly,
|
||||
parent=self,
|
||||
)
|
||||
self.card_IfMinimizeDirectly = SwitchSettingCard(
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="启动后直接最小化",
|
||||
@@ -825,7 +817,6 @@ class StartSettingCard(HeaderCardWidget):
|
||||
|
||||
Layout = QVBoxLayout()
|
||||
Layout.addWidget(self.card_IfSelfStart)
|
||||
Layout.addWidget(self.card_IfRunDirectly)
|
||||
Layout.addWidget(self.card_IfMinimizeDirectly)
|
||||
self.viewLayout.addLayout(Layout)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user