feat: 增加 Client Windows 打包基础 (#92)
This commit is contained in:
+9
-1
@@ -19,7 +19,15 @@ def data_dir() -> Path:
|
||||
"""返回可写数据目录;目录不存在时自动创建。"""
|
||||
|
||||
if getattr(sys, "frozen", False):
|
||||
directory = Path(sys.executable).resolve().parent / "data"
|
||||
executable_directory = Path(sys.executable).resolve().parent
|
||||
# 发布包结构是 Launcher.exe + app/CMAutoBuy.exe。主程序位于 app
|
||||
# 目录时,data 必须放在上一层,升级替换 app 才不会覆盖本地数据库。
|
||||
install_root = (
|
||||
executable_directory.parent
|
||||
if executable_directory.name.casefold() == "app"
|
||||
else executable_directory
|
||||
)
|
||||
directory = install_root / "data"
|
||||
else:
|
||||
directory = Path(__file__).resolve().parents[1] / "data"
|
||||
directory.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
Reference in New Issue
Block a user