feat: add path helper functions to file_service

- get_app_dir(): project root in dev, exe dir in PyInstaller bundle
- get_resource_path/get_config_path: paths under app dir
- get_log_dir/get_output_dir: auto-create and return logs/ and output/
- Refactor log_service to use get_log_dir() instead of own __file__ calc

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-15 16:48:37 +08:00
co-authored by Claude Sonnet 4.6
parent b8801ec024
commit f7d52e8cb0
3 changed files with 84 additions and 27 deletions
+9 -9
View File
@@ -87,18 +87,18 @@
任务:
- [ ] 在 `src/services/file_service.py` 中新增路径辅助函数(不单独建模块)
- [ ] 实现 `get_app_dir()`:返回程序根目录,兼容开发环境和 PyInstaller 打包环境
- [ ] 实现 `get_resource_path(relative_path)`:返回资源文件绝对路径
- [ ] 实现 `get_config_path(relative_path)`:返回配置文件绝对路径
- [ ] 实现 `get_log_dir()`:返回日志目录路径
- [ ] 实现 `get_output_dir()`:返回默认输出目录路径
- [ ] 保证 Windows 中文路径可用
- [x] 在 `src/services/file_service.py` 中新增路径辅助函数(不单独建模块)
- [x] 实现 `get_app_dir()`:返回程序根目录,兼容开发环境和 PyInstaller 打包环境
- [x] 实现 `get_resource_path(relative_path)`:返回资源文件绝对路径
- [x] 实现 `get_config_path(relative_path)`:返回配置文件绝对路径
- [x] 实现 `get_log_dir()`:返回日志目录路径
- [x] 实现 `get_output_dir()`:返回默认输出目录路径
- [x] 保证 Windows 中文路径可用
验收:
- [ ] 路径函数不使用开发机绝对路径
- [ ] 程序目录下缺少 `logs/` 或 `output/` 时可自动创建
- [x] 路径函数不使用开发机绝对路径
- [x] 程序目录下缺少 `logs/` 或 `output/` 时可自动创建
### 1.3 配置服务