mirror of
https://github.com/LifeArchiveProject/WeChatDataAnalysis.git
synced 2026-02-21 23:30:49 +08:00
- 若存在 WECHAT_TOOL_UI_DIR 或 frontend/.output/public,则在 / 挂载静态站点并支持 SPA 路由回退 - API 根端点调整为 /api,避免与静态 UI 冲突 - 新增 WECHAT_TOOL_DATA_DIR 输出目录约定,统一 databases/key store 等路径 - host/port 支持通过 WECHAT_TOOL_HOST / WECHAT_TOOL_PORT 配置,并打印可访问地址 - 新增 backend_entry.py 作为 PyInstaller 入口,减少动态导入识别问题
32 lines
745 B
Python
32 lines
745 B
Python
from __future__ import annotations
|
|
|
|
import os
|
|
from pathlib import Path
|
|
|
|
|
|
def get_data_dir() -> Path:
|
|
"""Base writable directory for all runtime output (logs, databases, key store).
|
|
|
|
- Desktop (Electron) should set `WECHAT_TOOL_DATA_DIR` to a per-user directory
|
|
(e.g. `%APPDATA%/WeChatDataAnalysis`).
|
|
- Dev defaults to the current working directory (repo root).
|
|
"""
|
|
|
|
v = os.environ.get("WECHAT_TOOL_DATA_DIR", "").strip()
|
|
if v:
|
|
return Path(v)
|
|
return Path.cwd()
|
|
|
|
|
|
def get_output_dir() -> Path:
|
|
return get_data_dir() / "output"
|
|
|
|
|
|
def get_output_databases_dir() -> Path:
|
|
return get_output_dir() / "databases"
|
|
|
|
|
|
def get_account_keys_path() -> Path:
|
|
return get_output_dir() / "account_keys.json"
|
|
|