update
This commit is contained in:
@@ -780,6 +780,8 @@ class App(tk.Tk):
|
|||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
env["PYTHONIOENCODING"] = "utf-8"
|
env["PYTHONIOENCODING"] = "utf-8"
|
||||||
env["WECHAT_DECRYPT_APP_DIR"] = BASE_DIR
|
env["WECHAT_DECRYPT_APP_DIR"] = BASE_DIR
|
||||||
|
env["WECHAT_DECRYPT_GUI"] = "1"
|
||||||
|
env["WECHAT_DECRYPT_NONINTERACTIVE"] = "1"
|
||||||
|
|
||||||
if self._selected_contacts:
|
if self._selected_contacts:
|
||||||
env["WECHAT_EXPORT_CONTACTS"] = ",".join(self._selected_contacts)
|
env["WECHAT_EXPORT_CONTACTS"] = ",".join(self._selected_contacts)
|
||||||
|
|||||||
@@ -54,7 +54,11 @@ def _choose_candidate(candidates):
|
|||||||
if len(candidates) == 1:
|
if len(candidates) == 1:
|
||||||
return candidates[0]
|
return candidates[0]
|
||||||
if len(candidates) > 1:
|
if len(candidates) > 1:
|
||||||
if not sys.stdin.isatty():
|
if (
|
||||||
|
os.environ.get("WECHAT_DECRYPT_NONINTERACTIVE") == "1"
|
||||||
|
or os.environ.get("WECHAT_DECRYPT_GUI") == "1"
|
||||||
|
or not sys.stdin.isatty()
|
||||||
|
):
|
||||||
return candidates[0]
|
return candidates[0]
|
||||||
print("[!] 检测到多个微信数据目录(请选择当前正在运行的微信账号):")
|
print("[!] 检测到多个微信数据目录(请选择当前正在运行的微信账号):")
|
||||||
for i, c in enumerate(candidates, 1):
|
for i, c in enumerate(candidates, 1):
|
||||||
|
|||||||
@@ -140,6 +140,35 @@ def get_wxwork_pids():
|
|||||||
|
|
||||||
# ── WXWork 数据目录自动检测 ──────────────────────────────────────────
|
# ── WXWork 数据目录自动检测 ──────────────────────────────────────────
|
||||||
|
|
||||||
|
def _wxwork_data_dir_mtime(data_dir):
|
||||||
|
"""返回企业微信 Data 目录最近活跃时间,用于多账号自动选择。"""
|
||||||
|
latest = 0
|
||||||
|
for root, dirs, files in os.walk(data_dir):
|
||||||
|
dirs[:] = [d for d in dirs if d not in ("-journal",)]
|
||||||
|
for name in files:
|
||||||
|
if not name.endswith((".db", ".db-wal", ".db-shm")):
|
||||||
|
continue
|
||||||
|
path = os.path.join(root, name)
|
||||||
|
try:
|
||||||
|
latest = max(latest, os.path.getmtime(path))
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
latest = max(latest, os.path.getmtime(data_dir))
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
return latest
|
||||||
|
|
||||||
|
|
||||||
|
def _is_noninteractive_mode():
|
||||||
|
return (
|
||||||
|
os.environ.get("WECHAT_DECRYPT_NONINTERACTIVE") == "1"
|
||||||
|
or os.environ.get("WXWORK_AUTO_SELECT_DB") == "1"
|
||||||
|
or os.environ.get("WECHAT_DECRYPT_GUI") == "1"
|
||||||
|
or not sys.stdin.isatty()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def auto_detect_wxwork_db_dir():
|
def auto_detect_wxwork_db_dir():
|
||||||
"""扫描 %USERPROFILE%\\Documents\\WXWork\\*\\Data 寻找包含加密DB的目录"""
|
"""扫描 %USERPROFILE%\\Documents\\WXWork\\*\\Data 寻找包含加密DB的目录"""
|
||||||
docs = os.path.join(os.environ.get("USERPROFILE", ""), "Documents", "WXWork")
|
docs = os.path.join(os.environ.get("USERPROFILE", ""), "Documents", "WXWork")
|
||||||
@@ -168,11 +197,18 @@ def auto_detect_wxwork_db_dir():
|
|||||||
|
|
||||||
if not candidates:
|
if not candidates:
|
||||||
return None
|
return None
|
||||||
|
candidates.sort(key=_wxwork_data_dir_mtime, reverse=True)
|
||||||
if len(candidates) == 1:
|
if len(candidates) == 1:
|
||||||
return candidates[0]
|
return candidates[0]
|
||||||
|
|
||||||
if not sys.stdin.isatty():
|
if _is_noninteractive_mode():
|
||||||
|
selected = candidates[0]
|
||||||
|
print("[!] 检测到多个企业微信数据目录,非交互模式下自动选择最近活跃目录:")
|
||||||
|
for i, c in enumerate(candidates, 1):
|
||||||
|
marker = " *" if c == selected else " "
|
||||||
|
print(f" {marker} {i}. {c}")
|
||||||
return candidates[0]
|
return candidates[0]
|
||||||
|
|
||||||
print("[!] 检测到多个企业微信数据目录:")
|
print("[!] 检测到多个企业微信数据目录:")
|
||||||
for i, c in enumerate(candidates, 1):
|
for i, c in enumerate(candidates, 1):
|
||||||
print(f" {i}. {c}")
|
print(f" {i}. {c}")
|
||||||
|
|||||||
Reference in New Issue
Block a user