- 新增依赖检测模块:启动时自动检测wkhtmltoimage和Playwright Chromium - 新增依赖安装对话框:缺失时提示用户一键下载安装 - 修复选项记忆功能:浏览类型、自动截图、自动上传选项现在会保存 - 优化KDocs登录检测:未登录时自动切换到金山文档页面并显示二维码 - 简化日志输出:移除debug信息,保留用户友好的状态提示 - 新增账号变化信号:账号管理页面的修改会自动同步到浏览任务页面 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
102 lines
2.9 KiB
Python
102 lines
2.9 KiB
Python
#!/usr/bin/env python3
|
||
# -*- coding: utf-8 -*-
|
||
"""
|
||
知识管理平台助手 - 精简版
|
||
PyQt6桌面应用入口
|
||
|
||
功能:
|
||
- 知识管理平台浏览(登录、标记已读)
|
||
- wkhtmltoimage截图
|
||
- 金山文档表格上传
|
||
|
||
作者: 老王
|
||
"""
|
||
|
||
import sys
|
||
import os
|
||
|
||
# 确保在正确的目录
|
||
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
||
|
||
from PyQt6.QtWidgets import QApplication
|
||
from PyQt6.QtCore import Qt
|
||
from PyQt6.QtGui import QFont
|
||
|
||
from config import get_config
|
||
from ui.main_window import MainWindow
|
||
from ui.styles import get_stylesheet, LIGHT_THEME, DARK_THEME
|
||
|
||
|
||
def main():
|
||
"""应用入口"""
|
||
# 高DPI支持
|
||
if hasattr(Qt, 'AA_EnableHighDpiScaling'):
|
||
QApplication.setAttribute(Qt.ApplicationAttribute.AA_EnableHighDpiScaling, True)
|
||
if hasattr(Qt, 'AA_UseHighDpiPixmaps'):
|
||
QApplication.setAttribute(Qt.ApplicationAttribute.AA_UseHighDpiPixmaps, True)
|
||
|
||
app = QApplication(sys.argv)
|
||
|
||
# 设置应用信息
|
||
app.setApplicationName("知识管理平台助手")
|
||
app.setApplicationVersion("1.0.0")
|
||
app.setOrganizationName("zsglpt-lite")
|
||
|
||
# 设置默认字体
|
||
font = QFont("Microsoft YaHei", 10)
|
||
app.setFont(font)
|
||
|
||
# 加载配置并应用主题
|
||
config = get_config()
|
||
theme = LIGHT_THEME if config.theme == "light" else DARK_THEME
|
||
app.setStyleSheet(get_stylesheet(theme))
|
||
|
||
# 创建主窗口
|
||
window = MainWindow()
|
||
window.show()
|
||
|
||
# Check for JSON to SQLite migration (silent)
|
||
from config import CONFIG_FILE
|
||
if CONFIG_FILE.exists():
|
||
from utils.storage import migrate_from_json
|
||
migrate_from_json()
|
||
|
||
# 简洁启动日志
|
||
window.log("✅ 应用启动成功")
|
||
window.log("✅ 数据加载成功")
|
||
|
||
# 检查依赖(wkhtmltoimage和Playwright Chromium)
|
||
from utils.dependency_installer import get_missing_dependencies
|
||
missing_deps = get_missing_dependencies()
|
||
|
||
# 如果有缺失的依赖,显示安装对话框
|
||
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("✅ 运行环境已就绪")
|
||
|
||
# 启动时自动检测金山文档登录状态(后台无头模式)
|
||
window.init_kdocs_login_check()
|
||
|
||
sys.exit(app.exec())
|
||
|
||
|
||
if __name__ == "__main__":
|
||
main()
|