1
1
mirror of https://github.com/KenanZhu/AutoLibrary.git synced 2026-06-22 01:13:02 +08:00

refactor(pages): 抽取时间选择策略为 TimeSelectMaker,将 Overlay 基类更名为 Dialog

将 findBestTimeOption 中的预约/续约双分支逻辑抽象为策略模式:
- TimeOptionReader 负责从 WebElement 提取时间数据(ReserveTimeReader / RenewTimeReader)
- TimeDecisionMaker 执行纯决策算法,零 Selenium 依赖
- TimeSelectMaker 作为工厂统一创建配置好的决策器
- 共享常量 LIBRARY_CLOSE_MINS 统一收敛至 TimeSelectMaker

同时将 Overlay 基类重命名为 Dialog,SeatMapOverlay 同步更名为 SeatMapDialog,保持命名一致性。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-27 13:13:43 +08:00
parent caa563e770
commit 345cb95b98
14 changed files with 244 additions and 114 deletions
+2 -2
View File
@@ -16,10 +16,10 @@ from selenium.common.exceptions import (
from selenium.webdriver.common.by import By
from selenium.webdriver.remote.webdriver import WebDriver
from pages.components.Overlay import Overlay
from pages.components.Dialog import Dialog
class CheckinResultDialog(Overlay):
class CheckinResultDialog(Dialog):
"""
Check-in result dialog.
"""
@@ -13,7 +13,7 @@ from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
class Overlay:
class Dialog:
"""
Context-managed overlay / modal / dialog on a page.
@@ -36,7 +36,7 @@ class Overlay:
def __enter__(
self,
) -> "Overlay":
) -> "Dialog":
WebDriverWait(self._driver, self._timeout).until(
EC.visibility_of_element_located(self._root_locator)
+2 -2
View File
@@ -16,10 +16,10 @@ from selenium.webdriver.common.by import By
from selenium.webdriver.remote.webdriver import WebDriver
from selenium.webdriver.remote.webelement import WebElement
from pages.components.Overlay import Overlay
from pages.components.Dialog import Dialog
class RenewDialog(Overlay):
class RenewDialog(Dialog):
"""
Renewal time selection dialog.
"""
+2 -2
View File
@@ -14,10 +14,10 @@ from selenium.common.exceptions import (
from selenium.webdriver.common.by import By
from selenium.webdriver.remote.webdriver import WebDriver
from pages.components.Overlay import Overlay
from pages.components.Dialog import Dialog
class ReserveResultDialog(Overlay):
class ReserveResultDialog(Dialog):
"""
Reservation result dialog shown after submitting a reserve request.
"""
@@ -18,10 +18,10 @@ from selenium.webdriver.remote.webdriver import WebDriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from pages.components.Overlay import Overlay
from pages.components.Dialog import Dialog
class SeatMapOverlay(Overlay):
class SeatMapDialog(Dialog):
"""
Seat selection overlay that opens after choosing a floor and room.
"""
+2 -2
View File
@@ -15,10 +15,10 @@ from selenium.webdriver.common.by import By
from selenium.webdriver.remote.webdriver import WebDriver
from selenium.webdriver.remote.webelement import WebElement
from pages.components.Overlay import Overlay
from pages.components.Dialog import Dialog
class TimeSelectDialog(Overlay):
class TimeSelectDialog(Dialog):
"""
Time selection panel that appears after selecting a seat.
+2 -2
View File
@@ -7,14 +7,14 @@ This software is provided "as is", without any warranty of any kind.
You may use, modify, and distribute this file under the terms of the MIT License.
See the LICENSE file for details.
"""
from pages.components.SeatMapOverlay import SeatMapOverlay
from pages.components.SeatMapDialog import SeatMapDialog
from pages.components.TimeSelectDialog import TimeSelectDialog
from pages.components.ReserveResultDialog import ReserveResultDialog
from pages.components.CheckinResultDialog import CheckinResultDialog
from pages.components.RenewDialog import RenewDialog
__all__ = [
"SeatMapOverlay",
"SeatMapDialog",
"TimeSelectDialog",
"ReserveResultDialog",
"CheckinResultDialog",