feat: 添加依赖自动检测与安装、选项记忆、KDocs登录优化
- 新增依赖检测模块:启动时自动检测wkhtmltoimage和Playwright Chromium - 新增依赖安装对话框:缺失时提示用户一键下载安装 - 修复选项记忆功能:浏览类型、自动截图、自动上传选项现在会保存 - 优化KDocs登录检测:未登录时自动切换到金山文档页面并显示二维码 - 简化日志输出:移除debug信息,保留用户友好的状态提示 - 新增账号变化信号:账号管理页面的修改会自动同步到浏览任务页面 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
50
main.py
50
main.py
@@ -55,32 +55,44 @@ def main():
|
||||
window = MainWindow()
|
||||
window.show()
|
||||
|
||||
# Check for JSON to SQLite migration
|
||||
# Check for JSON to SQLite migration (silent)
|
||||
from config import CONFIG_FILE
|
||||
if CONFIG_FILE.exists():
|
||||
from utils.storage import migrate_from_json
|
||||
window.log("检测到旧JSON配置,正在迁移到SQLite...")
|
||||
if migrate_from_json():
|
||||
window.log("✅ 配置迁移成功")
|
||||
else:
|
||||
window.log("⚠️ 配置迁移失败,将使用默认配置")
|
||||
migrate_from_json()
|
||||
|
||||
# 启动日志
|
||||
window.log("应用启动成功")
|
||||
window.log(f"数据目录: {os.path.abspath('data')}")
|
||||
# 简洁启动日志
|
||||
window.log("✅ 应用启动成功")
|
||||
window.log("✅ 数据加载成功")
|
||||
|
||||
# Show database info
|
||||
from utils.storage import _get_db_path
|
||||
db_path = _get_db_path()
|
||||
window.log(f"数据库: {db_path}")
|
||||
# 检查依赖(wkhtmltoimage和Playwright Chromium)
|
||||
from utils.dependency_installer import get_missing_dependencies
|
||||
missing_deps = get_missing_dependencies()
|
||||
|
||||
# 检查wkhtmltoimage
|
||||
from core.screenshot import _resolve_wkhtmltoimage_path
|
||||
wkhtml = _resolve_wkhtmltoimage_path()
|
||||
if wkhtml:
|
||||
window.log(f"wkhtmltoimage: {wkhtml}")
|
||||
# 如果有缺失的依赖,显示安装对话框
|
||||
has_missing = any(missing_deps.values())
|
||||
if has_missing:
|
||||
missing_names = []
|
||||
if missing_deps.get("wkhtmltoimage"):
|
||||
missing_names.append("wkhtmltoimage(截图功能)")
|
||||
if missing_deps.get("chromium"):
|
||||
missing_names.append("Chromium(金山文档上传)")
|
||||
window.log(f"⚠️ 缺少运行环境: {', '.join(missing_names)}")
|
||||
|
||||
# 显示安装对话框
|
||||
from ui.dependency_dialog import DependencyDialog
|
||||
dialog = DependencyDialog(missing_deps, window)
|
||||
dialog.exec()
|
||||
|
||||
# 重新检查
|
||||
missing_deps = get_missing_dependencies()
|
||||
if not missing_deps.get("wkhtmltoimage") and not missing_deps.get("chromium"):
|
||||
window.log("✅ 运行环境已就绪")
|
||||
else:
|
||||
window.log("⚠️ 警告: 未找到 wkhtmltoimage,截图功能可能不可用")
|
||||
window.log("✅ 运行环境已就绪")
|
||||
|
||||
# 启动时自动检测金山文档登录状态(后台无头模式)
|
||||
window.init_kdocs_login_check()
|
||||
|
||||
sys.exit(app.exec())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user