mirror of
https://github.com/JefferyHcool/BiliNote.git
synced 2026-05-07 08:22:54 +08:00
refactor(path_helper): 重构路径获取方法,支持打包运行
- 修改 get_data_dir 函数,以支持打包后可写的运行目录- 新增 get_app_dir 函数,提供更灵活的路径获取方式 - 优化路径处理逻辑,确保在不同环境下都能正确获取路径
This commit is contained in:
@@ -7,10 +7,10 @@ PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../")
|
||||
|
||||
def get_data_dir():
|
||||
if getattr(sys, 'frozen', False):
|
||||
# ✅ 打包后使用可写的运行目录
|
||||
|
||||
base_dir = os.path.dirname(sys.executable)
|
||||
else:
|
||||
# ✅ 开发时使用项目根目录下的 data 目录
|
||||
|
||||
base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../data"))
|
||||
|
||||
data_path = os.path.join(base_dir, "data")
|
||||
|
||||
Reference in New Issue
Block a user