feat: 全面优化用户界面和操作流程 1.统一所有弹窗界面风格 2.优化禁用更新/突破限制/刷新授权的操作流程 3.增加复制命令按钮功能 4.改进错误提示和操作指引 5.提升整体操作流畅度

This commit is contained in:
huangzhenpc
2025-02-14 20:44:16 +08:00
parent 26e159d71c
commit ae698796e7
9 changed files with 945 additions and 509 deletions

View File

@@ -348,27 +348,103 @@ class CursorAuthManager:
# 确保进程已关闭
if not self.close_cursor_process():
logging.error("无法关闭Cursor进程")
return False
# 等待系统资源释放
time.sleep(3)
# 启动Cursor
if sys.platform == "win32":
cursor_exe = self.cursor_path / "Cursor.exe"
if cursor_exe.exists():
os.startfile(str(cursor_exe))
logging.info("Cursor启动成功")
return True
max_retries = 3
for attempt in range(max_retries):
try:
# 检查是否还有Cursor进程在运行
try:
subprocess.check_output(
"tasklist | findstr Cursor.exe",
startupinfo=subprocess.STARTUPINFO(),
shell=True
)
# 如果找到进程,等待它关闭
if attempt < max_retries - 1:
logging.info("等待进程完全关闭...")
time.sleep(3)
continue
else:
logging.error("无法确保所有Cursor进程已关闭")
return False
except subprocess.CalledProcessError:
# 没有找到进程,可以继续启动
pass
# 使用subprocess启动
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
# 使用subprocess.Popen启动并等待一段时间
process = subprocess.Popen(
str(cursor_exe),
startupinfo=startupinfo,
creationflags=subprocess.CREATE_NEW_CONSOLE
)
# 等待进程启动
time.sleep(5)
# 验证进程是否成功启动
if process.poll() is None: # 进程仍在运行
logging.info("Cursor启动成功")
return True
else:
if attempt < max_retries - 1:
logging.warning(f"启动尝试 {attempt + 1} 失败,准备重试...")
time.sleep(3)
continue
logging.error("Cursor进程启动失败")
# 尝试使用 os.startfile 作为备选方案
try:
os.startfile(str(cursor_exe))
time.sleep(5)
logging.info("使用备选方案启动Cursor")
return True
except Exception as e:
logging.error(f"备选启动方案失败: {str(e)}")
return False
except Exception as e:
if attempt < max_retries - 1:
logging.warning(f"启动尝试 {attempt + 1} 失败: {str(e)},准备重试...")
time.sleep(3)
continue
logging.error(f"启动Cursor失败: {str(e)}")
return False
else:
logging.error(f"未找到Cursor程序: {cursor_exe}")
return False
elif sys.platform == "darwin":
subprocess.run("open -a Cursor", shell=True)
logging.info("Cursor启动成功")
return True
try:
subprocess.run("open -a Cursor", shell=True, check=True)
time.sleep(5)
logging.info("Cursor启动成功")
return True
except subprocess.CalledProcessError as e:
logging.error(f"启动Cursor失败: {str(e)}")
return False
elif sys.platform == "linux":
subprocess.run("cursor &", shell=True)
logging.info("Cursor启动成功")
return True
try:
subprocess.run("cursor &", shell=True, check=True)
time.sleep(5)
logging.info("Cursor启动成功")
return True
except subprocess.CalledProcessError as e:
logging.error(f"启动Cursor失败: {str(e)}")
return False
return False
except Exception as e: