From 039cd06e430f42b720c8fc847b2c927ba5d6363f Mon Sep 17 00:00:00 2001 From: huangzhenpc Date: Wed, 12 Feb 2025 10:05:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0:=201.=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=20Cursor=20=E7=89=88=E6=9C=AC=E5=8F=B7=E8=AF=BB=E5=8F=96?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=202.=20=E6=9B=B4=E6=96=B0=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=88=B0=203.0.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- account_switcher.py | 12 ++++++++++++ gui/main_window.py | 13 ++++++++++++- version.txt | 2 +- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/account_switcher.py b/account_switcher.py index d81453a..ec09585 100644 --- a/account_switcher.py +++ b/account_switcher.py @@ -53,6 +53,18 @@ class AccountSwitcher: self.hardware_id = get_hardware_id() self.registry = CursorRegistry() # 添加注册表操作工具类 + def get_cursor_version(self) -> str: + """获取Cursor版本号""" + try: + if self.package_json.exists(): + with open(self.package_json, "r", encoding="utf-8") as f: + data = json.load(f) + return data.get("version", "未知") + return "未知" + except Exception as e: + logging.error(f"获取Cursor版本失败: {str(e)}") + return "未知" + def get_device_info(self) -> dict: """获取设备信息""" try: diff --git a/gui/main_window.py b/gui/main_window.py index 823ed24..d2e8d80 100644 --- a/gui/main_window.py +++ b/gui/main_window.py @@ -10,13 +10,24 @@ sys.path.append(str(Path(__file__).parent.parent)) from utils.config import Config from account_switcher import AccountSwitcher +def get_version(): + try: + version_file = Path(__file__).parent.parent / 'version.txt' + with open(version_file, 'r', encoding='utf-8') as f: + return f.read().strip() + except Exception as e: + logging.error(f"读取版本号失败: {str(e)}") + return "未知版本" + class MainWindow: def __init__(self): self.config = Config() self.switcher = AccountSwitcher() self.root = tk.Tk() - self.root.title("听泉Cursor助手 v2.2.2 (本机Cursor版本: 0.45.11)") + version = get_version() + cursor_version = self.switcher.get_cursor_version() + self.root.title(f"听泉Cursor助手 v{version} (本机Cursor版本: {cursor_version})") self.root.geometry("600x500") # 调整窗口大小 self.root.resizable(True, True) # 允许调整窗口大小 diff --git a/version.txt b/version.txt index 13d683c..d9c62ed 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -3.0.1 \ No newline at end of file +3.0.2 \ No newline at end of file