feat: 添加任务下拉列表接口
This commit is contained in:
@@ -62,6 +62,22 @@ async def get_script_combox() -> ComboBoxOut:
|
||||
return ComboBoxOut(data=data)
|
||||
|
||||
|
||||
@router.post(
|
||||
"/combox/task",
|
||||
summary="获取可选任务下拉框信息",
|
||||
response_model=ComboBoxOut,
|
||||
status_code=200,
|
||||
)
|
||||
async def get_task_combox() -> ComboBoxOut:
|
||||
|
||||
try:
|
||||
raw_data = await Config.get_task_combox()
|
||||
data = [ComboBoxItem(**item) for item in raw_data] if raw_data else []
|
||||
except Exception as e:
|
||||
return ComboBoxOut(code=500, status="error", message=str(e), data=[])
|
||||
return ComboBoxOut(data=data)
|
||||
|
||||
|
||||
@router.post("/notice", summary="获取通知信息", response_model=InfoOut, status_code=200)
|
||||
async def get_notice_info() -> InfoOut:
|
||||
|
||||
|
||||
@@ -1277,6 +1277,29 @@ class AppConfig(GlobalConfig):
|
||||
|
||||
return data
|
||||
|
||||
async def get_task_combox(self):
|
||||
"""获取任务下拉框信息"""
|
||||
|
||||
logger.info("Getting task combo box information...")
|
||||
data = [{"label": "未选择", "value": None}]
|
||||
for uid, script in self.QueueConfig.items():
|
||||
data.append(
|
||||
{
|
||||
"label": f"队列 - {script.get('Info', 'Name')}",
|
||||
"value": str(uid),
|
||||
}
|
||||
)
|
||||
for uid, script in self.ScriptConfig.items():
|
||||
data.append(
|
||||
{
|
||||
"label": f"脚本 - {TYPE_BOOK[script.__class__.__name__]} - {script.get('Info', 'Name')}",
|
||||
"value": str(uid),
|
||||
}
|
||||
)
|
||||
logger.success("Task combo box information retrieved successfully.")
|
||||
|
||||
return data
|
||||
|
||||
async def get_server_info(self, type: str) -> Dict[str, Any]:
|
||||
"""获取公告信息"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user