feat: 添加脚本下拉框接口
This commit is contained in:
@@ -40,6 +40,21 @@ async def get_stage_info() -> InfoOut:
|
||||
return InfoOut(data=data)
|
||||
|
||||
|
||||
@router.post(
|
||||
"/combox/script",
|
||||
summary="获取脚本下拉框信息",
|
||||
response_model=ComboBoxOut,
|
||||
status_code=200,
|
||||
)
|
||||
async def get_script_combox() -> ComboBoxOut:
|
||||
|
||||
try:
|
||||
data: List[ComboBoxItem] = await Config.get_script_combox()
|
||||
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:
|
||||
|
||||
|
||||
@@ -627,6 +627,7 @@ class GeneralConfig(ConfigBase):
|
||||
|
||||
|
||||
CLASS_BOOK = {"MAA": MaaConfig, "MaaPlan": MaaPlanConfig, "General": GeneralConfig}
|
||||
TYPE_BOOK = {"MaaConfig": "MAA", "GeneralConfig": "通用"}
|
||||
|
||||
|
||||
class AppConfig(GlobalConfig):
|
||||
@@ -1262,6 +1263,22 @@ class AppConfig(GlobalConfig):
|
||||
|
||||
return True, {"ALL": results}
|
||||
|
||||
async def get_script_combox(self):
|
||||
"""获取脚本下拉框信息"""
|
||||
|
||||
logger.info("Getting script combo box information...")
|
||||
data = []
|
||||
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("Script combo box information retrieved successfully.")
|
||||
|
||||
return data
|
||||
|
||||
async def get_server_info(self, type: str) -> Dict[str, Any]:
|
||||
"""获取公告信息"""
|
||||
|
||||
|
||||
@@ -34,6 +34,15 @@ class InfoOut(OutBase):
|
||||
data: Dict[str, Any] = Field(..., description="收到的服务器数据")
|
||||
|
||||
|
||||
class ComboBoxItem(BaseModel):
|
||||
label: str = Field(..., description="展示值")
|
||||
value: str = Field(..., description="实际值")
|
||||
|
||||
|
||||
class ComboBoxOut(OutBase):
|
||||
data: List[ComboBoxItem] = Field(..., description="下拉框选项")
|
||||
|
||||
|
||||
class GlobalConfig_Function(BaseModel):
|
||||
HistoryRetentionTime: Optional[Literal[7, 15, 30, 60, 90, 180, 365, 0]] = Field(
|
||||
None, description="历史记录保留时间, 0表示永久保存"
|
||||
|
||||
Reference in New Issue
Block a user