mirror of
https://github.com/LifeArchiveProject/WeChatDataAnalysis.git
synced 2026-06-18 15:54:08 +08:00
fix(desktop-runtime): 兼容 updater 缺失并修复打包后 wcdb 加载路径
- electron-updater 改为可选加载,缺失时自动禁用更新并记录原因 - 打包环境优先注入 WECHAT_TOOL_WCDB_API_DLL_PATH 指向 resources/backend/native/wcdb_api.dll - 启动后端进程 cwd 调整为 exe 所在目录,避免运行目录不一致 - wcdb_init 失败时附带 native log 摘要,提升故障排查信息 - package.json 显式保留 updater 相关依赖,避免构建裁剪导致模块缺失
This commit is contained in:
@@ -253,7 +253,9 @@ def _ensure_initialized() -> None:
|
||||
return
|
||||
rc = int(lib.wcdb_init())
|
||||
if rc != 0:
|
||||
raise WCDBRealtimeError(f"wcdb_init failed: {rc}")
|
||||
logs = get_native_logs(require_initialized=False)
|
||||
hint = f" logs={logs[:6]}" if logs else ""
|
||||
raise WCDBRealtimeError(f"wcdb_init failed: {rc}.{hint}")
|
||||
_initialized = True
|
||||
|
||||
|
||||
@@ -315,11 +317,12 @@ def _call_out_error(fn, *args) -> None:
|
||||
pass
|
||||
|
||||
|
||||
def get_native_logs() -> list[str]:
|
||||
try:
|
||||
_ensure_initialized()
|
||||
except Exception:
|
||||
return []
|
||||
def get_native_logs(*, require_initialized: bool = True) -> list[str]:
|
||||
if require_initialized:
|
||||
try:
|
||||
_ensure_initialized()
|
||||
except Exception:
|
||||
return []
|
||||
lib = _load_wcdb_lib()
|
||||
out = ctypes.c_char_p()
|
||||
rc = int(lib.wcdb_get_logs(ctypes.byref(out)))
|
||||
|
||||
Reference in New Issue
Block a user