Files
yidaima_tools/main.py
王鹏 a2f5875d1b init
2026-04-09 14:55:54 +08:00

75 lines
2.1 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from __future__ import annotations
import sys
import argparse
import ctypes
import os
# 添加当前目录到 Python 路径
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
# Windows DPI 感知设置 - 必须在导入 tkinter 之前设置
if sys.platform == 'win32':
try:
# 设置 DPI 感知模式(支持 Windows 8.1 及以上)
ctypes.windll.shcore.SetProcessDpiAwareness(1) # 系统 DPI 感知
except Exception:
try:
# 兼容旧版本 Windows
ctypes.windll.user32.SetProcessDPIAware()
except Exception:
pass
from config_loader import get_config
from step1 import Step1FeastCoding
from step2 import Step2Converter
def run_business_flow(project_name: str | None = None) -> int:
"""运行完整的业务流程Step1 + Step2"""
config = get_config()
chrome_path = config.chrome_path
step1_config = config.step1_config
username = step1_config.get("username", "wangpeng")
password = step1_config.get("password", "Feastcoding@123")
try:
# Step 1
step1 = Step1FeastCoding(chrome_path, username, password)
if project_name:
step1.project_name = project_name
step1.run()
# Step 2
step2 = Step2Converter()
step2.run()
print("[INFO] 完整流程执行成功!")
return 0
except Exception as e:
print(f"[ERROR] 流程执行失败: {e}")
return 1
def main() -> int:
# 解析命令行参数
parser = argparse.ArgumentParser(description="自动化工具")
parser.add_argument("--cli", action="store_true", help="使用命令行模式(默认启动 GUI")
parser.add_argument("--project", type=str, help="设置项目名称")
args = parser.parse_args()
# 如果没有指定 --cli 参数,默认启动 GUI
if not args.cli:
from gui import main as gui_main
gui_main()
return 0
# 否则运行命令行模式
return run_business_flow(project_name=args.project)
if __name__ == "__main__":
raise SystemExit(main())