mirror of
https://github.com/JefferyHcool/BiliNote.git
synced 2026-09-07 08:36:39 +08:00
Merge pull request #93 from JefferyHcool/feature/kuaishou
Feature/kuaishou
This commit is contained in:
@@ -6,7 +6,14 @@ PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../")
|
|||||||
|
|
||||||
|
|
||||||
def get_data_dir():
|
def get_data_dir():
|
||||||
data_path = os.path.join(PROJECT_ROOT, "data")
|
if getattr(sys, 'frozen', False):
|
||||||
|
|
||||||
|
base_dir = os.path.dirname(sys.executable)
|
||||||
|
else:
|
||||||
|
|
||||||
|
base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../data"))
|
||||||
|
|
||||||
|
data_path = os.path.join(base_dir, "data")
|
||||||
os.makedirs(data_path, exist_ok=True)
|
os.makedirs(data_path, exist_ok=True)
|
||||||
return data_path
|
return data_path
|
||||||
|
|
||||||
@@ -24,3 +31,20 @@ def get_model_dir(subdir: str = "whisper") -> str:
|
|||||||
os.makedirs(path, exist_ok=True)
|
os.makedirs(path, exist_ok=True)
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
||||||
|
def get_app_dir(subdir: str = "") -> str:
|
||||||
|
"""
|
||||||
|
返回一个稳定的可写目录:
|
||||||
|
- 开发时:使用项目 data 目录
|
||||||
|
- 打包后:使用 exe 所在目录
|
||||||
|
"""
|
||||||
|
if getattr(sys, 'frozen', False):
|
||||||
|
# 打包后运行:使用 main.exe 所在目录
|
||||||
|
base_dir = os.path.dirname(sys.executable)
|
||||||
|
else:
|
||||||
|
# 开发模式:使用项目的 /data 目录
|
||||||
|
base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../data"))
|
||||||
|
|
||||||
|
full_path = os.path.join(base_dir, subdir)
|
||||||
|
os.makedirs(full_path, exist_ok=True)
|
||||||
|
return full_path
|
||||||
Reference in New Issue
Block a user