feat(event): add ResourceSelection event for update resource contexts

This commit is contained in:
InfinityPacer
2024-12-04 20:21:57 +08:00
parent 922e2fc446
commit a1e178c805
3 changed files with 46 additions and 2 deletions
+27 -1
View File
@@ -1,8 +1,10 @@
from pathlib import Path
from typing import Optional, Dict, Any
from typing import Optional, Dict, Any, List
from pydantic import BaseModel, Field, root_validator
from app.core.context import Context
class BaseEventData(BaseModel):
"""
@@ -143,3 +145,27 @@ class TransferRenameEventData(ChainEventData):
updated: bool = Field(False, description="是否已更新")
updated_str: Optional[str] = Field(None, description="更新后的字符串")
source: Optional[str] = Field("未知拦截源", description="拦截源")
class ResourceSelectionEventData(BaseModel):
"""
ResourceSelection 事件的数据模型
Attributes:
# 输入参数
contexts (List[Context]): 当前待选择的资源上下文列表
source (str): 事件源,指示事件的触发来源
# 输出参数
updated (bool): 是否已更新,默认值为 False
updated_contexts (Optional[List[Context]]): 已更新的资源上下文列表,默认值为 None
source (str): 更新源,默认值为 "未知更新源"
"""
# 输入参数
contexts: Any = Field(None, description="待选择的资源上下文列表")
downloader: Optional[str] = Field(None, description="下载器")
# 输出参数
updated: bool = Field(False, description="是否已更新")
updated_contexts: Optional[List[Context]] = Field(None, description="已更新的资源上下文列表")
source: Optional[str] = Field("未知拦截源", description="拦截源")
+2
View File
@@ -70,6 +70,8 @@ class ChainEventType(Enum):
CommandRegister = "command.register"
# 整理重命名
TransferRename = "transfer.rename"
# 资源选择
ResourceSelection = "resource.selection"
# 系统配置Key字典