fix: recognize modern Chrome Sessions so open restores login
All checks were successful
技能自动化发布 / release (push) Successful in 10s

This commit is contained in:
2026-09-16 14:13:38 +08:00
parent b93b2ea36e
commit 7709292f1c
5 changed files with 110 additions and 11 deletions

View File

@@ -14,7 +14,10 @@ import sys
from db.connection import get_conn, init_db
from db.accounts_repo import get_account_by_id, get_platform_from_db
from service.chrome_profile_prefs import ensure_session_restore
from service.chrome_profile_prefs import (
ensure_session_restore,
profile_has_restorable_session,
)
from util.logging_config import get_skill_logger
from util.platforms import PLATFORMS
@@ -314,12 +317,9 @@ def cmd_open(account_id):
finally:
conn.close()
# 有可恢复会话时不带 URL;首次/空 Profile 仍打开平台首页便于登录
session_dir = os.path.join(profile_abs, "Default")
has_session = any(
os.path.isfile(os.path.join(session_dir, name))
for name in ("Current Session", "Last Session", "Current Tabs", "Last Tabs")
)
# 有可恢复会话时不带 URL;首次/空 Profile 仍打开平台首页便于登录。
# 须识别现代 Chrome 的 Default/Sessions/Session_*(仅认旧文件名会导致每次都开首页冲掉 Session Cookie)。
has_session = profile_has_restorable_session(profile_abs)
launch_url = None if has_session else url
cmd = [browser_exe, *human_chrome_launch_args(profile_abs, launch_url)]