feat(core): 恢复启动后直接运行主任务功能以及相关托盘菜单

This commit is contained in:
DLmaster
2025-02-16 14:56:25 +08:00
parent c3212f0ca1
commit b3a3ccfea3
3 changed files with 46 additions and 53 deletions

View File

@@ -45,6 +45,7 @@ from qfluentwidgets import (
) )
from PySide6.QtGui import QIcon, QCloseEvent from PySide6.QtGui import QIcon, QCloseEvent
from PySide6.QtCore import Qt, QTimer from PySide6.QtCore import Qt, QTimer
import json
from app.core import Config, TaskManager, MainTimer, MainInfoBar from app.core import Config, TaskManager, MainTimer, MainInfoBar
from app.services import Notify, Crypto, System from app.services import Notify, Crypto, System
@@ -142,22 +143,17 @@ class AUTO_MAA(MSFluentWindow):
self.tray_menu.addSeparator() self.tray_menu.addSeparator()
# 开始任务菜单项 # 开始任务菜单项
# self.tray_menu.addActions( self.tray_menu.addActions(
# [ [
# Action( Action(FluentIcon.PLAY, "运行自动代理", triggered=self.start_main_task),
# FluentIcon.PLAY, Action(
# "运行自动代理", FluentIcon.PAUSE,
# triggered=lambda: self.start_task("自动代理"), "中止所有任务",
# ), triggered=lambda: TaskManager.stop_task("ALL"),
# Action( ),
# FluentIcon.PLAY, ]
# "运行人工排查", )
# triggered=lambda: self.start_task("人工排查"), self.tray_menu.addSeparator()
# ),
# Action(FluentIcon.PAUSE, "中止当前任务", triggered=self.stop_task),
# ]
# )
# self.tray_menu.addSeparator()
# 退出主程序菜单项 # 退出主程序菜单项
self.tray_menu.addAction( self.tray_menu.addAction(
@@ -228,6 +224,11 @@ class AUTO_MAA(MSFluentWindow):
info.addWidget(Up) info.addWidget(Up)
info.show() info.show()
# 直接运行主任务
if Config.global_config.get(Config.global_config.start_IfRunDirectly):
self.start_main_task()
def set_min_method(self) -> None: def set_min_method(self) -> None:
"""设置最小化方法""" """设置最小化方法"""
@@ -246,40 +247,32 @@ class AUTO_MAA(MSFluentWindow):
if reason == QSystemTrayIcon.DoubleClick: if reason == QSystemTrayIcon.DoubleClick:
self.show_ui("显示主窗口") self.show_ui("显示主窗口")
# def start_task(self, mode): def start_main_task(self) -> None:
# """调起对应任务""" """启动主任务"""
# if self.main.MaaManager.isRunning():
# Notify.push_notification(
# f"无法运行{mode}",
# "当前已有任务正在运行,请在该任务结束后重试",
# "当前已有任务正在运行,请在该任务结束后重试",
# 3,
# )
# else:
# self.main.maa_starter(mode)
# def stop_task(self): if (Config.app_path / "config/QueueConfig/调度队列_1.json").exists():
# """中止当前任务"""
# if self.main.MaaManager.isRunning(): with (Config.app_path / "config/QueueConfig/调度队列_1.json").open(
# if ( mode="r", encoding="utf-8"
# self.main.MaaManager.mode == "自动代理" ) as f:
# or self.main.MaaManager.mode == "人工排查" info = json.load(f)
# ):
# self.main.maa_ender(f"{self.main.MaaManager.mode}_结束") logger.info("自动添加任务调度队列_1")
# elif "设置MAA" in self.main.MaaManager.mode: TaskManager.add_task("自动代理_主调度台", "主任务队列", info)
# Notify.push_notification(
# "正在设置MAA", elif (Config.app_path / "config/MaaConfig/脚本_1").exists():
# "正在运行设置MAA任务无法中止",
# "正在运行设置MAA任务无法中止", info = {"Queue": {"Member_1": "脚本_1"}}
# 3,
# ) logger.info("自动添加任务脚本_1")
# else: TaskManager.add_task("自动代理_主调度台", "主任务队列", info)
# Notify.push_notification(
# "无任务运行!", else:
# "当前无任务正在运行,无需中止",
# "当前无任务正在运行,无需中止", logger.worning("启动主任务失败:未找到有效的主任务配置文件")
# 3, MainInfoBar.push_info_bar(
# ) "warning", "启动主任务失败", "“调度队列_1”与“脚本_1”均不存在", -1
)
def show_ui(self, mode: str, if_quick: bool = False) -> None: def show_ui(self, mode: str, if_quick: bool = False) -> None:
"""配置窗口状态""" """配置窗口状态"""

View File

@@ -484,8 +484,8 @@ class StartSettingCard(HeaderCardWidget):
) )
self.card_IfRunDirectly = SwitchSettingCard( self.card_IfRunDirectly = SwitchSettingCard(
icon=FluentIcon.PAGE_RIGHT, icon=FluentIcon.PAGE_RIGHT,
title="启动后直接运行", title="启动后直接运行主任务",
content="启动AUTO_MAA后自动运行任务(暂不可用)", content="启动AUTO_MAA后自动运行自动代理任务,优先级:调度队列 1 > 脚本 1",
configItem=Config.global_config.start_IfRunDirectly, configItem=Config.global_config.start_IfRunDirectly,
) )

View File

@@ -1,7 +1,7 @@
{ {
"main_version": "4.2.3.2", "main_version": "4.2.3.3",
"updater_version": "1.1.1.3", "updater_version": "1.1.1.3",
"announcement": "\n## 新增功能\n- 添加`简洁用户列表下相邻两个任务间的切换方式`可选项\n## 修复BUG\n- 修复静默代理标记移除异常情况\n- 适配深色模式 #18\n## 程序优化\n- 优化MAA关闭方法\n- 添加高级代理文件校验过程\n- 升级日志监看方法\n- 优化主调度台默认选项", "announcement": "\n## 新增功能\n- 添加`简洁用户列表下相邻两个任务间的切换方式`可选项\n- 恢复启动后直接运行主任务功能以及相关托盘菜单\n## 修复BUG\n- 修复静默代理标记移除异常情况\n- 适配深色模式 #18\n## 程序优化\n- 优化MAA关闭方法\n- 添加高级代理文件校验过程\n- 升级日志监看方法\n- 优化主调度台默认选项",
"proxy_list": [ "proxy_list": [
"", "",
"https://gitproxy.click/", "https://gitproxy.click/",