Refactor discrete material cleaner to improve maintainability and testability: - Introduce dependency injection pattern for service components - Add interfaces (IPageNavigator, IMaterialExtractor, IDeletionChecker) - Extract PageNavigator service for page navigation logic - Extract MaterialExtractor service for data extraction - Extract DatabaseDeletionChecker service for deletion logic - Add MaterialInfo data model for structured data - Centralize configuration (CleanerConfig, UIConstants) - Implement separation of concerns across services layer Also includes comprehensive execution mechanism documentation. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
73 lines
1.6 KiB
Python
73 lines
1.6 KiB
Python
"""
|
|
UI 常量配置
|
|
集中管理所有 UI 相关的选择器、超时、重试配置
|
|
"""
|
|
|
|
from dataclasses import dataclass
|
|
|
|
|
|
@dataclass
|
|
class Selectors:
|
|
"""CSS 选择器常量"""
|
|
|
|
# 搜索相关
|
|
SEARCH_BTN: str = ".search-component-searchBtn"
|
|
SEARCH_ICON: str = ".search-name-wrapper > .iconfont"
|
|
QUERY_BY_ORDER: str = "订单号查询"
|
|
TAB_ALL: str = "全部"
|
|
DISPLAY_COUNT_INPUT: str = "#rc_select_0"
|
|
|
|
# 订单相关
|
|
HOT_KEY_HEAD: str = "#hot-key-head_list"
|
|
MORE_BUTTON: str = "更多"
|
|
MATERIAL_PLAN: str = "备料计划"
|
|
|
|
# iframe
|
|
FORWARD_FRAME: str = "#forwardFrame"
|
|
MAIN_IFRAME: str = "#mainiframe"
|
|
|
|
# 按钮
|
|
MODIFY_BUTTON: str = "修改"
|
|
SAVE_BUTTON: str = "保存"
|
|
EXPAND_BUTTON: str = "展开"
|
|
|
|
# 容器
|
|
CARD_TABLE_SIDE_BOX: str = ".card-table-side-box"
|
|
|
|
|
|
@dataclass
|
|
class Timeouts:
|
|
"""超时配置常量(单位:毫秒)"""
|
|
|
|
# 页面加载
|
|
IFRAME_VISIBLE: int = 15000
|
|
PLAN_CODE_VISIBLE: int = 30000
|
|
BUTTON_VISIBLE: int = 10000
|
|
SERIAL_VISIBLE: int = 10000
|
|
FORM_VISIBLE: int = 5000
|
|
|
|
# 加载等待
|
|
LOADING_VISIBLE_WAIT: int = 3000
|
|
LOADING_HIDDEN_WAIT: int = 0 # 无限等待
|
|
|
|
# 轮询等待(秒)
|
|
PLAN_CODE_MAX_WAIT: int = 30 # 最多等待30秒
|
|
PLAN_CHECK_INTERVAL: float = 0.5 # 每0.5秒检查一次
|
|
|
|
|
|
@dataclass
|
|
class RetryConfig:
|
|
"""重试配置"""
|
|
|
|
DISPLAY_COUNT_MAX_RETRIES: int = 3
|
|
EXPECTED_DISPLAY_COUNT: str = "5000"
|
|
|
|
|
|
@dataclass
|
|
class UIConstants:
|
|
"""UI 配置总入口"""
|
|
|
|
selectors: Selectors = Selectors()
|
|
timeouts: Timeouts = Timeouts()
|
|
retry: RetryConfig = RetryConfig()
|