修复:第一次运行时,无法找到 questions.csv

This commit is contained in:
2025-05-18 12:02:35 +08:00
parent 6961b70a7d
commit 83b3790e8b
3 changed files with 13 additions and 10 deletions

View File

@@ -6,6 +6,7 @@ from pathlib import Path
from PySide6.QtWidgets import QApplication
from ui.main import MainWindow
from utils.function import resource_path
appdata_dir = Path(os.environ["APPDATA"])
dtg_dir = appdata_dir / "dtg"
@@ -13,7 +14,7 @@ target_csv = dtg_dir / "questions.csv"
if not target_csv.exists():
dtg_dir.mkdir(parents=True, exist_ok=True)
source_csv = Path("template/questions.csv")
source_csv = Path(resource_path("template/questions.csv"))
if not source_csv.exists():
raise FileNotFoundError(f"源文件不存在:{source_csv.resolve()}")
shutil.copy(source_csv, target_csv)