From 2b250a58ea43eeaf0767603d9d28f4f211adf049 Mon Sep 17 00:00:00 2001 From: duanshuwen Date: Mon, 6 Apr 2026 20:17:06 +0800 Subject: [PATCH] fix(fg_trace): handle date column index out of range error Improve robustness by checking if the requested dateIndex is within the available day columns before attempting to locate the element. This prevents a silent failure and provides a clear error message. --- src/main/scripts/fg.md | 2 +- src/main/scripts/fg_trace.js | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/scripts/fg.md b/src/main/scripts/fg.md index 64f62dc..13ae2bf 100644 --- a/src/main/scripts/fg.md +++ b/src/main/scripts/fg.md @@ -1,3 +1,3 @@ ```html -
房型排序
全部展开  
周三(今天)
03-11
周四
03-12
周五
03-13
周六
03-14
周日
03-15
周一
03-16
周二
03-17
周三
03-18
周四
03-19
周五
03-20
周六
03-21
周日
03-22
周一
03-23
周二
03-24
雅致大床房
雅致双床房
高级标准间
榻榻米双床房
亲子房
行政套房A
豪华特色房(麻将)
豪华至尊养生汤屋(私汤)
太空舱
亲子太空舱
豪华尊享大床房(双人温泉)
和雅小筑-至尊大床房(户外泡池)
至尊养生汤屋(含私汤)
行政套房B
天伦小筑-豪华套房(含私汤)
汤墅会馆
+
显示
房型排序
全部展开  
周一(今天)
04-06
周二
04-07
周三
04-08
周四
04-09
周五
04-10
周六
04-11
周日
04-12
周一
04-13
周二
04-14
周三
04-15
周四
04-16
周五
04-17
周六
04-18
周日
04-19
雅致大床房
双早-不可退
底价子价格活动
房态
限售
卖价
底价
服务
未维护
- -
-
-
2不可退
未维护
- -
-
-
2不可退
未维护
- -
-
-
2不可退
未维护
- -
-
-
2不可退
未维护
- -
-
-
2不可退
未维护
- -
-
-
2不可退
未维护
- -
-
-
2不可退
未维护
- -
-
-
2不可退
未维护
- -
-
-
2不可退
未维护
- -
-
-
2不可退
未维护
- -
-
-
2不可退
未维护
- -
-
-
2不可退
未维护
- -
-
-
2不可退
未维护
- -
-
-
2不可退
请选择
请选择
请选择
折后卖价
预计分账金额
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
雅致双床房
高级标准间
榻榻米双床房
亲子房
行政套房A
豪华特色房(麻将)
豪华至尊养生汤屋(私汤)
太空舱
亲子太空舱
豪华尊享大床房(双人温泉)
和雅小筑-至尊大床房(户外泡池)
至尊养生汤屋(含私汤)
行政套房B
天伦小筑-豪华套房(含私汤)
汤墅会馆
``` \ No newline at end of file diff --git a/src/main/scripts/fg_trace.js b/src/main/scripts/fg_trace.js index 4f3ae8c..854123e 100644 --- a/src/main/scripts/fg_trace.js +++ b/src/main/scripts/fg_trace.js @@ -104,13 +104,17 @@ const toggleRoomByDateIndex = async (container, { roomType, dateIndex, operation } await roomAnchor.scrollIntoViewIfNeeded(); - const row = roomAnchor.locator( - "xpath=ancestor::*[.//div[contains(@class,'boardRow')]][1]", + const boardRow = roomAnchor.locator("xpath=ancestor::div[contains(@class,'boardRow')][1]"); + const dayColumns = boardRow.locator( + "xpath=.//div[contains(@class,'switchbar')]/ancestor::div[contains(@class,'flex-col')][1]", ); - const boardRow = row.locator("xpath=.//div[contains(@class,'boardRow')]").first(); - - const boardColPosition = dateIndex + 2; - const dayColumn = boardRow.locator(`xpath=./div[${boardColPosition}]`); + const dayColumnCount = await dayColumns.count(); + if (dateIndex >= dayColumnCount) { + throw new Error( + `Date column out of range for room ${roomType}: index=${dateIndex}, available=${dayColumnCount}`, + ); + } + const dayColumn = dayColumns.nth(dateIndex); const targetStateClass = operation === 'open' ? 'error' : 'success'; const expectedCurrentLabel = operation === 'open' ? '满' : '有';