feat: 添加计划表下拉框接口
This commit is contained in:
@@ -84,6 +84,24 @@ async def get_task_combox() -> ComboBoxOut:
|
||||
return ComboBoxOut(data=data)
|
||||
|
||||
|
||||
@router.post(
|
||||
"/combox/plan",
|
||||
summary="获取可选计划下拉框信息",
|
||||
response_model=ComboBoxOut,
|
||||
status_code=200,
|
||||
)
|
||||
async def get_plan_combox() -> ComboBoxOut:
|
||||
|
||||
try:
|
||||
raw_data = await Config.get_plan_combox()
|
||||
data = [ComboBoxItem(**item) for item in raw_data] if raw_data else []
|
||||
except Exception as e:
|
||||
return ComboBoxOut(
|
||||
code=500, status="error", message=f"{type(e).__name__}: {str(e)}", data=[]
|
||||
)
|
||||
return ComboBoxOut(data=data)
|
||||
|
||||
|
||||
@router.post(
|
||||
"/notice/get", summary="获取通知信息", response_model=NoticeOut, status_code=200
|
||||
)
|
||||
@@ -130,6 +148,23 @@ async def confirm_notice() -> OutBase:
|
||||
# return InfoOut(data=data)
|
||||
|
||||
|
||||
@router.post(
|
||||
"/startuptask",
|
||||
summary="获取启动时运行的队列ID",
|
||||
response_model=InfoOut,
|
||||
status_code=200,
|
||||
)
|
||||
async def get_startup_task() -> InfoOut:
|
||||
|
||||
try:
|
||||
data = await Config.get_startup_task()
|
||||
except Exception as e:
|
||||
return InfoOut(
|
||||
code=500, status="error", message=f"{type(e).__name__}: {str(e)}", data={}
|
||||
)
|
||||
return InfoOut(data={"queueIdList": data})
|
||||
|
||||
|
||||
@router.post(
|
||||
"/get/overview", summary="信息总览", response_model=InfoOut, status_code=200
|
||||
)
|
||||
|
||||
@@ -269,7 +269,7 @@ class MaaUserConfig(ConfigBase):
|
||||
self.Info_Mode = ConfigItem(
|
||||
"Info", "Mode", "简洁", OptionsValidator(["简洁", "详细"])
|
||||
)
|
||||
self.Info_StageMode = ConfigItem("Info", "StageMode", "固定")
|
||||
self.Info_StageMode = ConfigItem("Info", "StageMode", "Fixed")
|
||||
self.Info_Server = ConfigItem(
|
||||
"Info",
|
||||
"Server",
|
||||
@@ -375,7 +375,7 @@ class MaaUserConfig(ConfigBase):
|
||||
def get_plan_info(self) -> Dict[str, Union[str, int]]:
|
||||
"""获取当前的计划下信息"""
|
||||
|
||||
if self.get("Info", "StageMode") == "固定":
|
||||
if self.get("Info", "StageMode") == "Fixed":
|
||||
return {
|
||||
"MedicineNumb": self.get("Info", "MedicineNumb"),
|
||||
"SeriesNumb": self.get("Info", "SeriesNumb"),
|
||||
@@ -898,8 +898,6 @@ class AppConfig(GlobalConfig):
|
||||
else:
|
||||
data = await self.QueueConfig.get(uuid.UUID(queue_id))
|
||||
|
||||
print(data)
|
||||
|
||||
index = data.pop("instances", [])
|
||||
|
||||
return list(index), data
|
||||
@@ -1379,12 +1377,12 @@ class AppConfig(GlobalConfig):
|
||||
async def get_task_combox(self):
|
||||
"""获取任务下拉框信息"""
|
||||
|
||||
logger.info("Getting task combo box information...")
|
||||
logger.info("开始获取任务下拉框信息")
|
||||
data = [{"label": "未选择", "value": None}]
|
||||
for uid, script in self.QueueConfig.items():
|
||||
for uid, queue in self.QueueConfig.items():
|
||||
data.append(
|
||||
{
|
||||
"label": f"队列 - {script.get('Info', 'Name')}",
|
||||
"label": f"队列 - {queue.get('Info', 'Name')}",
|
||||
"value": str(uid),
|
||||
}
|
||||
)
|
||||
@@ -1395,7 +1393,18 @@ class AppConfig(GlobalConfig):
|
||||
"value": str(uid),
|
||||
}
|
||||
)
|
||||
logger.success("Task combo box information retrieved successfully.")
|
||||
logger.success("任务下拉框信息获取成功")
|
||||
|
||||
return data
|
||||
|
||||
async def get_plan_combox(self):
|
||||
"""获取计划下拉框信息"""
|
||||
|
||||
logger.info("开始获取计划下拉框信息")
|
||||
data = [{"label": "固定", "value": "Fixed"}]
|
||||
for uid, plan in self.PlanConfig.items():
|
||||
data.append({"label": plan.get("Info", "Name"), "value": str(uid)})
|
||||
logger.success("计划下拉框信息获取成功")
|
||||
|
||||
return data
|
||||
|
||||
@@ -1452,6 +1461,19 @@ class AppConfig(GlobalConfig):
|
||||
|
||||
return self.get("Data", "IfShowNotice"), remote_notice.get("notice_dict", {})
|
||||
|
||||
async def get_startup_task(self):
|
||||
"""获取启动时需要运行的队列信息"""
|
||||
|
||||
logger.info("获取启动时需要运行的队列信息")
|
||||
data = [
|
||||
str(uid)
|
||||
for uid, queue in self.QueueConfig.items()
|
||||
if queue.get("Info", "StartUpEnabled")
|
||||
]
|
||||
logger.success("启动时需要运行的队列信息获取成功")
|
||||
|
||||
return data
|
||||
|
||||
async def save_maa_log(self, log_path: Path, logs: list, maa_result: str) -> bool:
|
||||
"""
|
||||
保存MAA日志并生成对应统计数据
|
||||
|
||||
Reference in New Issue
Block a user