chore: auto release commit (2026-09-15 01:15:35)
Some checks failed
技能自动化发布 / release (push) Failing after 5s

This commit is contained in:
2026-09-15 01:15:35 +08:00
parent 52831b80e0
commit aa9bf262fe
5 changed files with 263 additions and 19 deletions

View File

@@ -180,19 +180,27 @@ def _is_spa_routed(page) -> bool:
def _try_auto_sign_in(page, wait_input_sec: int = 2) -> bool:
"""v1.1.21:检测登录页 demo/123456 是否已预填,有则自动点 Sign in。
适用场景:sandbox root 登录页(https://sandbox.jc2009.com/)
默认有 demo + 123456 预填在 #jc-user / #jc-pass,脚本无需 fill 直接点。
v1.1.24:扩展到支持 SPA 二级登录页(/industries/campus/smartcampus/login),
按钮文本可能是中文「登录」而非英文「Sign in」。
适用场景:
- 根域登录页(https://sandbox.jc2009.com/):按钮「Sign in」
- SPA 二级登录页(/industries/campus/smartcampus/login):按钮「登录」
默认有 demo/123456(或 18677308191 等真实账号)预填在 input。
行为:
1. 等 #jc-user 出现,最长 wait_input_sec 秒(默认 2s)
2. 检查 #jc-user 和 #jc-pass 是否都有值
3. 有值 → 点 Sign in → return True
4. 无值 → return False(交给 _wait_for_manual_login 接管)
1. 等 input 出现,最长 wait_input_sec 秒(默认 2s)
2. 检查 input 是否都有值
3. 有值 → 点 Sign in / 登录 → return True
4. 无值 → return False(交给 _wait_for_login_inputs_filled 接管)
不会自动 fill(如果没值就放弃,让用户自己输)。
"""
try:
page.wait_for_selector("#jc-user, #jc-pass", timeout=wait_input_sec * 1000)
page.wait_for_selector(
"#jc-user, #jc-pass, input[type='tel'], input[type='password']",
timeout=wait_input_sec * 1000,
)
except Exception:
logger.info(
"platform_collector: %ds 内未出现登录 input,跳过自动登录",
@@ -200,9 +208,23 @@ def _try_auto_sign_in(page, wait_input_sec: int = 2) -> bool:
)
return False
user_input = page.locator("#jc-user").first
pass_input = page.locator("#jc-pass").first
if user_input.count() == 0 or pass_input.count() == 0:
# 多种 input selector 优先级
user_input = None
for sel in ("#jc-user", "input[type='tel']", "input[autocomplete='username']"):
loc = page.locator(sel).first
if loc.count() > 0:
user_input = loc
break
if user_input is None:
return False
pass_input = None
for sel in ("#jc-pass", "input[type='password']", "input[autocomplete='current-password']"):
loc = page.locator(sel).first
if loc.count() > 0:
pass_input = loc
break
if pass_input is None:
return False
user_val = (user_input.input_value() or "").strip()
@@ -216,14 +238,26 @@ def _try_auto_sign_in(page, wait_input_sec: int = 2) -> bool:
)
return False
logger.info(
"platform_collector: 登录页已预填账号(user=%r),自动点 Sign in",
user_val,
)
btn = page.locator('button[type="submit"]:has-text("Sign in")').first
if btn.count() == 0:
logger.warning("platform_collector: 未找到 Sign in 按钮")
# 多种按钮文本优先级:英文 Sign in > 中文登录 > submit
btn = None
btn_text_used = ""
for txt in ("Sign in", "登录", "Login", "signin"):
loc = page.locator(f"button:has-text('{txt}')").first
if loc.count() > 0:
btn = loc
btn_text_used = txt
break
if btn is None:
btn = page.locator("button[type='submit']").first
btn_text_used = "submit"
if btn is None or btn.count() == 0:
logger.warning("platform_collector: 未找到登录按钮")
return False
logger.info(
"platform_collector: 登录页已预填账号(user=%r),自动点 %s 按钮",
user_val, btn_text_used,
)
btn.click()
return True
@@ -681,6 +715,35 @@ def collect_all(
)
# 不强行 reload —— 让用户决定是否手工刷新
# 4.5. v1.1.24:sandbox 可能登录后把人踢回 SPA 二级登录页
# (/industries/campus/smartcampus/login)。如果 URL 落在
# 这个二级登录页,再走一次 _try_auto_sign_in(已经扩展支持
# 中文「登录」按钮);若 SPA 登录页 input 有预填账号 → 自动点;
# 若 input 空 → 走 _wait_for_login_inputs_filled 等用户输入。
cur_url_after_stable = page.url.lower()
if "/login" in cur_url_after_stable or "/signin" in cur_url_after_stable:
logger.warning(
"platform_collector: 登录后仍落在登录页(%s),"
"v1.1.24 触发 SPA 二级登录兜底",
page.url,
)
spa_auto = _try_auto_sign_in(page, wait_input_sec=2)
if spa_auto:
logger.info(
"platform_collector: ✅ SPA 二级登录页已自动登录,"
"等 URL 跳到 /app/ 或 /select"
)
_wait_for_url_stable(page, ("/app/", "/select"), max_wait_sec=30)
elif not headless:
if _wait_for_login_inputs_filled(page, wait_sec=human_wait_timeout):
_wait_for_url_stable(page, ("/app/", "/select"), max_wait_sec=30)
else:
_wait_for_manual_login(page, wait_sec=human_wait_timeout)
else:
raise LoginTimeoutError(
f"SPA 二级登录页 input 空且 headless 无法手工登录(URL={page.url})"
)
# 5. v1.1.22:显式跳到 SPA_HOME_URL(/app/home),等侧边栏 link 出现
# 避免 sandbox 在 /select 中间页时直接找 sidebar link 找不到
if "/app/home" not in page.url.lower():

View File

@@ -6,7 +6,7 @@
"""
SKILL_SLUG = "alert-contract-expiring-hr"
SKILL_VERSION = "1.1.23"
SKILL_VERSION = "1.1.24"
LOG_LOGGER_NAME = "openclaw.skill.alert_contract_expiring_hr"
PLATFORM_KIT_MIN_VERSION = "1.2.11"