Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
10523de040 | ||
|
|
dd0a307ff4 | ||
|
|
b5cbf0779b | ||
|
|
d81244c7e4 | ||
|
|
e3b5820d8b | ||
|
|
4ee3ac066e | ||
|
|
30aab5f9b2 | ||
|
|
207c3c604e | ||
|
|
4e11deb530 | ||
|
|
4531f12c0d | ||
|
|
e3058b9e39 | ||
|
|
56b619c4dc | ||
|
|
c58903846d | ||
|
|
6281f86743 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -18,3 +18,5 @@ env/
|
|||||||
|
|
||||||
# Local development settings
|
# Local development settings
|
||||||
.env
|
.env
|
||||||
|
|
||||||
|
testversion.txt
|
||||||
@@ -50,9 +50,41 @@ class AccountSwitcher:
|
|||||||
self.package_json = self.app_path / "package.json"
|
self.package_json = self.app_path / "package.json"
|
||||||
self.auth_manager = CursorAuthManager()
|
self.auth_manager = CursorAuthManager()
|
||||||
self.config = Config()
|
self.config = Config()
|
||||||
self.hardware_id = get_hardware_id()
|
self.hardware_id = self.get_hardware_id() # 先获取硬件ID
|
||||||
self.registry = CursorRegistry() # 添加注册表操作工具类
|
self.registry = CursorRegistry() # 添加注册表操作工具类
|
||||||
|
|
||||||
|
logging.info(f"初始化硬件ID: {self.hardware_id}")
|
||||||
|
|
||||||
|
def get_hardware_id(self) -> str:
|
||||||
|
"""获取硬件唯一标识"""
|
||||||
|
try:
|
||||||
|
# 创建startupinfo对象来隐藏命令行窗口
|
||||||
|
startupinfo = None
|
||||||
|
if sys.platform == "win32":
|
||||||
|
startupinfo = subprocess.STARTUPINFO()
|
||||||
|
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||||
|
startupinfo.wShowWindow = subprocess.SW_HIDE
|
||||||
|
|
||||||
|
# 获取CPU信息
|
||||||
|
cpu_info = subprocess.check_output('wmic cpu get ProcessorId', startupinfo=startupinfo).decode()
|
||||||
|
cpu_id = cpu_info.split('\n')[1].strip()
|
||||||
|
|
||||||
|
# 获取主板序列号
|
||||||
|
board_info = subprocess.check_output('wmic baseboard get SerialNumber', startupinfo=startupinfo).decode()
|
||||||
|
board_id = board_info.split('\n')[1].strip()
|
||||||
|
|
||||||
|
# 获取BIOS序列号
|
||||||
|
bios_info = subprocess.check_output('wmic bios get SerialNumber', startupinfo=startupinfo).decode()
|
||||||
|
bios_id = bios_info.split('\n')[1].strip()
|
||||||
|
|
||||||
|
# 组合信息并生成哈希
|
||||||
|
combined = f"{cpu_id}:{board_id}:{bios_id}"
|
||||||
|
return hashlib.md5(combined.encode()).hexdigest()
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f"获取硬件ID失败: {str(e)}")
|
||||||
|
# 如果获取失败,使用UUID作为备选方案
|
||||||
|
return str(uuid.uuid4())
|
||||||
|
|
||||||
def get_cursor_version(self) -> str:
|
def get_cursor_version(self) -> str:
|
||||||
"""获取Cursor版本号"""
|
"""获取Cursor版本号"""
|
||||||
try:
|
try:
|
||||||
@@ -71,198 +103,154 @@ class AccountSwitcher:
|
|||||||
import platform
|
import platform
|
||||||
import socket
|
import socket
|
||||||
import requests
|
import requests
|
||||||
|
import subprocess
|
||||||
|
|
||||||
# 获取操作系统信息
|
# 获取操作系统信息
|
||||||
os_info = f"{platform.system()} {platform.version()}"
|
os_info = f"{platform.system()} {platform.release()}"
|
||||||
|
|
||||||
# 获取设备名称
|
# 获取设备名称
|
||||||
device_name = platform.node()
|
|
||||||
|
|
||||||
# 获取地理位置(可选)
|
|
||||||
try:
|
try:
|
||||||
ip_info = requests.get('https://ipapi.co/json/', timeout=5).json()
|
# 在Windows上使用wmic获取更详细的计算机名称
|
||||||
|
if platform.system() == "Windows":
|
||||||
|
startupinfo = subprocess.STARTUPINFO()
|
||||||
|
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||||
|
computer_info = subprocess.check_output('wmic computersystem get model', startupinfo=startupinfo).decode()
|
||||||
|
device_name = computer_info.split('\n')[1].strip()
|
||||||
|
else:
|
||||||
|
device_name = platform.node()
|
||||||
|
except:
|
||||||
|
device_name = platform.node()
|
||||||
|
|
||||||
|
# 获取IP地址
|
||||||
|
try:
|
||||||
|
ip_response = requests.get('https://api.ipify.org?format=json', timeout=5)
|
||||||
|
ip_address = ip_response.json()['ip']
|
||||||
|
except:
|
||||||
|
ip_address = "未知"
|
||||||
|
|
||||||
|
# 获取地理位置
|
||||||
|
try:
|
||||||
|
ip_info = requests.get(f'https://ipapi.co/{ip_address}/json/', timeout=5).json()
|
||||||
location = f"{ip_info.get('country_name', '')}-{ip_info.get('region', '')}-{ip_info.get('city', '')}"
|
location = f"{ip_info.get('country_name', '')}-{ip_info.get('region', '')}-{ip_info.get('city', '')}"
|
||||||
except:
|
except:
|
||||||
location = ""
|
location = "未知"
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"os": os_info,
|
"os": os_info,
|
||||||
"device_name": device_name,
|
"device_name": device_name,
|
||||||
|
"ip": ip_address,
|
||||||
"location": location
|
"location": location
|
||||||
}
|
}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"获取设备信息失败: {str(e)}")
|
logging.error(f"获取设备信息失败: {str(e)}")
|
||||||
return {
|
return {
|
||||||
"os": "Windows 10",
|
"os": "Windows",
|
||||||
"device_name": "未知设备",
|
"device_name": "未知设备",
|
||||||
"location": ""
|
"ip": "未知",
|
||||||
|
"location": "未知"
|
||||||
}
|
}
|
||||||
|
|
||||||
def check_activation_code(self, code: str) -> Tuple[bool, str, Optional[Dict]]:
|
def check_activation_code(self, code: str) -> tuple:
|
||||||
"""验证激活码
|
"""检查激活码
|
||||||
|
|
||||||
|
Args:
|
||||||
|
code: 激活码
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Tuple[bool, str, Optional[Dict]]: (是否成功, 提示消息, 账号信息)
|
tuple: (成功标志, 消息, 账号信息)
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
# 获取当前状态
|
data = {
|
||||||
member_info = self.config.load_member_info()
|
"machine_id": self.hardware_id,
|
||||||
|
"code": code
|
||||||
|
}
|
||||||
|
|
||||||
# 分割多个激活码
|
# 禁用SSL警告
|
||||||
codes = [c.strip() for c in code.split(',')]
|
import urllib3
|
||||||
success_codes = []
|
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||||
failed_codes = []
|
|
||||||
activation_results = []
|
|
||||||
|
|
||||||
# 获取设备信息
|
# 设置请求参数
|
||||||
device_info = self.get_device_info()
|
request_kwargs = {
|
||||||
|
"json": data,
|
||||||
# 逐个验证激活码
|
"headers": {"Content-Type": "application/json"},
|
||||||
for single_code in codes:
|
"timeout": 5, # 减少超时时间从10秒到5秒
|
||||||
if not single_code:
|
"verify": False # 禁用SSL验证
|
||||||
continue
|
}
|
||||||
|
|
||||||
# 验证激活码
|
|
||||||
endpoint = "https://cursorapi.nosqli.com/admin/api.member/activate"
|
|
||||||
data = {
|
|
||||||
"code": single_code,
|
|
||||||
"machine_id": self.hardware_id,
|
|
||||||
"os": device_info["os"],
|
|
||||||
"device_name": device_info["device_name"],
|
|
||||||
"location": device_info["location"]
|
|
||||||
}
|
|
||||||
|
|
||||||
headers = {
|
|
||||||
"Content-Type": "application/json"
|
|
||||||
}
|
|
||||||
|
|
||||||
try:
|
|
||||||
response = requests.post(
|
|
||||||
endpoint,
|
|
||||||
json=data,
|
|
||||||
headers=headers,
|
|
||||||
timeout=10
|
|
||||||
)
|
|
||||||
|
|
||||||
response_data = response.json()
|
|
||||||
if response_data.get("code") == 200:
|
|
||||||
result_data = response_data.get("data", {})
|
|
||||||
logging.info(f"激活码 {single_code} 验证成功: {response_data.get('msg', '')}")
|
|
||||||
activation_results.append(result_data)
|
|
||||||
success_codes.append(single_code)
|
|
||||||
elif response_data.get("code") == 400:
|
|
||||||
error_msg = response_data.get("msg", "参数错误")
|
|
||||||
if "已被使用" in error_msg or "已激活" in error_msg:
|
|
||||||
logging.warning(f"激活码 {single_code} 已被使用")
|
|
||||||
failed_codes.append(f"{single_code} (已被使用)")
|
|
||||||
else:
|
|
||||||
logging.error(f"激活码 {single_code} 验证失败: {error_msg}")
|
|
||||||
failed_codes.append(f"{single_code} ({error_msg})")
|
|
||||||
elif response_data.get("code") == 500:
|
|
||||||
error_msg = response_data.get("msg", "系统错误")
|
|
||||||
logging.error(f"激活码 {single_code} 验证失败: {error_msg}")
|
|
||||||
failed_codes.append(f"{single_code} ({error_msg})")
|
|
||||||
else:
|
|
||||||
error_msg = response_data.get("msg", "未知错误")
|
|
||||||
logging.error(f"激活码 {single_code} 验证失败: {error_msg}")
|
|
||||||
failed_codes.append(f"{single_code} ({error_msg})")
|
|
||||||
|
|
||||||
except requests.RequestException as e:
|
|
||||||
logging.error(f"激活码 {single_code} 请求失败: {str(e)}")
|
|
||||||
failed_codes.append(f"{single_code} (网络请求失败)")
|
|
||||||
except Exception as e:
|
|
||||||
logging.error(f"激活码 {single_code} 处理失败: {str(e)}")
|
|
||||||
failed_codes.append(f"{single_code} (处理失败)")
|
|
||||||
|
|
||||||
if not success_codes:
|
|
||||||
failed_msg = "\n".join(failed_codes)
|
|
||||||
return False, f"激活失败:\n{failed_msg}", None
|
|
||||||
|
|
||||||
|
# 尝试发送请求
|
||||||
try:
|
try:
|
||||||
# 使用最后一次激活的结果作为最终状态
|
response = requests.post(
|
||||||
final_result = activation_results[-1]
|
self.config.get_api_url("activate"),
|
||||||
|
**request_kwargs
|
||||||
|
)
|
||||||
|
except requests.exceptions.SSLError:
|
||||||
|
# 如果发生SSL错误,创建自定义SSL上下文
|
||||||
|
import ssl
|
||||||
|
ssl_context = ssl.create_default_context()
|
||||||
|
ssl_context.check_hostname = False
|
||||||
|
ssl_context.verify_mode = ssl.CERT_NONE
|
||||||
|
|
||||||
# 保存会员信息
|
# 使用自定义SSL上下文重试请求
|
||||||
member_info = {
|
session = requests.Session()
|
||||||
"hardware_id": final_result.get("machine_id", self.hardware_id),
|
session.verify = False
|
||||||
"expire_time": final_result.get("expire_time", ""),
|
response = session.post(
|
||||||
"days_left": final_result.get("days_left", 0), # 使用days_left
|
self.config.get_api_url("activate"),
|
||||||
"total_days": final_result.get("total_days", 0), # 使用total_days
|
**request_kwargs
|
||||||
"status": final_result.get("status", "inactive"),
|
)
|
||||||
"device_info": final_result.get("device_info", device_info),
|
|
||||||
"activation_time": final_result.get("activation_time", ""),
|
result = response.json()
|
||||||
"activation_records": final_result.get("activation_records", []) # 保存激活记录
|
# 激活成功
|
||||||
|
if result["code"] == 200:
|
||||||
|
api_data = result["data"]
|
||||||
|
# 构造标准的返回数据结构
|
||||||
|
account_info = {
|
||||||
|
"status": "active",
|
||||||
|
"expire_time": api_data.get("expire_time", ""),
|
||||||
|
"total_days": api_data.get("total_days", 0),
|
||||||
|
"days_left": api_data.get("days_left", 0),
|
||||||
|
"device_info": self.get_device_info()
|
||||||
}
|
}
|
||||||
self.config.save_member_info(member_info)
|
return True, result["msg"], account_info
|
||||||
|
# 激活码无效或已被使用
|
||||||
# 生成结果消息
|
elif result["code"] == 400:
|
||||||
message = f"激活成功\n"
|
logging.warning(f"激活码无效或已被使用: {result.get('msg', '未知错误')}")
|
||||||
|
return False, result.get("msg", "激活码无效或已被使用"), None
|
||||||
# 显示每个成功激活码的信息
|
# 其他错误情况
|
||||||
for i, result in enumerate(activation_results, 1):
|
else:
|
||||||
message += f"\n第{i}个激活码:\n"
|
logging.error(f"激活失败: {result.get('msg', '未知错误')}")
|
||||||
message += f"- 新增天数: {result.get('added_days', 0)}天\n" # 使用added_days显示本次新增天数
|
return False, result["msg"], None # 返回 None 而不是空的账号信息
|
||||||
# 格式化时间显示
|
|
||||||
activation_time = result.get('activation_time', '')
|
|
||||||
if activation_time:
|
|
||||||
try:
|
|
||||||
from datetime import datetime
|
|
||||||
dt = datetime.strptime(activation_time, "%Y-%m-%d %H:%M:%S")
|
|
||||||
activation_time = dt.strftime("%Y-%m-%d %H:%M:%S")
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
message += f"- 激活时间: {activation_time}\n"
|
|
||||||
|
|
||||||
message += f"\n最终状态:"
|
|
||||||
message += f"\n- 总天数: {final_result.get('total_days', 0)}天" # 累计总天数
|
|
||||||
message += f"\n- 剩余天数: {final_result.get('days_left', 0)}天" # 剩余天数
|
|
||||||
|
|
||||||
# 格式化到期时间显示
|
|
||||||
expire_time = final_result.get('expire_time', '')
|
|
||||||
if expire_time:
|
|
||||||
try:
|
|
||||||
dt = datetime.strptime(expire_time, "%Y-%m-%d %H:%M:%S")
|
|
||||||
expire_time = dt.strftime("%Y-%m-%d %H:%M:%S")
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
message += f"\n- 到期时间: {expire_time}"
|
|
||||||
|
|
||||||
# 显示激活记录历史
|
|
||||||
message += "\n\n历史激活记录:"
|
|
||||||
for record in final_result.get('activation_records', []):
|
|
||||||
activation_time = record.get('activation_time', '')
|
|
||||||
if activation_time:
|
|
||||||
try:
|
|
||||||
dt = datetime.strptime(activation_time, "%Y-%m-%d %H:%M:%S")
|
|
||||||
activation_time = dt.strftime("%Y-%m-%d %H:%M:%S")
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
message += f"\n- 激活码: {record.get('code', '')}"
|
|
||||||
message += f"\n 天数: {record.get('days', 0)}天"
|
|
||||||
message += f"\n 时间: {activation_time}\n"
|
|
||||||
|
|
||||||
if failed_codes:
|
|
||||||
message += f"\n\n以下激活码验证失败:\n" + "\n".join(failed_codes)
|
|
||||||
|
|
||||||
return True, message, member_info
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
logging.error(f"处理激活结果时出错: {str(e)}")
|
|
||||||
return False, f"处理激活结果失败: {str(e)}", None
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"激活码验证过程出错: {str(e)}")
|
logging.error(f"激活失败: {str(e)}")
|
||||||
return False, f"激活失败: {str(e)}", None
|
return False, f"激活失败: {str(e)}", None # 返回 None 而不是空的账号信息
|
||||||
|
|
||||||
def reset_machine_id(self) -> bool:
|
def reset_machine_id(self) -> bool:
|
||||||
"""重置机器码"""
|
"""重置机器码"""
|
||||||
try:
|
try:
|
||||||
# 1. 先关闭所有Cursor进程
|
# 1. 先关闭所有Cursor进程
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
os.system("taskkill /f /im Cursor.exe >nul 2>&1")
|
# 创建startupinfo对象来隐藏命令行窗口
|
||||||
|
startupinfo = subprocess.STARTUPINFO()
|
||||||
|
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||||
|
startupinfo.wShowWindow = subprocess.SW_HIDE
|
||||||
|
|
||||||
|
# 使用subprocess.run来执行命令,并隐藏窗口
|
||||||
|
subprocess.run(
|
||||||
|
"taskkill /f /im Cursor.exe >nul 2>&1",
|
||||||
|
startupinfo=startupinfo,
|
||||||
|
shell=True
|
||||||
|
)
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
# 2. 删除 package.json 中的 machineId
|
# 2. 清理注册表(包括更新系统 MachineGuid)
|
||||||
|
if not self.registry.clean_registry():
|
||||||
|
logging.warning("注册表清理失败")
|
||||||
|
|
||||||
|
# 3. 清理文件(包括备份 storage.json)
|
||||||
|
if not self.registry.clean_cursor_files():
|
||||||
|
logging.warning("文件清理失败")
|
||||||
|
|
||||||
|
# 4. 修改 package.json 中的 machineId
|
||||||
if self.package_json.exists():
|
if self.package_json.exists():
|
||||||
with open(self.package_json, "r", encoding="utf-8") as f:
|
with open(self.package_json, "r", encoding="utf-8") as f:
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
@@ -273,67 +261,20 @@ class AccountSwitcher:
|
|||||||
with open(self.package_json, "w", encoding="utf-8") as f:
|
with open(self.package_json, "w", encoding="utf-8") as f:
|
||||||
json.dump(data, f, indent=2)
|
json.dump(data, f, indent=2)
|
||||||
|
|
||||||
# 3. 清理特定的配置文件和缓存
|
# 5. 修改 storage.json 中的遥测 ID
|
||||||
local_app_data = Path(os.getenv('LOCALAPPDATA'))
|
storage_path = Path(os.getenv('APPDATA')) / "Cursor" / "User" / "globalStorage" / "storage.json"
|
||||||
cursor_path = local_app_data / "Cursor"
|
if storage_path.exists():
|
||||||
|
with open(storage_path, "r", encoding="utf-8") as f:
|
||||||
|
storage_data = json.load(f)
|
||||||
|
|
||||||
# 需要清理的目录
|
# 只修改 machineId,保持其他遥测 ID 不变
|
||||||
cache_dirs = [
|
if "telemetry.machineId" in storage_data:
|
||||||
cursor_path / "Cache",
|
# 生成新的 machineId(使用与 GitHub 脚本类似的格式)
|
||||||
cursor_path / "Code Cache",
|
new_machine_id = hashlib.sha256(str(uuid.uuid4()).encode()).hexdigest()
|
||||||
cursor_path / "GPUCache",
|
storage_data["telemetry.machineId"] = new_machine_id
|
||||||
cursor_path / "Local Storage" / "leveldb"
|
|
||||||
]
|
|
||||||
|
|
||||||
# 需要删除的配置文件
|
with open(storage_path, "w", encoding="utf-8") as f:
|
||||||
config_files = [
|
json.dump(storage_data, f, indent=2)
|
||||||
cursor_path / "User" / "globalStorage" / "storage.json",
|
|
||||||
cursor_path / "User" / "globalStorage" / "state.json",
|
|
||||||
self.app_path / "config.json",
|
|
||||||
self.app_path / "state.json",
|
|
||||||
self.app_path / "settings.json"
|
|
||||||
]
|
|
||||||
|
|
||||||
# 清理缓存目录
|
|
||||||
for dir_path in cache_dirs:
|
|
||||||
if dir_path.exists():
|
|
||||||
try:
|
|
||||||
import shutil
|
|
||||||
shutil.rmtree(str(dir_path))
|
|
||||||
logging.info(f"清理目录成功: {dir_path}")
|
|
||||||
except Exception as e:
|
|
||||||
logging.warning(f"清理目录失败: {dir_path}, 错误: {str(e)}")
|
|
||||||
|
|
||||||
# 删除配置文件
|
|
||||||
for file_path in config_files:
|
|
||||||
if file_path.exists():
|
|
||||||
try:
|
|
||||||
os.remove(file_path)
|
|
||||||
logging.info(f"删除配置文件成功: {file_path}")
|
|
||||||
except Exception as e:
|
|
||||||
logging.warning(f"删除配置文件失败: {file_path}, 错误: {str(e)}")
|
|
||||||
|
|
||||||
# 4. 刷新注册表
|
|
||||||
if not self.registry.refresh_registry():
|
|
||||||
logging.warning("注册表刷新失败")
|
|
||||||
|
|
||||||
# 5. 删除卸载注册表项
|
|
||||||
try:
|
|
||||||
import winreg
|
|
||||||
with winreg.OpenKey(winreg.HKEY_CURRENT_USER, r"Software\Microsoft\Windows\CurrentVersion\Uninstall", 0, winreg.KEY_ALL_ACCESS) as key:
|
|
||||||
# 遍历所有子键,找到Cursor相关的
|
|
||||||
i = 0
|
|
||||||
while True:
|
|
||||||
try:
|
|
||||||
subkey_name = winreg.EnumKey(key, i)
|
|
||||||
if "Cursor" in subkey_name:
|
|
||||||
winreg.DeleteKey(key, subkey_name)
|
|
||||||
logging.info(f"删除注册表项成功: {subkey_name}")
|
|
||||||
i += 1
|
|
||||||
except WindowsError:
|
|
||||||
break
|
|
||||||
except Exception as e:
|
|
||||||
logging.warning(f"删除注册表项失败: {str(e)}")
|
|
||||||
|
|
||||||
# 6. 重启Cursor
|
# 6. 重启Cursor
|
||||||
cursor_exe = self.cursor_path / "Cursor.exe"
|
cursor_exe = self.cursor_path / "Cursor.exe"
|
||||||
@@ -353,7 +294,17 @@ class AccountSwitcher:
|
|||||||
try:
|
try:
|
||||||
# 1. 先关闭所有Cursor进程
|
# 1. 先关闭所有Cursor进程
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
os.system("taskkill /f /im Cursor.exe >nul 2>&1")
|
# 创建startupinfo对象来隐藏命令行窗口
|
||||||
|
startupinfo = subprocess.STARTUPINFO()
|
||||||
|
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||||
|
startupinfo.wShowWindow = subprocess.SW_HIDE
|
||||||
|
|
||||||
|
# 关闭Cursor
|
||||||
|
subprocess.run(
|
||||||
|
"taskkill /f /im Cursor.exe >nul 2>&1",
|
||||||
|
startupinfo=startupinfo,
|
||||||
|
shell=True
|
||||||
|
)
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
# 2. 重置机器码
|
# 2. 重置机器码
|
||||||
@@ -384,93 +335,86 @@ class AccountSwitcher:
|
|||||||
logging.error(f"激活过程出错: {str(e)}")
|
logging.error(f"激活过程出错: {str(e)}")
|
||||||
return False, f"激活失败: {str(e)}"
|
return False, f"激活失败: {str(e)}"
|
||||||
|
|
||||||
def get_member_status(self) -> Optional[Dict]:
|
def get_member_status(self) -> dict:
|
||||||
"""获取会员状态
|
"""获取会员状态
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Optional[Dict]: 会员状态信息
|
dict: 会员状态信息,包含:
|
||||||
|
- status: 状态(active/inactive/expired)
|
||||||
|
- expire_time: 到期时间
|
||||||
|
- total_days: 总天数
|
||||||
|
- days_left: 剩余天数
|
||||||
|
- device_info: 设备信息
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
# 读取保存的会员信息
|
|
||||||
member_info = self.config.load_member_info()
|
|
||||||
|
|
||||||
# 构造状态检查请求
|
|
||||||
endpoint = "https://cursorapi.nosqli.com/admin/api.member/status"
|
|
||||||
data = {
|
data = {
|
||||||
"machine_id": self.hardware_id
|
"machine_id": self.hardware_id
|
||||||
}
|
}
|
||||||
headers = {
|
|
||||||
"Content-Type": "application/json"
|
api_url = self.config.get_api_url("status")
|
||||||
|
logging.info(f"正在检查会员状态...")
|
||||||
|
|
||||||
|
# 设置请求参数
|
||||||
|
request_kwargs = {
|
||||||
|
"json": data,
|
||||||
|
"headers": {"Content-Type": "application/json"},
|
||||||
|
"timeout": 2, # 减少超时时间到2秒
|
||||||
|
"verify": False
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 使用session来复用连接
|
||||||
|
session = requests.Session()
|
||||||
|
session.verify = False
|
||||||
|
|
||||||
|
# 尝试发送请求
|
||||||
try:
|
try:
|
||||||
response = requests.post(endpoint, json=data, headers=headers, timeout=10)
|
response = session.post(api_url, **request_kwargs)
|
||||||
response_data = response.json()
|
except requests.exceptions.Timeout:
|
||||||
|
# 超时后快速重试一次
|
||||||
|
logging.warning("首次请求超时,正在重试...")
|
||||||
|
response = session.post(api_url, **request_kwargs)
|
||||||
|
|
||||||
if response_data.get("code") == 200:
|
result = response.json()
|
||||||
# 正常状态
|
logging.info(f"状态检查响应: {result}")
|
||||||
data = response_data.get("data", {})
|
|
||||||
status = data.get("status", "inactive")
|
|
||||||
|
|
||||||
# 构造会员信息
|
if result.get("code") in [1, 200]:
|
||||||
member_info = {
|
api_data = result.get("data", {})
|
||||||
"hardware_id": data.get("machine_id", self.hardware_id),
|
return {
|
||||||
"expire_time": data.get("expire_time", ""),
|
"status": api_data.get("status", "inactive"),
|
||||||
"days_left": data.get("days_left", 0), # 使用days_left
|
"expire_time": api_data.get("expire_time", ""),
|
||||||
"total_days": data.get("total_days", 0), # 使用total_days
|
"total_days": api_data.get("total_days", 0),
|
||||||
"status": status,
|
"days_left": api_data.get("days_left", 0),
|
||||||
"activation_records": data.get("activation_records", []) # 保存激活记录
|
"device_info": self.get_device_info()
|
||||||
}
|
}
|
||||||
|
else:
|
||||||
# 打印调试信息
|
error_msg = result.get("msg", "未知错误")
|
||||||
logging.info(f"API返回数据: {data}")
|
logging.error(f"获取状态失败: {error_msg}")
|
||||||
logging.info(f"处理后的会员信息: {member_info}")
|
return {
|
||||||
|
"status": "inactive",
|
||||||
self.config.save_member_info(member_info)
|
"expire_time": "",
|
||||||
return member_info
|
"total_days": 0,
|
||||||
|
"days_left": 0,
|
||||||
elif response_data.get("code") == 401:
|
"device_info": self.get_device_info()
|
||||||
# 未激活或已过期
|
}
|
||||||
logging.warning("会员未激活或已过期")
|
|
||||||
return self._get_inactive_status()
|
|
||||||
|
|
||||||
elif response_data.get("code") == 400:
|
|
||||||
# 参数错误
|
|
||||||
error_msg = response_data.get("msg", "参数错误")
|
|
||||||
logging.error(f"获取会员状态失败: {error_msg}")
|
|
||||||
return self._get_inactive_status()
|
|
||||||
|
|
||||||
elif response_data.get("code") == 500:
|
|
||||||
# 系统错误
|
|
||||||
error_msg = response_data.get("msg", "系统错误")
|
|
||||||
logging.error(f"获取会员状态失败: {error_msg}")
|
|
||||||
return self._get_inactive_status()
|
|
||||||
|
|
||||||
else:
|
|
||||||
# 其他未知错误
|
|
||||||
error_msg = response_data.get("msg", "未知错误")
|
|
||||||
logging.error(f"获取会员状态失败: {error_msg}")
|
|
||||||
return self._get_inactive_status()
|
|
||||||
|
|
||||||
except requests.RequestException as e:
|
|
||||||
logging.error(f"请求会员状态失败: {str(e)}")
|
|
||||||
return self._get_inactive_status()
|
|
||||||
|
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
logging.error(f"API请求失败: {str(e)}")
|
||||||
|
return {
|
||||||
|
"status": "inactive",
|
||||||
|
"expire_time": "",
|
||||||
|
"total_days": 0,
|
||||||
|
"days_left": 0,
|
||||||
|
"device_info": self.get_device_info()
|
||||||
|
}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"获取会员状态出错: {str(e)}")
|
logging.error(f"获取会员状态失败: {str(e)}")
|
||||||
return self._get_inactive_status()
|
return {
|
||||||
|
"status": "inactive",
|
||||||
def _get_inactive_status(self) -> Dict:
|
"expire_time": "",
|
||||||
"""获取未激活状态的默认信息"""
|
"total_days": 0,
|
||||||
return {
|
"days_left": 0,
|
||||||
"hardware_id": self.hardware_id,
|
"device_info": self.get_device_info()
|
||||||
"expire_time": "",
|
}
|
||||||
"days": 0,
|
|
||||||
"total_days": 0,
|
|
||||||
"status": "inactive",
|
|
||||||
"last_activation": {},
|
|
||||||
"activation_records": []
|
|
||||||
}
|
|
||||||
|
|
||||||
def restart_cursor(self) -> bool:
|
def restart_cursor(self) -> bool:
|
||||||
"""重启Cursor编辑器
|
"""重启Cursor编辑器
|
||||||
@@ -482,9 +426,19 @@ class AccountSwitcher:
|
|||||||
logging.info("正在重启Cursor...")
|
logging.info("正在重启Cursor...")
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
# Windows系统
|
# Windows系统
|
||||||
|
# 创建startupinfo对象来隐藏命令行窗口
|
||||||
|
startupinfo = subprocess.STARTUPINFO()
|
||||||
|
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||||
|
startupinfo.wShowWindow = subprocess.SW_HIDE
|
||||||
|
|
||||||
# 关闭Cursor
|
# 关闭Cursor
|
||||||
os.system("taskkill /f /im Cursor.exe 2>nul")
|
subprocess.run(
|
||||||
|
"taskkill /f /im Cursor.exe 2>nul",
|
||||||
|
startupinfo=startupinfo,
|
||||||
|
shell=True
|
||||||
|
)
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
# 获取Cursor安装路径
|
# 获取Cursor安装路径
|
||||||
cursor_exe = self.cursor_path / "Cursor.exe"
|
cursor_exe = self.cursor_path / "Cursor.exe"
|
||||||
if cursor_exe.exists():
|
if cursor_exe.exists():
|
||||||
@@ -497,16 +451,16 @@ class AccountSwitcher:
|
|||||||
return False
|
return False
|
||||||
elif sys.platform == "darwin":
|
elif sys.platform == "darwin":
|
||||||
# macOS系统
|
# macOS系统
|
||||||
os.system("killall Cursor 2>/dev/null")
|
subprocess.run("killall Cursor 2>/dev/null", shell=True)
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
os.system("open -a Cursor")
|
subprocess.run("open -a Cursor", shell=True)
|
||||||
logging.info("Cursor重启成功")
|
logging.info("Cursor重启成功")
|
||||||
return True
|
return True
|
||||||
elif sys.platform == "linux":
|
elif sys.platform == "linux":
|
||||||
# Linux系统
|
# Linux系统
|
||||||
os.system("pkill -f cursor")
|
subprocess.run("pkill -f cursor", shell=True)
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
os.system("cursor &")
|
subprocess.run("cursor &", shell=True)
|
||||||
logging.info("Cursor重启成功")
|
logging.info("Cursor重启成功")
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
@@ -523,7 +477,7 @@ class AccountSwitcher:
|
|||||||
Tuple[bool, str]: (是否成功, 提示消息)
|
Tuple[bool, str]: (是否成功, 提示消息)
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
# 获取未使用的账号
|
# 1. 获取未使用的账号
|
||||||
endpoint = "https://cursorapi.nosqli.com/admin/api.account/getUnused"
|
endpoint = "https://cursorapi.nosqli.com/admin/api.account/getUnused"
|
||||||
data = {
|
data = {
|
||||||
"machine_id": self.hardware_id
|
"machine_id": self.hardware_id
|
||||||
@@ -532,17 +486,33 @@ class AccountSwitcher:
|
|||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 禁用SSL警告
|
||||||
|
import urllib3
|
||||||
|
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||||
|
|
||||||
|
# 设置请求参数
|
||||||
|
request_kwargs = {
|
||||||
|
"json": data,
|
||||||
|
"headers": headers,
|
||||||
|
"timeout": 30, # 增加超时时间
|
||||||
|
"verify": False # 禁用SSL验证
|
||||||
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# 添加SSL验证选项和超时设置
|
# 尝试发送请求
|
||||||
response = requests.post(
|
try:
|
||||||
endpoint,
|
response = requests.post(endpoint, **request_kwargs)
|
||||||
json=data,
|
except requests.exceptions.SSLError:
|
||||||
headers=headers,
|
# 如果发生SSL错误,创建自定义SSL上下文
|
||||||
timeout=30, # 增加超时时间
|
import ssl
|
||||||
verify=False, # 禁用SSL验证
|
ssl_context = ssl.create_default_context()
|
||||||
)
|
ssl_context.check_hostname = False
|
||||||
# 禁用SSL警告
|
ssl_context.verify_mode = ssl.CERT_NONE
|
||||||
requests.packages.urllib3.disable_warnings()
|
|
||||||
|
# 使用自定义SSL上下文重试请求
|
||||||
|
session = requests.Session()
|
||||||
|
session.verify = False
|
||||||
|
response = session.post(endpoint, **request_kwargs)
|
||||||
|
|
||||||
response_data = response.json()
|
response_data = response.json()
|
||||||
|
|
||||||
@@ -559,26 +529,29 @@ class AccountSwitcher:
|
|||||||
if not all([email, access_token, refresh_token]):
|
if not all([email, access_token, refresh_token]):
|
||||||
return False, "获取账号信息不完整"
|
return False, "获取账号信息不完整"
|
||||||
|
|
||||||
# 更新Cursor认证信息
|
# 2. 先关闭Cursor进程
|
||||||
|
if sys.platform == "win32":
|
||||||
|
# 创建startupinfo对象来隐藏命令行窗口
|
||||||
|
startupinfo = subprocess.STARTUPINFO()
|
||||||
|
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||||
|
startupinfo.wShowWindow = subprocess.SW_HIDE
|
||||||
|
|
||||||
|
# 使用subprocess.run来执行命令,并隐藏窗口
|
||||||
|
subprocess.run(
|
||||||
|
"taskkill /f /im Cursor.exe >nul 2>&1",
|
||||||
|
startupinfo=startupinfo,
|
||||||
|
shell=True
|
||||||
|
)
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
|
# 3. 更新Cursor认证信息
|
||||||
if not self.auth_manager.update_auth(email, access_token, refresh_token):
|
if not self.auth_manager.update_auth(email, access_token, refresh_token):
|
||||||
return False, "更新Cursor认证信息失败"
|
return False, "更新Cursor认证信息失败"
|
||||||
|
|
||||||
# 重置机器码
|
# 4. 重置机器码(使用现有的reset_machine_id方法)
|
||||||
if not self.reset_machine_id():
|
if not self.reset_machine_id():
|
||||||
return False, "重置机器码失败"
|
return False, "重置机器码失败"
|
||||||
|
|
||||||
# 刷新注册表
|
|
||||||
if not self.registry.refresh_registry():
|
|
||||||
logging.warning("注册表刷新失败,但不影响主要功能")
|
|
||||||
|
|
||||||
# 重启Cursor
|
|
||||||
if not self.auth_manager.restart_cursor():
|
|
||||||
return False, "重启Cursor失败"
|
|
||||||
# 重启Cursor
|
|
||||||
# if not self.restart_cursor():
|
|
||||||
# logging.warning("Cursor重启失败,请手动重启")
|
|
||||||
# return True, f"授权刷新成功,请手动重启Cursor编辑器\n邮箱: {email}\n到期时间: {expire_time}\n剩余天数: {days_left}天"
|
|
||||||
|
|
||||||
return True, f"授权刷新成功,Cursor编辑器已重启\n邮箱: {email}\n"
|
return True, f"授权刷新成功,Cursor编辑器已重启\n邮箱: {email}\n"
|
||||||
|
|
||||||
elif response_data.get("code") == 404:
|
elif response_data.get("code") == 404:
|
||||||
@@ -613,7 +586,17 @@ class AccountSwitcher:
|
|||||||
try:
|
try:
|
||||||
# 1. 先关闭所有Cursor进程
|
# 1. 先关闭所有Cursor进程
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
os.system("taskkill /f /im Cursor.exe >nul 2>&1")
|
# 创建startupinfo对象来隐藏命令行窗口
|
||||||
|
startupinfo = subprocess.STARTUPINFO()
|
||||||
|
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||||
|
startupinfo.wShowWindow = subprocess.SW_HIDE
|
||||||
|
|
||||||
|
# 关闭Cursor
|
||||||
|
subprocess.run(
|
||||||
|
"taskkill /f /im Cursor.exe >nul 2>&1",
|
||||||
|
startupinfo=startupinfo,
|
||||||
|
shell=True
|
||||||
|
)
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
# 2. 删除updater目录并创建同名文件以阻止更新
|
# 2. 删除updater目录并创建同名文件以阻止更新
|
||||||
|
|||||||
BIN
banbenjietu.png
Normal file
BIN
banbenjietu.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 56 KiB |
53
build.bat
53
build.bat
@@ -5,8 +5,61 @@ echo 开始打包流程...
|
|||||||
:: 更新版本号
|
:: 更新版本号
|
||||||
python update_version.py
|
python update_version.py
|
||||||
|
|
||||||
|
:: 读取版本号
|
||||||
|
set /p VERSION=<version.txt
|
||||||
|
echo 当前版本: %VERSION%
|
||||||
|
|
||||||
|
:: 提取主版本号和次版本号 (3.4.4 -> 3.4)
|
||||||
|
for /f "tokens=1,2 delims=." %%a in ("%VERSION%") do (
|
||||||
|
set MAJOR_VERSION=%%a.%%b
|
||||||
|
)
|
||||||
|
echo 主版本目录: %MAJOR_VERSION%
|
||||||
|
|
||||||
|
:: 创建版本目录
|
||||||
|
set VERSION_DIR=dist\%MAJOR_VERSION%
|
||||||
|
if not exist "%VERSION_DIR%" (
|
||||||
|
mkdir "%VERSION_DIR%"
|
||||||
|
echo 创建目录: %VERSION_DIR%
|
||||||
|
)
|
||||||
|
|
||||||
:: 使用新的spec文件进行打包
|
:: 使用新的spec文件进行打包
|
||||||
pyinstaller --noconfirm build_nezha.spec
|
pyinstaller --noconfirm build_nezha.spec
|
||||||
|
|
||||||
|
:: 检查源文件是否存在
|
||||||
|
echo 检查文件: dist\听泉cursor助手%VERSION%.exe
|
||||||
|
if not exist "dist\听泉cursor助手%VERSION%.exe" (
|
||||||
|
echo 错误: 打包后的文件不存在
|
||||||
|
echo 预期文件路径: dist\听泉cursor助手%VERSION%.exe
|
||||||
|
dir /b dist
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
:: 检查目标目录是否存在
|
||||||
|
echo 检查目标目录: %VERSION_DIR%
|
||||||
|
if not exist "%VERSION_DIR%" (
|
||||||
|
echo 错误: 目标目录不存在
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
:: 移动文件到版本目录
|
||||||
|
echo 移动文件:
|
||||||
|
echo 源文件: dist\听泉cursor助手%VERSION%.exe
|
||||||
|
echo 目标文件: %VERSION_DIR%\听泉cursor助手v%VERSION%.exe
|
||||||
|
move "dist\听泉cursor助手%VERSION%.exe" "%VERSION_DIR%\听泉cursor助手v%VERSION%.exe"
|
||||||
|
if errorlevel 1 (
|
||||||
|
echo 移动文件失败,请检查:
|
||||||
|
echo 1. 源文件是否存在: dist\听泉cursor助手%VERSION%.exe
|
||||||
|
echo 2. 目标目录是否可写: %VERSION_DIR%
|
||||||
|
echo 3. 目标文件是否已存在: %VERSION_DIR%\听泉cursor助手v%VERSION%.exe
|
||||||
|
dir /b dist
|
||||||
|
dir /b "%VERSION_DIR%"
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
echo.
|
||||||
echo 打包完成!
|
echo 打包完成!
|
||||||
|
echo 文件保存在: %VERSION_DIR%\听泉cursor助手v%VERSION%.exe
|
||||||
pause
|
pause
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
# -*- mode: python ; coding: utf-8 -*-
|
# -*- mode: python ; coding: utf-8 -*-
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
from PyInstaller.utils.hooks import collect_all
|
||||||
|
|
||||||
def get_version():
|
def get_version():
|
||||||
with open('version.txt', 'r', encoding='utf-8') as f:
|
with open('version.txt', 'r', encoding='utf-8') as f:
|
||||||
@@ -8,21 +10,43 @@ def get_version():
|
|||||||
|
|
||||||
version = get_version()
|
version = get_version()
|
||||||
|
|
||||||
|
# 收集所有需要的依赖
|
||||||
|
datas = [('icon', 'icon'), ('version.txt', '.')]
|
||||||
|
binaries = []
|
||||||
|
hiddenimports = [
|
||||||
|
'win32gui', 'win32con', 'win32process', 'psutil', # Windows API 相关
|
||||||
|
'PyQt5', 'PyQt5.QtCore', 'PyQt5.QtGui', 'PyQt5.QtWidgets', # GUI 相关
|
||||||
|
'PyQt5.sip', # PyQt5 必需
|
||||||
|
'PyQt5.QtNetwork', # 网络相关
|
||||||
|
'PIL', # Pillow 相关
|
||||||
|
'PIL._imaging', # Pillow 核心
|
||||||
|
'requests', 'urllib3', 'certifi', # 网络请求相关
|
||||||
|
'json', 'uuid', 'hashlib', 'logging', # 基础功能相关
|
||||||
|
'importlib', # 导入相关
|
||||||
|
'pkg_resources', # 包资源
|
||||||
|
]
|
||||||
|
|
||||||
|
# 主要的分析对象
|
||||||
a = Analysis(
|
a = Analysis(
|
||||||
['main.py'],
|
['main.py'],
|
||||||
pathex=[],
|
pathex=[],
|
||||||
binaries=[],
|
binaries=binaries,
|
||||||
datas=[('icon', 'icon'), ('version.txt', '.')],
|
datas=datas,
|
||||||
hiddenimports=[],
|
hiddenimports=hiddenimports,
|
||||||
hookspath=[],
|
hookspath=[],
|
||||||
hooksconfig={},
|
hooksconfig={},
|
||||||
runtime_hooks=[],
|
runtime_hooks=[],
|
||||||
excludes=[],
|
excludes=['_tkinter', 'tkinter', 'Tkinter'],
|
||||||
|
win_no_prefer_redirects=False,
|
||||||
|
win_private_assemblies=False,
|
||||||
noarchive=False,
|
noarchive=False,
|
||||||
optimize=0,
|
module_collection_mode={'PyQt5': 'pyz+py'},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# 创建PYZ
|
||||||
pyz = PYZ(a.pure)
|
pyz = PYZ(a.pure)
|
||||||
|
|
||||||
|
# 创建EXE
|
||||||
exe = EXE(
|
exe = EXE(
|
||||||
pyz,
|
pyz,
|
||||||
a.scripts,
|
a.scripts,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import time
|
|||||||
import logging
|
import logging
|
||||||
import sqlite3
|
import sqlite3
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
import subprocess
|
||||||
|
|
||||||
class CursorAuthManager:
|
class CursorAuthManager:
|
||||||
"""Cursor认证信息管理器"""
|
"""Cursor认证信息管理器"""
|
||||||
@@ -99,9 +100,19 @@ class CursorAuthManager:
|
|||||||
logging.info("正在重启Cursor...")
|
logging.info("正在重启Cursor...")
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
# Windows系统
|
# Windows系统
|
||||||
|
# 创建startupinfo对象来隐藏命令行窗口
|
||||||
|
startupinfo = subprocess.STARTUPINFO()
|
||||||
|
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||||
|
startupinfo.wShowWindow = subprocess.SW_HIDE
|
||||||
|
|
||||||
# 关闭Cursor
|
# 关闭Cursor
|
||||||
os.system("taskkill /f /im Cursor.exe 2>nul")
|
subprocess.run(
|
||||||
|
"taskkill /f /im Cursor.exe 2>nul",
|
||||||
|
startupinfo=startupinfo,
|
||||||
|
shell=True
|
||||||
|
)
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
# 获取Cursor安装路径
|
# 获取Cursor安装路径
|
||||||
cursor_exe = self.cursor_path / "Cursor.exe"
|
cursor_exe = self.cursor_path / "Cursor.exe"
|
||||||
if cursor_exe.exists():
|
if cursor_exe.exists():
|
||||||
@@ -114,16 +125,16 @@ class CursorAuthManager:
|
|||||||
return False
|
return False
|
||||||
elif sys.platform == "darwin":
|
elif sys.platform == "darwin":
|
||||||
# macOS系统
|
# macOS系统
|
||||||
os.system("killall Cursor 2>/dev/null")
|
subprocess.run("killall Cursor 2>/dev/null", shell=True)
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
os.system("open -a Cursor")
|
subprocess.run("open -a Cursor", shell=True)
|
||||||
logging.info("Cursor重启成功")
|
logging.info("Cursor重启成功")
|
||||||
return True
|
return True
|
||||||
elif sys.platform == "linux":
|
elif sys.platform == "linux":
|
||||||
# Linux系统
|
# Linux系统
|
||||||
os.system("pkill -f cursor")
|
subprocess.run("pkill -f cursor", shell=True)
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
os.system("cursor &")
|
subprocess.run("cursor &", shell=True)
|
||||||
logging.info("Cursor重启成功")
|
logging.info("Cursor重启成功")
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
|
|||||||
504
cursor_win_id_modifier.ps1
Normal file
504
cursor_win_id_modifier.ps1
Normal file
@@ -0,0 +1,504 @@
|
|||||||
|
# 设置输出编码为 UTF-8
|
||||||
|
$OutputEncoding = [System.Text.Encoding]::UTF8
|
||||||
|
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
||||||
|
|
||||||
|
# 颜色定义
|
||||||
|
$RED = "`e[31m"
|
||||||
|
$GREEN = "`e[32m"
|
||||||
|
$YELLOW = "`e[33m"
|
||||||
|
$BLUE = "`e[34m"
|
||||||
|
$NC = "`e[0m"
|
||||||
|
|
||||||
|
# 配置文件路径
|
||||||
|
$STORAGE_FILE = "$env:APPDATA\Cursor\User\globalStorage\storage.json"
|
||||||
|
$BACKUP_DIR = "$env:APPDATA\Cursor\User\globalStorage\backups"
|
||||||
|
|
||||||
|
# 检查管理员权限
|
||||||
|
function Test-Administrator {
|
||||||
|
$user = [Security.Principal.WindowsIdentity]::GetCurrent()
|
||||||
|
$principal = New-Object Security.Principal.WindowsPrincipal($user)
|
||||||
|
return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not (Test-Administrator)) {
|
||||||
|
Write-Host "$RED[错误]$NC 请以管理员身份运行此脚本"
|
||||||
|
Write-Host "请右键点击脚本,选择'以管理员身份运行'"
|
||||||
|
Read-Host "按回车键退出"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# 显示 Logo
|
||||||
|
Clear-Host
|
||||||
|
Write-Host @"
|
||||||
|
|
||||||
|
██████╗██╗ ██╗██████╗ ███████╗ ██████╗ ██████╗
|
||||||
|
██╔════╝██║ ██║██╔══██╗██╔════╝██╔═══██╗██╔══██╗
|
||||||
|
██║ ██║ ██║██████╔╝███████╗██║ ██║██████╔╝
|
||||||
|
██║ ██║ ██║██╔══██╗╚════██║██║ ██║██╔══██╗
|
||||||
|
╚██████╗╚██████╔╝██║ ██║███████║╚██████╔╝██║ ██║
|
||||||
|
╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝
|
||||||
|
|
||||||
|
"@
|
||||||
|
Write-Host "$BLUE================================$NC"
|
||||||
|
Write-Host "$GREEN Cursor 设备ID 修改工具 $NC"
|
||||||
|
Write-Host "$YELLOW 关注公众号【煎饼果子卷AI】 $NC"
|
||||||
|
Write-Host "$YELLOW 一起交流更多Cursor技巧和AI知识(脚本免费、关注公众号加群有更多技巧和大佬) $NC"
|
||||||
|
Write-Host "$YELLOW [重要提示] 本工具免费,如果对您有帮助,请关注公众号【煎饼果子卷AI】 $NC"
|
||||||
|
Write-Host "$BLUE================================$NC"
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
# 获取并显示 Cursor 版本
|
||||||
|
function Get-CursorVersion {
|
||||||
|
try {
|
||||||
|
# 主要检测路径
|
||||||
|
$packagePath = "$env:LOCALAPPDATA\Programs\cursor\resources\app\package.json"
|
||||||
|
|
||||||
|
if (Test-Path $packagePath) {
|
||||||
|
$packageJson = Get-Content $packagePath -Raw | ConvertFrom-Json
|
||||||
|
if ($packageJson.version) {
|
||||||
|
Write-Host "$GREEN[信息]$NC 当前安装的 Cursor 版本: v$($packageJson.version)"
|
||||||
|
return $packageJson.version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# 备用路径检测
|
||||||
|
$altPath = "$env:LOCALAPPDATA\cursor\resources\app\package.json"
|
||||||
|
if (Test-Path $altPath) {
|
||||||
|
$packageJson = Get-Content $altPath -Raw | ConvertFrom-Json
|
||||||
|
if ($packageJson.version) {
|
||||||
|
Write-Host "$GREEN[信息]$NC 当前安装的 Cursor 版本: v$($packageJson.version)"
|
||||||
|
return $packageJson.version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "$YELLOW[警告]$NC 无法检测到 Cursor 版本"
|
||||||
|
Write-Host "$YELLOW[提示]$NC 请确保 Cursor 已正确安装"
|
||||||
|
return $null
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Host "$RED[错误]$NC 获取 Cursor 版本失败: $_"
|
||||||
|
return $null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# 获取并显示版本信息
|
||||||
|
$cursorVersion = Get-CursorVersion
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
Write-Host "$YELLOW[重要提示]$NC 最新的 0.45.x (以支持)"
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
# 检查并关闭 Cursor 进程
|
||||||
|
Write-Host "$GREEN[信息]$NC 检查 Cursor 进程..."
|
||||||
|
|
||||||
|
function Get-ProcessDetails {
|
||||||
|
param($processName)
|
||||||
|
Write-Host "$BLUE[调试]$NC 正在获取 $processName 进程详细信息:"
|
||||||
|
Get-WmiObject Win32_Process -Filter "name='$processName'" |
|
||||||
|
Select-Object ProcessId, ExecutablePath, CommandLine |
|
||||||
|
Format-List
|
||||||
|
}
|
||||||
|
|
||||||
|
# 定义最大重试次数和等待时间
|
||||||
|
$MAX_RETRIES = 5
|
||||||
|
$WAIT_TIME = 1
|
||||||
|
|
||||||
|
# 处理进程关闭
|
||||||
|
function Close-CursorProcess {
|
||||||
|
param($processName)
|
||||||
|
|
||||||
|
$process = Get-Process -Name $processName -ErrorAction SilentlyContinue
|
||||||
|
if ($process) {
|
||||||
|
Write-Host "$YELLOW[警告]$NC 发现 $processName 正在运行"
|
||||||
|
Get-ProcessDetails $processName
|
||||||
|
|
||||||
|
Write-Host "$YELLOW[警告]$NC 尝试关闭 $processName..."
|
||||||
|
Stop-Process -Name $processName -Force
|
||||||
|
|
||||||
|
$retryCount = 0
|
||||||
|
while ($retryCount -lt $MAX_RETRIES) {
|
||||||
|
$process = Get-Process -Name $processName -ErrorAction SilentlyContinue
|
||||||
|
if (-not $process) { break }
|
||||||
|
|
||||||
|
$retryCount++
|
||||||
|
if ($retryCount -ge $MAX_RETRIES) {
|
||||||
|
Write-Host "$RED[错误]$NC 在 $MAX_RETRIES 次尝试后仍无法关闭 $processName"
|
||||||
|
Get-ProcessDetails $processName
|
||||||
|
Write-Host "$RED[错误]$NC 请手动关闭进程后重试"
|
||||||
|
Read-Host "按回车键退出"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
Write-Host "$YELLOW[警告]$NC 等待进程关闭,尝试 $retryCount/$MAX_RETRIES..."
|
||||||
|
Start-Sleep -Seconds $WAIT_TIME
|
||||||
|
}
|
||||||
|
Write-Host "$GREEN[信息]$NC $processName 已成功关闭"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# 关闭所有 Cursor 进程
|
||||||
|
Close-CursorProcess "Cursor"
|
||||||
|
Close-CursorProcess "cursor"
|
||||||
|
|
||||||
|
# 创建备份目录
|
||||||
|
if (-not (Test-Path $BACKUP_DIR)) {
|
||||||
|
New-Item -ItemType Directory -Path $BACKUP_DIR | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
# 备份现有配置
|
||||||
|
if (Test-Path $STORAGE_FILE) {
|
||||||
|
Write-Host "$GREEN[信息]$NC 正在备份配置文件..."
|
||||||
|
$backupName = "storage.json.backup_$(Get-Date -Format 'yyyyMMdd_HHmmss')"
|
||||||
|
Copy-Item $STORAGE_FILE "$BACKUP_DIR\$backupName"
|
||||||
|
}
|
||||||
|
|
||||||
|
# 生成新的 ID
|
||||||
|
Write-Host "$GREEN[信息]$NC 正在生成新的 ID..."
|
||||||
|
|
||||||
|
# 在颜色定义后添加此函数
|
||||||
|
function Get-RandomHex {
|
||||||
|
param (
|
||||||
|
[int]$length
|
||||||
|
)
|
||||||
|
|
||||||
|
$bytes = New-Object byte[] ($length)
|
||||||
|
$rng = [System.Security.Cryptography.RNGCryptoServiceProvider]::new()
|
||||||
|
$rng.GetBytes($bytes)
|
||||||
|
$hexString = [System.BitConverter]::ToString($bytes) -replace '-',''
|
||||||
|
$rng.Dispose()
|
||||||
|
return $hexString
|
||||||
|
}
|
||||||
|
|
||||||
|
# 改进 ID 生成函数
|
||||||
|
function New-StandardMachineId {
|
||||||
|
$template = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"
|
||||||
|
$result = $template -replace '[xy]', {
|
||||||
|
param($match)
|
||||||
|
$r = [Random]::new().Next(16)
|
||||||
|
$v = if ($match.Value -eq "x") { $r } else { ($r -band 0x3) -bor 0x8 }
|
||||||
|
return $v.ToString("x")
|
||||||
|
}
|
||||||
|
return $result
|
||||||
|
}
|
||||||
|
|
||||||
|
# 在生成 ID 时使用新函数
|
||||||
|
$MAC_MACHINE_ID = New-StandardMachineId
|
||||||
|
$UUID = [System.Guid]::NewGuid().ToString()
|
||||||
|
# 将 auth0|user_ 转换为字节数组的十六进制
|
||||||
|
$prefixBytes = [System.Text.Encoding]::UTF8.GetBytes("auth0|user_")
|
||||||
|
$prefixHex = -join ($prefixBytes | ForEach-Object { '{0:x2}' -f $_ })
|
||||||
|
# 生成32字节(64个十六进制字符)的随机数作为 machineId 的随机部分
|
||||||
|
$randomPart = Get-RandomHex -length 32
|
||||||
|
$MACHINE_ID = "$prefixHex$randomPart"
|
||||||
|
$SQM_ID = "{$([System.Guid]::NewGuid().ToString().ToUpper())}"
|
||||||
|
|
||||||
|
# 在生成新ID后直接执行注册表操作,移除询问
|
||||||
|
function Update-MachineGuid {
|
||||||
|
try {
|
||||||
|
$newMachineGuid = [System.Guid]::NewGuid().ToString()
|
||||||
|
$registryPath = "HKLM:\SOFTWARE\Microsoft\Cryptography"
|
||||||
|
|
||||||
|
# 备份原始值
|
||||||
|
$originalGuid = (Get-ItemProperty -Path $registryPath -Name "MachineGuid").MachineGuid
|
||||||
|
$backupFile = "$BACKUP_DIR\MachineGuid.backup_$(Get-Date -Format 'yyyyMMdd_HHmmss')"
|
||||||
|
$originalGuid | Out-File $backupFile -Encoding UTF8
|
||||||
|
|
||||||
|
# 更新注册表
|
||||||
|
Set-ItemProperty -Path $registryPath -Name "MachineGuid" -Value $newMachineGuid
|
||||||
|
Write-Host "$GREEN[信息]$NC 已更新系统 MachineGuid: $newMachineGuid"
|
||||||
|
Write-Host "$GREEN[信息]$NC 原始值已备份至: $backupFile"
|
||||||
|
Write-Host "$GREEN[信息]$NC 注册表路径: 计算机\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography"
|
||||||
|
Write-Host "$GREEN[信息]$NC 注册表项名: MachineGuid"
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Host "$RED[错误]$NC 更新系统 MachineGuid 失败: $_"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# 创建或更新配置文件
|
||||||
|
Write-Host "$GREEN[信息]$NC 正在更新配置..."
|
||||||
|
|
||||||
|
try {
|
||||||
|
# 检查配置文件是否存在
|
||||||
|
if (-not (Test-Path $STORAGE_FILE)) {
|
||||||
|
Write-Host "$RED[错误]$NC 未找到配置文件: $STORAGE_FILE"
|
||||||
|
Write-Host "$YELLOW[提示]$NC 请先安装并运行一次 Cursor 后再使用此脚本"
|
||||||
|
Read-Host "按回车键退出"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# 读取现有配置文件
|
||||||
|
try {
|
||||||
|
$originalContent = Get-Content $STORAGE_FILE -Raw -Encoding UTF8
|
||||||
|
|
||||||
|
# 将 JSON 字符串转换为 PowerShell 对象
|
||||||
|
$config = $originalContent | ConvertFrom-Json
|
||||||
|
|
||||||
|
# 备份当前值
|
||||||
|
$oldValues = @{
|
||||||
|
'machineId' = $config.'telemetry.machineId'
|
||||||
|
'macMachineId' = $config.'telemetry.macMachineId'
|
||||||
|
'devDeviceId' = $config.'telemetry.devDeviceId'
|
||||||
|
'sqmId' = $config.'telemetry.sqmId'
|
||||||
|
}
|
||||||
|
|
||||||
|
# 更新特定的值
|
||||||
|
$config.'telemetry.machineId' = $MACHINE_ID
|
||||||
|
$config.'telemetry.macMachineId' = $MAC_MACHINE_ID
|
||||||
|
$config.'telemetry.devDeviceId' = $UUID
|
||||||
|
$config.'telemetry.sqmId' = $SQM_ID
|
||||||
|
|
||||||
|
# 将更新后的对象转换回 JSON 并保存
|
||||||
|
$updatedJson = $config | ConvertTo-Json -Depth 10
|
||||||
|
[System.IO.File]::WriteAllText(
|
||||||
|
[System.IO.Path]::GetFullPath($STORAGE_FILE),
|
||||||
|
$updatedJson,
|
||||||
|
[System.Text.Encoding]::UTF8
|
||||||
|
)
|
||||||
|
Write-Host "$GREEN[信息]$NC 成功更新配置文件"
|
||||||
|
} catch {
|
||||||
|
# 如果出错,尝试恢复原始内容
|
||||||
|
if ($originalContent) {
|
||||||
|
[System.IO.File]::WriteAllText(
|
||||||
|
[System.IO.Path]::GetFullPath($STORAGE_FILE),
|
||||||
|
$originalContent,
|
||||||
|
[System.Text.Encoding]::UTF8
|
||||||
|
)
|
||||||
|
}
|
||||||
|
throw "处理 JSON 失败: $_"
|
||||||
|
}
|
||||||
|
# 直接执行更新 MachineGuid,不再询问
|
||||||
|
Update-MachineGuid
|
||||||
|
# 显示结果
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "$GREEN[信息]$NC 已更新配置:"
|
||||||
|
Write-Host "$BLUE[调试]$NC machineId: $MACHINE_ID"
|
||||||
|
Write-Host "$BLUE[调试]$NC macMachineId: $MAC_MACHINE_ID"
|
||||||
|
Write-Host "$BLUE[调试]$NC devDeviceId: $UUID"
|
||||||
|
Write-Host "$BLUE[调试]$NC sqmId: $SQM_ID"
|
||||||
|
|
||||||
|
# 显示文件树结构
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "$GREEN[信息]$NC 文件结构:"
|
||||||
|
Write-Host "$BLUE$env:APPDATA\Cursor\User$NC"
|
||||||
|
Write-Host "├── globalStorage"
|
||||||
|
Write-Host "│ ├── storage.json (已修改)"
|
||||||
|
Write-Host "│ └── backups"
|
||||||
|
|
||||||
|
# 列出备份文件
|
||||||
|
$backupFiles = Get-ChildItem "$BACKUP_DIR\*" -ErrorAction SilentlyContinue
|
||||||
|
if ($backupFiles) {
|
||||||
|
foreach ($file in $backupFiles) {
|
||||||
|
Write-Host "│ └── $($file.Name)"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Write-Host "│ └── (空)"
|
||||||
|
}
|
||||||
|
|
||||||
|
# 显示公众号信息
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "$GREEN================================$NC"
|
||||||
|
Write-Host "$YELLOW 关注公众号【煎饼果子卷AI】一起交流更多Cursor技巧和AI知识(脚本免费、关注公众号加群有更多技巧和大佬) $NC"
|
||||||
|
Write-Host "$GREEN================================$NC"
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "$GREEN[信息]$NC 请重启 Cursor 以应用新的配置"
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
# 询问是否要禁用自动更新
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "$YELLOW[询问]$NC 是否要禁用 Cursor 自动更新功能?"
|
||||||
|
Write-Host "0) 否 - 保持默认设置 (按回车键)"
|
||||||
|
Write-Host "1) 是 - 禁用自动更新"
|
||||||
|
$choice = Read-Host "请输入选项 (0)"
|
||||||
|
|
||||||
|
if ($choice -eq "1") {
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "$GREEN[信息]$NC 正在处理自动更新..."
|
||||||
|
$updaterPath = "$env:LOCALAPPDATA\cursor-updater"
|
||||||
|
|
||||||
|
# 定义手动设置教程
|
||||||
|
function Show-ManualGuide {
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "$YELLOW[警告]$NC 自动设置失败,请尝试手动操作:"
|
||||||
|
Write-Host "$YELLOW手动禁用更新步骤:$NC"
|
||||||
|
Write-Host "1. 以管理员身份打开 PowerShell"
|
||||||
|
Write-Host "2. 复制粘贴以下命令:"
|
||||||
|
Write-Host "$BLUE命令1 - 删除现有目录(如果存在):$NC"
|
||||||
|
Write-Host "Remove-Item -Path `"$updaterPath`" -Force -Recurse -ErrorAction SilentlyContinue"
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "$BLUE命令2 - 创建阻止文件:$NC"
|
||||||
|
Write-Host "New-Item -Path `"$updaterPath`" -ItemType File -Force | Out-Null"
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "$BLUE命令3 - 设置只读属性:$NC"
|
||||||
|
Write-Host "Set-ItemProperty -Path `"$updaterPath`" -Name IsReadOnly -Value `$true"
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "$BLUE命令4 - 设置权限(可选):$NC"
|
||||||
|
Write-Host "icacls `"$updaterPath`" /inheritance:r /grant:r `"`$($env:USERNAME):(R)`""
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "$YELLOW验证方法:$NC"
|
||||||
|
Write-Host "1. 运行命令:Get-ItemProperty `"$updaterPath`""
|
||||||
|
Write-Host "2. 确认 IsReadOnly 属性为 True"
|
||||||
|
Write-Host "3. 运行命令:icacls `"$updaterPath`""
|
||||||
|
Write-Host "4. 确认只有读取权限"
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "$YELLOW[提示]$NC 完成后请重启 Cursor"
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
# 删除现有目录
|
||||||
|
if (Test-Path $updaterPath) {
|
||||||
|
try {
|
||||||
|
Remove-Item -Path $updaterPath -Force -Recurse -ErrorAction Stop
|
||||||
|
Write-Host "$GREEN[信息]$NC 成功删除 cursor-updater 目录"
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Host "$RED[错误]$NC 删除 cursor-updater 目录失败"
|
||||||
|
Show-ManualGuide
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# 创建阻止文件
|
||||||
|
try {
|
||||||
|
New-Item -Path $updaterPath -ItemType File -Force -ErrorAction Stop | Out-Null
|
||||||
|
Write-Host "$GREEN[信息]$NC 成功创建阻止文件"
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Host "$RED[错误]$NC 创建阻止文件失败"
|
||||||
|
Show-ManualGuide
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
# 设置文件权限
|
||||||
|
try {
|
||||||
|
# 设置只读属性
|
||||||
|
Set-ItemProperty -Path $updaterPath -Name IsReadOnly -Value $true -ErrorAction Stop
|
||||||
|
|
||||||
|
# 使用 icacls 设置权限
|
||||||
|
$result = Start-Process "icacls.exe" -ArgumentList "`"$updaterPath`" /inheritance:r /grant:r `"$($env:USERNAME):(R)`"" -Wait -NoNewWindow -PassThru
|
||||||
|
if ($result.ExitCode -ne 0) {
|
||||||
|
throw "icacls 命令失败"
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "$GREEN[信息]$NC 成功设置文件权限"
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Host "$RED[错误]$NC 设置文件权限失败"
|
||||||
|
Show-ManualGuide
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
# 验证设置
|
||||||
|
try {
|
||||||
|
$fileInfo = Get-ItemProperty $updaterPath
|
||||||
|
if (-not $fileInfo.IsReadOnly) {
|
||||||
|
Write-Host "$RED[错误]$NC 验证失败:文件权限设置可能未生效"
|
||||||
|
Show-ManualGuide
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Host "$RED[错误]$NC 验证设置失败"
|
||||||
|
Show-ManualGuide
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "$GREEN[信息]$NC 成功禁用自动更新"
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Host "$RED[错误]$NC 发生未知错误: $_"
|
||||||
|
Show-ManualGuide
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Host "$GREEN[信息]$NC 保持默认设置,不进行更改"
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch {
|
||||||
|
Write-Host "$RED[错误]$NC 主要操作失败: $_"
|
||||||
|
Write-Host "$YELLOW[尝试]$NC 使用备选方法..."
|
||||||
|
|
||||||
|
try {
|
||||||
|
# 备选方法:使用 Add-Content
|
||||||
|
$tempFile = [System.IO.Path]::GetTempFileName()
|
||||||
|
$config | ConvertTo-Json | Set-Content -Path $tempFile -Encoding UTF8
|
||||||
|
Copy-Item -Path $tempFile -Destination $STORAGE_FILE -Force
|
||||||
|
Remove-Item -Path $tempFile
|
||||||
|
Write-Host "$GREEN[信息]$NC 使用备选方法成功写入配置"
|
||||||
|
} catch {
|
||||||
|
Write-Host "$RED[错误]$NC 所有尝试都失败了"
|
||||||
|
Write-Host "错误详情: $_"
|
||||||
|
Write-Host "目标文件: $STORAGE_FILE"
|
||||||
|
Write-Host "请确保您有足够的权限访问该文件"
|
||||||
|
Read-Host "按回车键退出"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Read-Host "按回车键退出"
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
# 在文件写入部分修改
|
||||||
|
function Write-ConfigFile {
|
||||||
|
param($config, $filePath)
|
||||||
|
|
||||||
|
try {
|
||||||
|
# 使用 UTF8 无 BOM 编码
|
||||||
|
$utf8NoBom = New-Object System.Text.UTF8Encoding $false
|
||||||
|
$jsonContent = $config | ConvertTo-Json -Depth 10
|
||||||
|
|
||||||
|
# 统一使用 LF 换行符
|
||||||
|
$jsonContent = $jsonContent.Replace("`r`n", "`n")
|
||||||
|
|
||||||
|
[System.IO.File]::WriteAllText(
|
||||||
|
[System.IO.Path]::GetFullPath($filePath),
|
||||||
|
$jsonContent,
|
||||||
|
$utf8NoBom
|
||||||
|
)
|
||||||
|
|
||||||
|
Write-Host "$GREEN[信息]$NC 成功写入配置文件(UTF8 无 BOM)"
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
throw "写入配置文件失败: $_"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Compare-Version {
|
||||||
|
param (
|
||||||
|
[string]$version1,
|
||||||
|
[string]$version2
|
||||||
|
)
|
||||||
|
|
||||||
|
try {
|
||||||
|
$v1 = [version]($version1 -replace '[^\d\.].*$')
|
||||||
|
$v2 = [version]($version2 -replace '[^\d\.].*$')
|
||||||
|
return $v1.CompareTo($v2)
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Host "$RED[错误]$NC 版本比较失败: $_"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# 在主流程开始时添加版本检查
|
||||||
|
Write-Host "$GREEN[信息]$NC 正在检查 Cursor 版本..."
|
||||||
|
$cursorVersion = Get-CursorVersion
|
||||||
|
|
||||||
|
if ($cursorVersion) {
|
||||||
|
$compareResult = Compare-Version $cursorVersion "0.45.0"
|
||||||
|
if ($compareResult -ge 0) {
|
||||||
|
Write-Host "$RED[错误]$NC 当前版本 ($cursorVersion) 暂不支持"
|
||||||
|
Write-Host "$YELLOW[建议]$NC 请使用 v0.44.11 及以下版本"
|
||||||
|
Write-Host "$YELLOW[建议]$NC 可以从以下地址下载支持的版本:"
|
||||||
|
Write-Host "Windows: https://download.todesktop.com/230313mzl4w4u92/Cursor%20Setup%200.44.11%20-%20Build%20250103fqxdt5u9z-x64.exe"
|
||||||
|
Write-Host "Mac ARM64: https://dl.todesktop.com/230313mzl4w4u92/versions/0.44.11/mac/zip/arm64"
|
||||||
|
Read-Host "按回车键退出"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Host "$GREEN[信息]$NC 当前版本 ($cursorVersion) 支持重置功能"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Host "$YELLOW[警告]$NC 无法检测版本,将继续执行..."
|
||||||
|
}
|
||||||
2161
gui/main_window.py
2161
gui/main_window.py
File diff suppressed because it is too large
Load Diff
BIN
icon/logo1.ico
Normal file
BIN
icon/logo1.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
BIN
icon/logo2.ico
Normal file
BIN
icon/logo2.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 29 KiB |
BIN
icon/logo3.ico
Normal file
BIN
icon/logo3.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
81
main.py
81
main.py
@@ -1,9 +1,36 @@
|
|||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
|
import os
|
||||||
|
import atexit
|
||||||
|
import shutil
|
||||||
|
import tempfile
|
||||||
|
import urllib3
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from PyQt5.QtWidgets import QApplication, QMessageBox, QSystemTrayIcon, QMenu
|
||||||
|
from PyQt5.QtGui import QIcon
|
||||||
|
from PyQt5.QtCore import Qt
|
||||||
from gui.main_window import MainWindow
|
from gui.main_window import MainWindow
|
||||||
|
|
||||||
|
# 禁用所有 SSL 相关警告
|
||||||
|
urllib3.disable_warnings()
|
||||||
|
logging.getLogger('urllib3').setLevel(logging.ERROR)
|
||||||
|
|
||||||
|
def cleanup_temp():
|
||||||
|
"""清理临时文件"""
|
||||||
|
try:
|
||||||
|
temp_dir = Path(tempfile._get_default_tempdir())
|
||||||
|
for item in temp_dir.glob('_MEI*'):
|
||||||
|
try:
|
||||||
|
if item.is_dir():
|
||||||
|
shutil.rmtree(str(item), ignore_errors=True)
|
||||||
|
elif item.is_file():
|
||||||
|
item.unlink()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
def setup_logging():
|
def setup_logging():
|
||||||
"""设置日志"""
|
"""设置日志"""
|
||||||
try:
|
try:
|
||||||
@@ -27,6 +54,21 @@ def setup_logging():
|
|||||||
def main():
|
def main():
|
||||||
"""主函数"""
|
"""主函数"""
|
||||||
try:
|
try:
|
||||||
|
# 注册退出时的清理函数
|
||||||
|
atexit.register(cleanup_temp)
|
||||||
|
|
||||||
|
# 创建QApplication实例
|
||||||
|
app = QApplication(sys.argv)
|
||||||
|
|
||||||
|
# 检查系统托盘是否可用
|
||||||
|
if not QSystemTrayIcon.isSystemTrayAvailable():
|
||||||
|
logging.error("系统托盘不可用")
|
||||||
|
QMessageBox.critical(None, "错误", "系统托盘不可用,程序无法正常运行。")
|
||||||
|
return 1
|
||||||
|
|
||||||
|
# 设置应用程序不会在最后一个窗口关闭时退出
|
||||||
|
app.setQuitOnLastWindowClosed(False)
|
||||||
|
|
||||||
setup_logging()
|
setup_logging()
|
||||||
|
|
||||||
# 检查Python版本
|
# 检查Python版本
|
||||||
@@ -41,17 +83,46 @@ def main():
|
|||||||
logging.info(f" - {p}")
|
logging.info(f" - {p}")
|
||||||
|
|
||||||
logging.info("正在初始化主窗口...")
|
logging.info("正在初始化主窗口...")
|
||||||
|
|
||||||
|
# 设置应用程序ID (在设置图标之前)
|
||||||
|
if sys.platform == "win32":
|
||||||
|
import ctypes
|
||||||
|
myappid = u'nezha.cursor.helper.v3'
|
||||||
|
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
|
||||||
|
logging.info(f"设置应用程序ID: {myappid}")
|
||||||
|
|
||||||
|
# 设置应用程序图标
|
||||||
|
try:
|
||||||
|
icon_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "icon", "two.ico")
|
||||||
|
if os.path.exists(icon_path):
|
||||||
|
app_icon = QIcon(icon_path)
|
||||||
|
if not app_icon.isNull():
|
||||||
|
app.setWindowIcon(app_icon)
|
||||||
|
logging.info(f"成功设置应用程序图标: {icon_path}")
|
||||||
|
else:
|
||||||
|
logging.error("图标文件加载失败")
|
||||||
|
else:
|
||||||
|
logging.error(f"图标文件不存在: {icon_path}")
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f"设置应用程序图标失败: {str(e)}")
|
||||||
|
|
||||||
window = MainWindow()
|
window = MainWindow()
|
||||||
|
window.setWindowIcon(app.windowIcon()) # 确保窗口使用相同的图标
|
||||||
|
|
||||||
logging.info("正在启动主窗口...")
|
logging.info("正在启动主窗口...")
|
||||||
window.run()
|
window.show()
|
||||||
|
|
||||||
|
return app.exec_()
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error_msg = f"程序运行出错: {str(e)}\n{traceback.format_exc()}"
|
error_msg = f"程序运行出错: {str(e)}\n{traceback.format_exc()}"
|
||||||
logging.error(error_msg)
|
logging.error(error_msg)
|
||||||
# 使用tkinter的消息框显示错误
|
# 使用 QMessageBox 显示错误
|
||||||
from tkinter import messagebox
|
if QApplication.instance() is None:
|
||||||
messagebox.showerror("错误", error_msg)
|
app = QApplication(sys.argv)
|
||||||
|
QMessageBox.critical(None, "错误", error_msg)
|
||||||
|
return 1
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
sys.exit(main())
|
||||||
@@ -1,4 +1,11 @@
|
|||||||
|
# Use Tsinghua mirror for faster download in China:
|
||||||
|
# pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt
|
||||||
|
|
||||||
requests==2.31.0
|
requests==2.31.0
|
||||||
|
setuptools>=68.0.0
|
||||||
|
altgraph>=0.17.4
|
||||||
pyinstaller==6.3.0
|
pyinstaller==6.3.0
|
||||||
pillow==10.2.0 # 用于处理图标
|
pillow==10.2.0
|
||||||
setuptools==65.5.1 # 解决pkg_resources.extern问题
|
PyQt5==5.15.10
|
||||||
|
pywin32==306
|
||||||
|
packaging>=23.2
|
||||||
295
test_compare_reset.py
Normal file
295
test_compare_reset.py
Normal file
@@ -0,0 +1,295 @@
|
|||||||
|
import json
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
|
from datetime import datetime
|
||||||
|
from account_switcher import AccountSwitcher
|
||||||
|
|
||||||
|
def get_full_machine_info():
|
||||||
|
"""获取更完整的机器码相关信息"""
|
||||||
|
info = {}
|
||||||
|
|
||||||
|
# 1. 获取 package.json 中的所有信息(检查两个可能的路径)
|
||||||
|
cursor_paths = [
|
||||||
|
Path(os.path.expanduser("~")) / "AppData" / "Local" / "Programs" / "Cursor",
|
||||||
|
Path(os.path.expanduser("~")) / "AppData" / "Local" / "cursor"
|
||||||
|
]
|
||||||
|
|
||||||
|
info["package_json"] = {}
|
||||||
|
for cursor_path in cursor_paths:
|
||||||
|
package_json = cursor_path / "resources" / "app" / "package.json"
|
||||||
|
if package_json.exists():
|
||||||
|
with open(package_json, "r", encoding="utf-8") as f:
|
||||||
|
info["package_json"][str(package_json)] = json.load(f)
|
||||||
|
|
||||||
|
# 2. 获取 storage.json 的内容
|
||||||
|
storage_path = Path(os.getenv('APPDATA')) / "Cursor" / "User" / "globalStorage" / "storage.json"
|
||||||
|
info["storage_json"] = None
|
||||||
|
if storage_path.exists():
|
||||||
|
try:
|
||||||
|
with open(storage_path, "r", encoding="utf-8") as f:
|
||||||
|
info["storage_json"] = json.load(f)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# 3. 检查注册表项和其值
|
||||||
|
import winreg
|
||||||
|
registry_paths = {
|
||||||
|
"cryptography": r"SOFTWARE\Microsoft\Cryptography", # 系统 MachineGuid
|
||||||
|
"cursor_shell": r"Software\Classes\Directory\Background\shell\Cursor",
|
||||||
|
"cursor_command": r"Software\Classes\Directory\Background\shell\Cursor\command",
|
||||||
|
"cursor_auth": r"Software\Cursor\Auth",
|
||||||
|
"cursor_updates": r"Software\Cursor\Updates",
|
||||||
|
"cursor_main": r"Software\Cursor"
|
||||||
|
}
|
||||||
|
|
||||||
|
info["registry"] = {}
|
||||||
|
|
||||||
|
# HKEY_LOCAL_MACHINE 项
|
||||||
|
try:
|
||||||
|
key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, registry_paths["cryptography"], 0, winreg.KEY_READ | winreg.KEY_WOW64_64KEY)
|
||||||
|
info["registry"]["HKLM_MachineGuid"] = {
|
||||||
|
"exists": True,
|
||||||
|
"value": winreg.QueryValueEx(key, "MachineGuid")[0]
|
||||||
|
}
|
||||||
|
except WindowsError:
|
||||||
|
info["registry"]["HKLM_MachineGuid"] = {
|
||||||
|
"exists": False,
|
||||||
|
"value": None
|
||||||
|
}
|
||||||
|
|
||||||
|
# HKEY_CURRENT_USER 项
|
||||||
|
for name, path in registry_paths.items():
|
||||||
|
if name == "cryptography":
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, path, 0, winreg.KEY_READ)
|
||||||
|
info["registry"][f"HKCU_{name}"] = {"exists": True, "values": {}}
|
||||||
|
try:
|
||||||
|
i = 0
|
||||||
|
while True:
|
||||||
|
name, value, type = winreg.EnumValue(key, i)
|
||||||
|
info["registry"][f"HKCU_{name}"]["values"][name] = value
|
||||||
|
i += 1
|
||||||
|
except WindowsError:
|
||||||
|
pass
|
||||||
|
except WindowsError:
|
||||||
|
info["registry"][f"HKCU_{name}"] = {"exists": False, "values": {}}
|
||||||
|
|
||||||
|
# 4. 检查关键文件的存在状态
|
||||||
|
paths_to_check = {
|
||||||
|
"storage": storage_path,
|
||||||
|
"storage_backup": Path(os.getenv('APPDATA')) / "Cursor" / "User" / "globalStorage" / "backups",
|
||||||
|
"user_data": Path(os.getenv('LOCALAPPDATA')) / "Cursor" / "User",
|
||||||
|
"global_storage": Path(os.getenv('APPDATA')) / "Cursor" / "User" / "globalStorage",
|
||||||
|
"cache": Path(os.getenv('LOCALAPPDATA')) / "Cursor" / "Cache",
|
||||||
|
"updater": Path(os.getenv('LOCALAPPDATA')) / "cursor-updater"
|
||||||
|
}
|
||||||
|
|
||||||
|
info["files"] = {}
|
||||||
|
for name, path in paths_to_check.items():
|
||||||
|
if path.exists():
|
||||||
|
info["files"][name] = {
|
||||||
|
"exists": True,
|
||||||
|
"is_dir": path.is_dir(),
|
||||||
|
"size": os.path.getsize(path) if path.is_file() else None,
|
||||||
|
"modified_time": datetime.fromtimestamp(os.path.getmtime(path)).isoformat()
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
info["files"][name] = {
|
||||||
|
"exists": False,
|
||||||
|
"is_dir": None,
|
||||||
|
"size": None,
|
||||||
|
"modified_time": None
|
||||||
|
}
|
||||||
|
|
||||||
|
# 5. 获取遥测相关的配置值
|
||||||
|
info["telemetry"] = {
|
||||||
|
"machineId": info["storage_json"].get("telemetry.machineId") if info["storage_json"] else None,
|
||||||
|
"macMachineId": info["storage_json"].get("telemetry.macMachineId") if info["storage_json"] else None,
|
||||||
|
"devDeviceId": info["storage_json"].get("telemetry.devDeviceId") if info["storage_json"] else None,
|
||||||
|
"sqmId": info["storage_json"].get("telemetry.sqmId") if info["storage_json"] else None
|
||||||
|
}
|
||||||
|
|
||||||
|
return info
|
||||||
|
|
||||||
|
def save_info(info, filename):
|
||||||
|
"""保存信息到文件"""
|
||||||
|
with open(filename, "w", encoding="utf-8") as f:
|
||||||
|
json.dump(info, f, indent=2, ensure_ascii=False)
|
||||||
|
|
||||||
|
def compare_info(before_file, after_file):
|
||||||
|
"""比较两个信息文件的差异"""
|
||||||
|
with open(before_file, "r", encoding="utf-8") as f:
|
||||||
|
before = json.load(f)
|
||||||
|
with open(after_file, "r", encoding="utf-8") as f:
|
||||||
|
after = json.load(f)
|
||||||
|
|
||||||
|
differences = {
|
||||||
|
"package_json_changes": {},
|
||||||
|
"registry_changes": {},
|
||||||
|
"file_changes": {}
|
||||||
|
}
|
||||||
|
|
||||||
|
# 比较 package.json 变化
|
||||||
|
if "package_json" in before and "package_json" in after:
|
||||||
|
for key in set(before["package_json"].keys()) | set(after["package_json"].keys()):
|
||||||
|
before_val = before["package_json"].get(key)
|
||||||
|
after_val = after["package_json"].get(key)
|
||||||
|
if before_val != after_val:
|
||||||
|
differences["package_json_changes"][key] = {
|
||||||
|
"before": before_val,
|
||||||
|
"after": after_val
|
||||||
|
}
|
||||||
|
|
||||||
|
# 比较注册表变化
|
||||||
|
for path in set(before["registry"].keys()) | set(after["registry"].keys()):
|
||||||
|
before_reg = before["registry"].get(path, {})
|
||||||
|
after_reg = after["registry"].get(path, {})
|
||||||
|
if before_reg != after_reg:
|
||||||
|
differences["registry_changes"][path] = {
|
||||||
|
"before": before_reg,
|
||||||
|
"after": after_reg
|
||||||
|
}
|
||||||
|
|
||||||
|
# 比较文件变化
|
||||||
|
for name in set(before["files"].keys()) | set(after["files"].keys()):
|
||||||
|
before_file = before["files"].get(name, {})
|
||||||
|
after_file = after["files"].get(name, {})
|
||||||
|
if before_file != after_file:
|
||||||
|
differences["file_changes"][name] = {
|
||||||
|
"before": before_file,
|
||||||
|
"after": after_file
|
||||||
|
}
|
||||||
|
|
||||||
|
return differences
|
||||||
|
|
||||||
|
def main():
|
||||||
|
"""主测试流程"""
|
||||||
|
# 设置日志
|
||||||
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
|
print("选择操作:")
|
||||||
|
print("1. 记录当前状态(在运行 GitHub 脚本前执行)")
|
||||||
|
print("2. 记录重置后状态并对比(在运行 GitHub 脚本后执行)")
|
||||||
|
print("3. 运行我们的重置方法并记录对比")
|
||||||
|
|
||||||
|
choice = input("\n请选择操作 (1/2/3): ").strip()
|
||||||
|
|
||||||
|
if choice == "1":
|
||||||
|
# 记录初始状态
|
||||||
|
print("\n记录初始状态...")
|
||||||
|
initial_info = get_full_machine_info()
|
||||||
|
save_info(initial_info, "before_github_reset.json")
|
||||||
|
print("初始状态已保存到 before_github_reset.json")
|
||||||
|
|
||||||
|
elif choice == "2":
|
||||||
|
# 检查是否存在初始状态文件
|
||||||
|
if not os.path.exists("before_github_reset.json"):
|
||||||
|
print("错误:找不到初始状态文件 before_github_reset.json")
|
||||||
|
print("请先执行选项 1 记录初始状态")
|
||||||
|
return
|
||||||
|
|
||||||
|
# 记录 GitHub 脚本执行后的状态
|
||||||
|
print("\n记录 GitHub 脚本执行后的状态...")
|
||||||
|
after_info = get_full_machine_info()
|
||||||
|
save_info(after_info, "after_github_reset.json")
|
||||||
|
|
||||||
|
# 对比变化
|
||||||
|
print("\n=== GitHub 脚本执行前后的变化 ===")
|
||||||
|
differences = compare_info("before_github_reset.json", "after_github_reset.json")
|
||||||
|
|
||||||
|
# 显示 package.json 的变化
|
||||||
|
if differences["package_json_changes"]:
|
||||||
|
print("\npackage.json 变化:")
|
||||||
|
for key, change in differences["package_json_changes"].items():
|
||||||
|
print(f"- {key}:")
|
||||||
|
print(f" 之前: {change['before']}")
|
||||||
|
print(f" 之后: {change['after']}")
|
||||||
|
|
||||||
|
# 显示注册表的变化
|
||||||
|
if differences["registry_changes"]:
|
||||||
|
print("\n注册表变化:")
|
||||||
|
for path, change in differences["registry_changes"].items():
|
||||||
|
print(f"\n- {path}:")
|
||||||
|
print(f" 之前: {change['before']}")
|
||||||
|
print(f" 之后: {change['after']}")
|
||||||
|
|
||||||
|
# 显示文件的变化
|
||||||
|
if differences["file_changes"]:
|
||||||
|
print("\n文件变化:")
|
||||||
|
for name, change in differences["file_changes"].items():
|
||||||
|
print(f"\n- {name}:")
|
||||||
|
before_status = "存在" if change["before"].get("exists") else "不存在"
|
||||||
|
after_status = "存在" if change["after"].get("exists") else "不存在"
|
||||||
|
print(f" 状态: {before_status} -> {after_status}")
|
||||||
|
if change["before"].get("exists") and change["after"].get("exists"):
|
||||||
|
if change["before"].get("size") != change["after"].get("size"):
|
||||||
|
print(f" 大小: {change['before'].get('size')} -> {change['after'].get('size')}")
|
||||||
|
if change["before"].get("modified_time") != change["after"].get("modified_time"):
|
||||||
|
print(f" 修改时间: {change['before'].get('modified_time')} -> {change['after'].get('modified_time')}")
|
||||||
|
|
||||||
|
# 保存差异到文件
|
||||||
|
save_info(differences, "github_script_changes.json")
|
||||||
|
print("\n详细的变化信息已保存到 github_script_changes.json")
|
||||||
|
|
||||||
|
elif choice == "3":
|
||||||
|
if not os.path.exists("github_script_changes.json"):
|
||||||
|
print("错误:找不到 GitHub 脚本的变化记录文件 github_script_changes.json")
|
||||||
|
print("请先执行选项 1 和 2 来记录 GitHub 脚本的变化")
|
||||||
|
return
|
||||||
|
|
||||||
|
# 记录运行我们的重置方法前的状态
|
||||||
|
print("\n记录当前状态...")
|
||||||
|
before_our_reset = get_full_machine_info()
|
||||||
|
save_info(before_our_reset, "before_our_reset.json")
|
||||||
|
|
||||||
|
# 运行我们的重置方法
|
||||||
|
print("\n运行我们的重置方法...")
|
||||||
|
switcher = AccountSwitcher()
|
||||||
|
original_restart = switcher.restart_cursor
|
||||||
|
try:
|
||||||
|
switcher.restart_cursor = lambda: True
|
||||||
|
switcher.reset_machine_id()
|
||||||
|
finally:
|
||||||
|
switcher.restart_cursor = original_restart
|
||||||
|
|
||||||
|
# 记录重置后的状态
|
||||||
|
print("\n记录重置后的状态...")
|
||||||
|
after_our_reset = get_full_machine_info()
|
||||||
|
save_info(after_our_reset, "after_our_reset.json")
|
||||||
|
|
||||||
|
# 对比我们的方法与 GitHub 脚本的差异
|
||||||
|
print("\n=== 对比我们的重置方法与 GitHub 脚本的差异 ===")
|
||||||
|
with open("github_script_changes.json", "r", encoding="utf-8") as f:
|
||||||
|
github_changes = json.load(f)
|
||||||
|
our_changes = compare_info("before_our_reset.json", "after_our_reset.json")
|
||||||
|
|
||||||
|
# 分析差异
|
||||||
|
print("\n=== 差异分析 ===")
|
||||||
|
print("1. GitHub 脚本改变但我们没有改变的项:")
|
||||||
|
for category in ["package_json_changes", "registry_changes", "file_changes"]:
|
||||||
|
for key in github_changes[category]:
|
||||||
|
if key not in our_changes[category]:
|
||||||
|
print(f"- {category}: {key}")
|
||||||
|
|
||||||
|
print("\n2. 我们改变但 GitHub 脚本没有改变的项:")
|
||||||
|
for category in ["package_json_changes", "registry_changes", "file_changes"]:
|
||||||
|
for key in our_changes[category]:
|
||||||
|
if key not in github_changes[category]:
|
||||||
|
print(f"- {category}: {key}")
|
||||||
|
|
||||||
|
# 保存分析结果
|
||||||
|
save_info({
|
||||||
|
"github_changes": github_changes,
|
||||||
|
"our_changes": our_changes
|
||||||
|
}, "reset_methods_comparison.json")
|
||||||
|
print("\n详细的对比结果已保存到 reset_methods_comparison.json")
|
||||||
|
|
||||||
|
else:
|
||||||
|
print("无效的选择")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
104
test_reset.py
Normal file
104
test_reset.py
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
import json
|
||||||
|
import logging
|
||||||
|
from pathlib import Path
|
||||||
|
from account_switcher import AccountSwitcher
|
||||||
|
import os
|
||||||
|
|
||||||
|
def get_machine_info():
|
||||||
|
"""获取当前机器码相关信息"""
|
||||||
|
info = {}
|
||||||
|
|
||||||
|
# 1. 获取 package.json 中的 machineId
|
||||||
|
cursor_path = Path(os.path.expanduser("~")) / "AppData" / "Local" / "Programs" / "Cursor"
|
||||||
|
package_json = cursor_path / "resources" / "app" / "package.json"
|
||||||
|
if package_json.exists():
|
||||||
|
with open(package_json, "r", encoding="utf-8") as f:
|
||||||
|
data = json.load(f)
|
||||||
|
info["machine_id"] = data.get("machineId", "未找到")
|
||||||
|
|
||||||
|
# 2. 检查注册表项是否存在
|
||||||
|
import winreg
|
||||||
|
registry_paths = [
|
||||||
|
r"Software\Classes\Directory\Background\shell\Cursor\command",
|
||||||
|
r"Software\Classes\Directory\Background\shell\Cursor",
|
||||||
|
r"Software\Cursor\Auth",
|
||||||
|
r"Software\Cursor\Updates",
|
||||||
|
r"Software\Cursor"
|
||||||
|
]
|
||||||
|
|
||||||
|
info["registry"] = {}
|
||||||
|
for path in registry_paths:
|
||||||
|
try:
|
||||||
|
winreg.OpenKey(winreg.HKEY_CURRENT_USER, path, 0, winreg.KEY_READ)
|
||||||
|
info["registry"][path] = "存在"
|
||||||
|
except WindowsError:
|
||||||
|
info["registry"][path] = "不存在"
|
||||||
|
|
||||||
|
# 3. 检查文件是否存在
|
||||||
|
local_app_data = Path(os.getenv('LOCALAPPDATA'))
|
||||||
|
files_to_check = [
|
||||||
|
local_app_data / "Cursor" / "User" / "globalStorage",
|
||||||
|
local_app_data / "Cursor" / "Cache",
|
||||||
|
local_app_data / "cursor-updater",
|
||||||
|
cursor_path / "resources" / "app" / "config.json",
|
||||||
|
cursor_path / "resources" / "app" / "state.json",
|
||||||
|
cursor_path / "resources" / "app" / "settings.json"
|
||||||
|
]
|
||||||
|
|
||||||
|
info["files"] = {}
|
||||||
|
for path in files_to_check:
|
||||||
|
info["files"][str(path)] = "存在" if path.exists() else "不存在"
|
||||||
|
|
||||||
|
return info
|
||||||
|
|
||||||
|
def test_reset_machine_id():
|
||||||
|
"""测试重置机器码功能"""
|
||||||
|
# 设置日志
|
||||||
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
|
print("=== 重置前的状态 ===")
|
||||||
|
before_info = get_machine_info()
|
||||||
|
print(json.dumps(before_info, indent=2, ensure_ascii=False))
|
||||||
|
|
||||||
|
# 创建 AccountSwitcher 实例并修改 reset_machine_id 方法以跳过重启
|
||||||
|
switcher = AccountSwitcher()
|
||||||
|
|
||||||
|
# 保存原始的 restart_cursor 方法
|
||||||
|
original_restart = switcher.restart_cursor
|
||||||
|
|
||||||
|
try:
|
||||||
|
# 替换 restart_cursor 方法为空函数
|
||||||
|
switcher.restart_cursor = lambda: True
|
||||||
|
|
||||||
|
# 执行重置
|
||||||
|
print("\n=== 执行重置 ===")
|
||||||
|
result = switcher.reset_machine_id()
|
||||||
|
print(f"重置结果: {result}")
|
||||||
|
|
||||||
|
print("\n=== 重置后的状态 ===")
|
||||||
|
after_info = get_machine_info()
|
||||||
|
print(json.dumps(after_info, indent=2, ensure_ascii=False))
|
||||||
|
|
||||||
|
# 比较差异
|
||||||
|
print("\n=== 变化分析 ===")
|
||||||
|
|
||||||
|
# 检查 machineId
|
||||||
|
if before_info.get("machine_id") != after_info.get("machine_id"):
|
||||||
|
print(f"machineId 变化: {before_info.get('machine_id')} -> {after_info.get('machine_id')}")
|
||||||
|
|
||||||
|
# 检查注册表变化
|
||||||
|
for path in before_info["registry"]:
|
||||||
|
if before_info["registry"][path] != after_info["registry"][path]:
|
||||||
|
print(f"注册表 {path}: {before_info['registry'][path]} -> {after_info['registry'][path]}")
|
||||||
|
|
||||||
|
# 检查文件变化
|
||||||
|
for path in before_info["files"]:
|
||||||
|
if before_info["files"][path] != after_info["files"][path]:
|
||||||
|
print(f"文件 {path}: {before_info['files'][path]} -> {after_info['files'][path]}")
|
||||||
|
|
||||||
|
finally:
|
||||||
|
# 恢复原始的 restart_cursor 方法
|
||||||
|
switcher.restart_cursor = original_restart
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
test_reset_machine_id()
|
||||||
63
test_version_manager.py
Normal file
63
test_version_manager.py
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
import logging
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
from utils.version_manager import VersionManager
|
||||||
|
|
||||||
|
# 配置日志
|
||||||
|
logging.basicConfig(
|
||||||
|
level=logging.INFO,
|
||||||
|
format='%(asctime)s - %(levelname)s - %(message)s',
|
||||||
|
handlers=[
|
||||||
|
logging.StreamHandler(sys.stdout),
|
||||||
|
logging.FileHandler('version_check.log')
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_version_manager():
|
||||||
|
"""测试版本管理器功能"""
|
||||||
|
try:
|
||||||
|
vm = VersionManager()
|
||||||
|
logging.info(f"当前版本: {vm.current_version}")
|
||||||
|
logging.info(f"当前平台: {vm.platform}")
|
||||||
|
|
||||||
|
# 测试获取最新版本
|
||||||
|
logging.info("\n=== 测试获取最新版本 ===")
|
||||||
|
latest = vm.get_latest_version()
|
||||||
|
logging.info(f"最新版本信息: {latest}")
|
||||||
|
|
||||||
|
# 测试检查更新
|
||||||
|
logging.info("\n=== 测试检查更新 ===")
|
||||||
|
update_info = vm.check_update()
|
||||||
|
logging.info(f"更新检查结果: {update_info}")
|
||||||
|
|
||||||
|
# 测试是否需要更新
|
||||||
|
logging.info("\n=== 测试是否需要更新 ===")
|
||||||
|
has_update, is_force, version_info = vm.needs_update()
|
||||||
|
logging.info(f"是否有更新: {has_update}")
|
||||||
|
logging.info(f"是否强制更新: {is_force}")
|
||||||
|
logging.info(f"版本信息: {version_info}")
|
||||||
|
|
||||||
|
# 如果有更新,测试下载功能
|
||||||
|
if has_update and version_info:
|
||||||
|
logging.info("\n=== 测试下载更新 ===")
|
||||||
|
download_url = version_info.get('download_url')
|
||||||
|
if download_url:
|
||||||
|
save_path = Path.home() / "Downloads" / "CursorHelper" / "test_update.exe"
|
||||||
|
save_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
logging.info(f"下载地址: {download_url}")
|
||||||
|
logging.info(f"保存路径: {save_path}")
|
||||||
|
|
||||||
|
success = vm.download_update(download_url, str(save_path))
|
||||||
|
logging.info(f"下载结果: {'成功' if success else '失败'}")
|
||||||
|
|
||||||
|
if success:
|
||||||
|
logging.info(f"文件大小: {save_path.stat().st_size} 字节")
|
||||||
|
else:
|
||||||
|
logging.warning("未找到下载地址")
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f"测试过程中发生错误: {str(e)}", exc_info=True)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
test_version_manager()
|
||||||
84
testbuild.bat
Normal file
84
testbuild.bat
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
@echo off
|
||||||
|
chcp 65001 >nul
|
||||||
|
setlocal EnableDelayedExpansion
|
||||||
|
|
||||||
|
REM 激活虚拟环境
|
||||||
|
call venv\Scripts\activate.bat
|
||||||
|
|
||||||
|
REM 确保安装了必要的包
|
||||||
|
pip install -r requirements.txt
|
||||||
|
|
||||||
|
REM 读取当前版本号
|
||||||
|
set /p VERSION=<version.txt
|
||||||
|
echo 当前正式版本: %VERSION%
|
||||||
|
|
||||||
|
REM 提取主版本号和次版本号 (3.4.4 -> 3.4)
|
||||||
|
for /f "tokens=1,2 delims=." %%a in ("%VERSION%") do (
|
||||||
|
set MAJOR_VERSION=%%a.%%b
|
||||||
|
)
|
||||||
|
echo 主版本目录: %MAJOR_VERSION%
|
||||||
|
|
||||||
|
REM 读取测试版本号(如果存在)
|
||||||
|
if exist testversion.txt (
|
||||||
|
set /p TEST_VERSION=<testversion.txt
|
||||||
|
) else (
|
||||||
|
set TEST_VERSION=0
|
||||||
|
)
|
||||||
|
|
||||||
|
REM 增加测试版本号
|
||||||
|
set /a TEST_VERSION+=1
|
||||||
|
echo !TEST_VERSION!>testversion.txt
|
||||||
|
echo 测试版本号: !TEST_VERSION!
|
||||||
|
|
||||||
|
REM 组合完整版本号
|
||||||
|
set FULL_VERSION=%VERSION%.!TEST_VERSION!
|
||||||
|
echo 完整版本号: !FULL_VERSION!
|
||||||
|
|
||||||
|
REM 创建测试版本输出目录
|
||||||
|
set TEST_DIR=dist\test\%MAJOR_VERSION%
|
||||||
|
if not exist "!TEST_DIR!" (
|
||||||
|
mkdir "!TEST_DIR!"
|
||||||
|
echo 创建目录: !TEST_DIR!
|
||||||
|
)
|
||||||
|
|
||||||
|
REM 清理旧文件
|
||||||
|
if exist "dist\听泉cursor助手%VERSION%.exe" del "dist\听泉cursor助手%VERSION%.exe"
|
||||||
|
if exist "build" rmdir /s /q "build"
|
||||||
|
|
||||||
|
REM 执行打包
|
||||||
|
venv\Scripts\python.exe -m PyInstaller build_nezha.spec --clean
|
||||||
|
|
||||||
|
REM 检查源文件是否存在
|
||||||
|
echo 检查文件: dist\听泉cursor助手%VERSION%.exe
|
||||||
|
if not exist "dist\听泉cursor助手%VERSION%.exe" (
|
||||||
|
echo 错误: 打包后的文件不存在
|
||||||
|
echo 预期文件路径: dist\听泉cursor助手%VERSION%.exe
|
||||||
|
dir /b dist
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
REM 移动并重命名文件
|
||||||
|
echo 移动文件:
|
||||||
|
echo 源文件: dist\听泉cursor助手%VERSION%.exe
|
||||||
|
echo 目标文件: !TEST_DIR!\听泉cursor助手v!FULL_VERSION!.exe
|
||||||
|
move "dist\听泉cursor助手%VERSION%.exe" "!TEST_DIR!\听泉cursor助手v!FULL_VERSION!.exe"
|
||||||
|
if errorlevel 1 (
|
||||||
|
echo 移动文件失败,请检查:
|
||||||
|
echo 1. 源文件是否存在: dist\听泉cursor助手%VERSION%.exe
|
||||||
|
echo 2. 目标目录是否可写: !TEST_DIR!
|
||||||
|
echo 3. 目标文件是否已存在: !TEST_DIR!\听泉cursor助手v!FULL_VERSION!.exe
|
||||||
|
dir /b dist
|
||||||
|
dir /b "!TEST_DIR!"
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo 测试版本构建完成!
|
||||||
|
echo 版本号: v!FULL_VERSION!
|
||||||
|
echo 文件位置: !TEST_DIR!\听泉cursor助手v!FULL_VERSION!.exe
|
||||||
|
|
||||||
|
REM 退出虚拟环境
|
||||||
|
deactivate
|
||||||
|
pause
|
||||||
@@ -4,8 +4,15 @@ import logging
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
|
"""配置类"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.api_base_url = "https://cursorapi.nosqli.com/admin"
|
self.base_url = "https://cursorapi.nosqli.com"
|
||||||
|
self.api_endpoints = {
|
||||||
|
"activate": f"{self.base_url}/admin/api.member/activate",
|
||||||
|
"status": f"{self.base_url}/admin/api.member/status",
|
||||||
|
"get_unused": f"{self.base_url}/admin/api.account/getUnused"
|
||||||
|
}
|
||||||
self.config_dir = Path(os.path.expanduser("~")) / ".cursor_switcher"
|
self.config_dir = Path(os.path.expanduser("~")) / ".cursor_switcher"
|
||||||
self.config_file = self.config_dir / "config.json"
|
self.config_file = self.config_dir / "config.json"
|
||||||
self.member_file = self.config_dir / "member.json"
|
self.member_file = self.config_dir / "member.json"
|
||||||
@@ -65,3 +72,14 @@ class Config:
|
|||||||
with open(self.config_file, "w", encoding="utf-8") as f:
|
with open(self.config_file, "w", encoding="utf-8") as f:
|
||||||
json.dump(config, f, indent=2, ensure_ascii=False)
|
json.dump(config, f, indent=2, ensure_ascii=False)
|
||||||
self.api_token = api_token
|
self.api_token = api_token
|
||||||
|
|
||||||
|
def get_api_url(self, endpoint_name: str) -> str:
|
||||||
|
"""获取API端点URL
|
||||||
|
|
||||||
|
Args:
|
||||||
|
endpoint_name: 端点名称
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
str: 完整的API URL
|
||||||
|
"""
|
||||||
|
return self.api_endpoints.get(endpoint_name, "")
|
||||||
@@ -1,8 +1,12 @@
|
|||||||
import os
|
import os
|
||||||
import winreg
|
import winreg
|
||||||
import logging
|
import logging
|
||||||
|
import shutil
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import uuid
|
import uuid
|
||||||
|
from datetime import datetime
|
||||||
|
import json
|
||||||
|
import hashlib
|
||||||
|
|
||||||
class CursorRegistry:
|
class CursorRegistry:
|
||||||
"""Cursor注册表操作工具类"""
|
"""Cursor注册表操作工具类"""
|
||||||
@@ -10,53 +14,61 @@ class CursorRegistry:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.cursor_path = Path(os.path.expanduser("~")) / "AppData" / "Local" / "Programs" / "Cursor"
|
self.cursor_path = Path(os.path.expanduser("~")) / "AppData" / "Local" / "Programs" / "Cursor"
|
||||||
self.app_path = self.cursor_path / "resources" / "app"
|
self.app_path = self.cursor_path / "resources" / "app"
|
||||||
self.machine_guid_path = r"SOFTWARE\Microsoft\Cryptography"
|
|
||||||
self.machine_guid_name = "MachineGuid"
|
|
||||||
|
|
||||||
def refresh_registry(self) -> bool:
|
def update_machine_guid(self) -> bool:
|
||||||
"""刷新注册表
|
"""更新系统的 MachineGuid
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
bool: 是否成功
|
bool: 是否成功
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
# 生成新的GUID
|
# 生成新的 GUID
|
||||||
new_guid = str(uuid.uuid4())
|
new_guid = str(uuid.uuid4())
|
||||||
|
registry_path = r"SOFTWARE\Microsoft\Cryptography"
|
||||||
|
|
||||||
# 修改 MachineGuid
|
|
||||||
try:
|
try:
|
||||||
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, self.machine_guid_path, 0, winreg.KEY_ALL_ACCESS) as key:
|
# 使用管理员权限打开注册表项
|
||||||
winreg.SetValueEx(key, self.machine_guid_name, 0, winreg.REG_SZ, new_guid)
|
key = None
|
||||||
logging.info(f"更新 MachineGuid 成功: {new_guid}")
|
try:
|
||||||
except Exception as e:
|
# 先尝试直接打开读取权限
|
||||||
logging.error(f"更新 MachineGuid 失败: {str(e)}")
|
key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, registry_path, 0,
|
||||||
return False
|
winreg.KEY_READ | winreg.KEY_WOW64_64KEY)
|
||||||
|
# 读取原始值并备份
|
||||||
|
original_guid = winreg.QueryValueEx(key, "MachineGuid")[0]
|
||||||
|
winreg.CloseKey(key)
|
||||||
|
|
||||||
# 获取Cursor安装路径
|
# 备份原始 MachineGuid
|
||||||
cursor_exe = self.cursor_path / "Cursor.exe"
|
backup_dir = Path(os.getenv('APPDATA')) / "Cursor" / "User" / "globalStorage" / "backups"
|
||||||
if not cursor_exe.exists():
|
backup_dir.mkdir(parents=True, exist_ok=True)
|
||||||
logging.error("未找到Cursor.exe")
|
backup_name = f"MachineGuid.backup_{datetime.now().strftime('%Y%m%d_%H%M%S')}"
|
||||||
return False
|
with open(backup_dir / backup_name, 'w', encoding='utf-8') as f:
|
||||||
|
f.write(original_guid)
|
||||||
|
logging.info(f"备份 MachineGuid 到: {backup_name}")
|
||||||
|
|
||||||
# 刷新注册表项
|
# 重新打开写入权限
|
||||||
try:
|
key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, registry_path, 0,
|
||||||
# 打开HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\Cursor
|
winreg.KEY_WRITE | winreg.KEY_WOW64_64KEY)
|
||||||
key_path = r"Software\Classes\Directory\Background\shell\Cursor"
|
except WindowsError:
|
||||||
with winreg.OpenKey(winreg.HKEY_CURRENT_USER, key_path, 0, winreg.KEY_WRITE) as key:
|
# 如果失败,尝试以管理员权限运行
|
||||||
winreg.SetValueEx(key, "Icon", 0, winreg.REG_SZ, str(cursor_exe))
|
import ctypes
|
||||||
|
if ctypes.windll.shell32.IsUserAnAdmin() == 0:
|
||||||
|
logging.warning("需要管理员权限来修改 MachineGuid")
|
||||||
|
return False
|
||||||
|
key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, registry_path, 0,
|
||||||
|
winreg.KEY_ALL_ACCESS | winreg.KEY_WOW64_64KEY)
|
||||||
|
|
||||||
# 打开command子键
|
# 设置新的 GUID
|
||||||
with winreg.OpenKey(winreg.HKEY_CURRENT_USER, key_path + r"\command", 0, winreg.KEY_WRITE) as key:
|
winreg.SetValueEx(key, "MachineGuid", 0, winreg.REG_SZ, new_guid)
|
||||||
winreg.SetValueEx(key, "", 0, winreg.REG_SZ, f'"{str(cursor_exe)}" "%V"')
|
winreg.CloseKey(key)
|
||||||
|
logging.info(f"更新系统 MachineGuid 成功: {new_guid}")
|
||||||
logging.info("注册表刷新成功")
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
except WindowsError as e:
|
except WindowsError as e:
|
||||||
logging.error(f"刷新注册表失败: {str(e)}")
|
logging.error(f"更新系统 MachineGuid 失败: {str(e)}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"刷新注册表失败: {str(e)}")
|
logging.error(f"更新 MachineGuid 过程出错: {str(e)}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def clean_registry(self) -> bool:
|
def clean_registry(self) -> bool:
|
||||||
@@ -66,21 +78,149 @@ class CursorRegistry:
|
|||||||
bool: 是否成功
|
bool: 是否成功
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
# 删除注册表项
|
# 需要清理的注册表路径列表
|
||||||
try:
|
registry_paths = [
|
||||||
key_path = r"Software\Classes\Directory\Background\shell\Cursor"
|
r"Software\Classes\Directory\Background\shell\Cursor\command",
|
||||||
winreg.DeleteKey(winreg.HKEY_CURRENT_USER, key_path + r"\command")
|
r"Software\Classes\Directory\Background\shell\Cursor",
|
||||||
winreg.DeleteKey(winreg.HKEY_CURRENT_USER, key_path)
|
r"Software\Cursor\Auth",
|
||||||
logging.info("注册表清理成功")
|
r"Software\Cursor\Updates",
|
||||||
return True
|
r"Software\Cursor"
|
||||||
|
]
|
||||||
|
|
||||||
except WindowsError as e:
|
for path in registry_paths:
|
||||||
if e.winerror == 2: # 找不到注册表项
|
try:
|
||||||
logging.info("注册表项不存在,无需清理")
|
winreg.DeleteKey(winreg.HKEY_CURRENT_USER, path)
|
||||||
return True
|
logging.info(f"删除注册表项成功: {path}")
|
||||||
logging.error(f"清理注册表失败: {str(e)}")
|
except WindowsError as e:
|
||||||
return False
|
if e.winerror == 2: # 找不到注册表项
|
||||||
|
logging.info(f"注册表项不存在,无需清理: {path}")
|
||||||
|
else:
|
||||||
|
logging.error(f"清理注册表失败: {path}, 错误: {str(e)}")
|
||||||
|
|
||||||
|
# 更新系统 MachineGuid
|
||||||
|
self.update_machine_guid()
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"清理注册表过程出错: {str(e)}")
|
logging.error(f"清理注册表过程出错: {str(e)}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def clean_cursor_files(self) -> bool:
|
||||||
|
"""清理Cursor相关的文件和目录,但保留重要的配置和历史记录"""
|
||||||
|
try:
|
||||||
|
local_app_data = Path(os.getenv('LOCALAPPDATA'))
|
||||||
|
app_data = Path(os.getenv('APPDATA'))
|
||||||
|
|
||||||
|
# 需要备份的文件
|
||||||
|
storage_path = app_data / "Cursor" / "User" / "globalStorage" / "storage.json"
|
||||||
|
backup_dir = app_data / "Cursor" / "User" / "globalStorage" / "backups"
|
||||||
|
global_storage_dir = app_data / "Cursor" / "User" / "globalStorage"
|
||||||
|
|
||||||
|
# 如果存在 storage.json,先备份
|
||||||
|
if storage_path.exists():
|
||||||
|
# 确保备份目录存在
|
||||||
|
backup_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
# 备份 storage.json
|
||||||
|
backup_name = f"storage.json.backup_{datetime.now().strftime('%Y%m%d_%H%M%S')}"
|
||||||
|
shutil.copy2(storage_path, backup_dir / backup_name)
|
||||||
|
logging.info(f"备份 storage.json 到: {backup_name}")
|
||||||
|
|
||||||
|
# 备份 global_storage 目录中的其他重要文件
|
||||||
|
if global_storage_dir.exists():
|
||||||
|
for item in global_storage_dir.iterdir():
|
||||||
|
if item.name != "storage.json" and item.name != "backups":
|
||||||
|
try:
|
||||||
|
backup_item_dir = backup_dir / f"other_files_{datetime.now().strftime('%Y%m%d_%H%M%S')}"
|
||||||
|
backup_item_dir.mkdir(exist_ok=True)
|
||||||
|
if item.is_file():
|
||||||
|
shutil.copy2(item, backup_item_dir / item.name)
|
||||||
|
logging.info(f"备份文件: {item.name}")
|
||||||
|
elif item.is_dir():
|
||||||
|
shutil.copytree(item, backup_item_dir / item.name)
|
||||||
|
logging.info(f"备份目录: {item.name}")
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f"备份 {item} 失败: {str(e)}")
|
||||||
|
|
||||||
|
# 读取当前内容
|
||||||
|
with open(storage_path, "r", encoding="utf-8") as f:
|
||||||
|
storage_data = json.load(f)
|
||||||
|
|
||||||
|
# 只修改 machineId,保持其他配置不变
|
||||||
|
if "telemetry.machineId" in storage_data:
|
||||||
|
# 生成新的 machineId
|
||||||
|
new_machine_id = hashlib.sha256(str(uuid.uuid4()).encode()).hexdigest()
|
||||||
|
storage_data["telemetry.machineId"] = new_machine_id
|
||||||
|
logging.info(f"更新 machineId: {new_machine_id}")
|
||||||
|
|
||||||
|
# 保存修改后的内容
|
||||||
|
with open(storage_path, "w", encoding="utf-8") as f:
|
||||||
|
json.dump(storage_data, f, indent=2)
|
||||||
|
|
||||||
|
# 处理 updater 目录
|
||||||
|
updater_path = local_app_data / "cursor-updater"
|
||||||
|
try:
|
||||||
|
# 如果是目录,则删除
|
||||||
|
if updater_path.is_dir():
|
||||||
|
shutil.rmtree(str(updater_path))
|
||||||
|
logging.info("删除 updater 目录成功")
|
||||||
|
# 如果是文件,则删除
|
||||||
|
if updater_path.is_file():
|
||||||
|
updater_path.unlink()
|
||||||
|
logging.info("删除 updater 文件成功")
|
||||||
|
# 创建同名空文件来阻止更新
|
||||||
|
updater_path.touch()
|
||||||
|
logging.info("创建 updater 空文件成功")
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f"处理 updater 文件失败: {str(e)}")
|
||||||
|
|
||||||
|
# 只清理缓存相关的路径
|
||||||
|
paths_to_clean = [
|
||||||
|
local_app_data / "Cursor" / "Cache"
|
||||||
|
]
|
||||||
|
|
||||||
|
for path in paths_to_clean:
|
||||||
|
try:
|
||||||
|
if path.is_dir():
|
||||||
|
shutil.rmtree(str(path), ignore_errors=True)
|
||||||
|
logging.info(f"删除目录成功: {path}")
|
||||||
|
elif path.exists():
|
||||||
|
path.unlink()
|
||||||
|
logging.info(f"删除文件成功: {path}")
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f"清理文件/目录失败: {path}, 错误: {str(e)}")
|
||||||
|
|
||||||
|
# 修复 Cursor 启动配置
|
||||||
|
self.fix_cursor_startup()
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f"清理文件过程出错: {str(e)}")
|
||||||
|
return False
|
||||||
|
|
||||||
|
def fix_cursor_startup(self) -> bool:
|
||||||
|
"""修复 Cursor 启动警告"""
|
||||||
|
try:
|
||||||
|
# 1. 修改 package.json 中的更新相关配置
|
||||||
|
if self.app_path.exists():
|
||||||
|
package_json = self.app_path / "package.json"
|
||||||
|
if package_json.exists():
|
||||||
|
with open(package_json, "r", encoding="utf-8") as f:
|
||||||
|
data = json.load(f)
|
||||||
|
|
||||||
|
# 只修改更新相关配置,与 GitHub 脚本保持一致
|
||||||
|
data["updateUrl"] = "" # 清空更新 URL
|
||||||
|
data["disableUpdate"] = True # 禁用更新
|
||||||
|
|
||||||
|
with open(package_json, "w", encoding="utf-8") as f:
|
||||||
|
json.dump(data, f, indent=2)
|
||||||
|
|
||||||
|
logging.info("已修复 Cursor 启动配置")
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f"修复 Cursor 启动配置失败: {str(e)}")
|
||||||
|
return False
|
||||||
303
utils/version_manager.py
Normal file
303
utils/version_manager.py
Normal file
@@ -0,0 +1,303 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import requests
|
||||||
|
from packaging import version
|
||||||
|
from typing import Optional, Dict, Any
|
||||||
|
import json
|
||||||
|
import logging
|
||||||
|
from urllib.parse import quote, unquote
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
class VersionManager:
|
||||||
|
"""版本管理器
|
||||||
|
|
||||||
|
错误码说明:
|
||||||
|
- 0: 成功
|
||||||
|
- 1: 一般性错误
|
||||||
|
- 401: 未授权或授权失败
|
||||||
|
- 404: 请求的资源不存在
|
||||||
|
- 500: 服务器内部错误
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.base_url = "https://cursorapi.nosqli.com"
|
||||||
|
# 获取项目根目录路径
|
||||||
|
self.root_path = Path(__file__).parent.parent
|
||||||
|
self.current_version = self._get_current_version()
|
||||||
|
self.platform = "windows" if sys.platform.startswith("win") else "mac" if sys.platform.startswith("darwin") else "linux"
|
||||||
|
|
||||||
|
def _get_current_version(self) -> str:
|
||||||
|
"""获取当前版本号"""
|
||||||
|
try:
|
||||||
|
version_file = self.root_path / "version.txt"
|
||||||
|
if not version_file.exists():
|
||||||
|
logging.error(f"版本文件不存在: {version_file}")
|
||||||
|
return "0.0.0"
|
||||||
|
|
||||||
|
with open(version_file, "r", encoding="utf-8") as f:
|
||||||
|
version = f.read().strip()
|
||||||
|
logging.info(f"当前版本: {version}")
|
||||||
|
return version
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f"读取版本号失败: {str(e)}")
|
||||||
|
return "0.0.0"
|
||||||
|
|
||||||
|
def _handle_response(self, response: requests.Response) -> Dict[str, Any]:
|
||||||
|
"""处理API响应
|
||||||
|
|
||||||
|
Args:
|
||||||
|
response: API响应对象
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Dict[str, Any]: 处理后的响应数据
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
Exception: API调用失败时抛出异常
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
data = response.json()
|
||||||
|
code = data.get("code")
|
||||||
|
msg = data.get("msg") or data.get("info", "未知错误") # 兼容 info 字段
|
||||||
|
|
||||||
|
if code == 0 or code == 1: # 兼容 code=1 的情况
|
||||||
|
# 处理空数据情况
|
||||||
|
if not data.get("data"):
|
||||||
|
logging.warning("API返回空数据")
|
||||||
|
return {
|
||||||
|
"code": 0,
|
||||||
|
"msg": msg,
|
||||||
|
"data": {
|
||||||
|
"has_update": False,
|
||||||
|
"is_force": False,
|
||||||
|
"version_info": None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
"code": 0, # 统一返回 code=0
|
||||||
|
"msg": msg,
|
||||||
|
"data": data.get("data")
|
||||||
|
}
|
||||||
|
elif code == 401:
|
||||||
|
raise Exception("未授权或授权失败")
|
||||||
|
elif code == 404:
|
||||||
|
raise Exception("请求的资源不存在")
|
||||||
|
elif code == 500:
|
||||||
|
raise Exception("服务器内部错误")
|
||||||
|
else:
|
||||||
|
raise Exception(msg)
|
||||||
|
|
||||||
|
except requests.exceptions.JSONDecodeError:
|
||||||
|
raise Exception("服务器响应格式错误")
|
||||||
|
|
||||||
|
def check_update(self) -> Dict[str, Any]:
|
||||||
|
"""检查是否有更新"""
|
||||||
|
try:
|
||||||
|
url = f"{self.base_url}/admin/api.version/check"
|
||||||
|
current_version = self.current_version.lstrip('v') # 移除可能存在的v前缀
|
||||||
|
|
||||||
|
params = {
|
||||||
|
"version": current_version,
|
||||||
|
"platform": self.platform
|
||||||
|
}
|
||||||
|
logging.info(f"正在请求: {url}")
|
||||||
|
logging.info(f"参数: {params}")
|
||||||
|
|
||||||
|
response = requests.get(
|
||||||
|
url,
|
||||||
|
params=params,
|
||||||
|
timeout=10
|
||||||
|
)
|
||||||
|
|
||||||
|
logging.info(f"状态码: {response.status_code}")
|
||||||
|
logging.info(f"响应头: {dict(response.headers)}")
|
||||||
|
logging.info(f"响应内容: {response.text}")
|
||||||
|
|
||||||
|
result = self._handle_response(response)
|
||||||
|
|
||||||
|
# 确保返回的数据包含版本信息
|
||||||
|
if result["code"] == 0 and result.get("data"):
|
||||||
|
data = result["data"]
|
||||||
|
if "version_info" in data:
|
||||||
|
version_info = data["version_info"]
|
||||||
|
# 确保版本号格式一致
|
||||||
|
if "version_no" in version_info:
|
||||||
|
version_info["version_no"] = version_info["version_no"].lstrip('v')
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
except requests.exceptions.Timeout:
|
||||||
|
logging.error("检查更新超时")
|
||||||
|
return {"code": -1, "msg": "请求超时,请检查网络连接", "data": None}
|
||||||
|
except requests.exceptions.ConnectionError as e:
|
||||||
|
logging.error(f"检查更新连接失败: {str(e)}")
|
||||||
|
return {"code": -1, "msg": "连接服务器失败,请检查网络连接", "data": None}
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f"检查更新失败: {str(e)}")
|
||||||
|
return {"code": -1, "msg": str(e), "data": None}
|
||||||
|
|
||||||
|
def get_latest_version(self) -> Dict[str, Any]:
|
||||||
|
"""获取最新版本信息"""
|
||||||
|
try:
|
||||||
|
url = f"{self.base_url}/admin/api.version/latest"
|
||||||
|
params = {"platform": self.platform}
|
||||||
|
logging.info(f"正在请求: {url}")
|
||||||
|
logging.info(f"参数: {params}")
|
||||||
|
|
||||||
|
response = requests.get(
|
||||||
|
url,
|
||||||
|
params=params,
|
||||||
|
timeout=10
|
||||||
|
)
|
||||||
|
|
||||||
|
logging.info(f"状态码: {response.status_code}")
|
||||||
|
logging.info(f"响应头: {dict(response.headers)}")
|
||||||
|
logging.info(f"响应内容: {response.text}")
|
||||||
|
|
||||||
|
return self._handle_response(response)
|
||||||
|
except requests.exceptions.Timeout:
|
||||||
|
logging.error("获取最新版本超时")
|
||||||
|
return {"code": -1, "msg": "请求超时,请检查网络连接", "data": None}
|
||||||
|
except requests.exceptions.ConnectionError as e:
|
||||||
|
logging.error(f"获取最新版本连接失败: {str(e)}")
|
||||||
|
return {"code": -1, "msg": "连接服务器失败,请检查网络连接", "data": None}
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f"获取最新版本失败: {str(e)}")
|
||||||
|
return {"code": -1, "msg": str(e), "data": None}
|
||||||
|
|
||||||
|
def needs_update(self) -> tuple[bool, bool, Optional[Dict[str, Any]]]:
|
||||||
|
"""检查是否需要更新
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
tuple: (是否有更新, 是否强制更新, 版本信息)
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
result = self.check_update()
|
||||||
|
if result["code"] == 0 and result["data"]:
|
||||||
|
data = result["data"]
|
||||||
|
version_info = data.get("version_info", {})
|
||||||
|
|
||||||
|
# 比较版本号(移除v前缀)
|
||||||
|
current = self.current_version.lstrip('v')
|
||||||
|
latest = version_info.get("version_no", "0.0.0").lstrip('v')
|
||||||
|
|
||||||
|
# 使用packaging.version进行版本比较
|
||||||
|
has_update = version.parse(latest) > version.parse(current)
|
||||||
|
|
||||||
|
return (
|
||||||
|
has_update,
|
||||||
|
bool(data.get("is_force")),
|
||||||
|
version_info
|
||||||
|
)
|
||||||
|
return False, False, None
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f"检查更新失败: {str(e)}")
|
||||||
|
return False, False, None
|
||||||
|
|
||||||
|
def download_update(self, download_url: str, save_path: str) -> tuple[bool, str]:
|
||||||
|
"""下载更新文件
|
||||||
|
|
||||||
|
Args:
|
||||||
|
download_url: 下载地址
|
||||||
|
save_path: 保存路径
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
tuple[bool, str]: (是否下载成功, 错误信息)
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
if not download_url:
|
||||||
|
error_msg = "下载地址为空,请联系管理员"
|
||||||
|
logging.error(error_msg)
|
||||||
|
return False, error_msg
|
||||||
|
|
||||||
|
# 处理下载地址中的中文字符
|
||||||
|
url_parts = download_url.split('/')
|
||||||
|
# 只对最后一部分(文件名)进行编码
|
||||||
|
url_parts[-1] = quote(url_parts[-1])
|
||||||
|
encoded_url = '/'.join(url_parts)
|
||||||
|
|
||||||
|
logging.info(f"原始下载地址: {download_url}")
|
||||||
|
logging.info(f"编码后的地址: {encoded_url}")
|
||||||
|
|
||||||
|
# 设置请求头,模拟浏览器行为
|
||||||
|
headers = {
|
||||||
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36',
|
||||||
|
'Accept': '*/*',
|
||||||
|
'Accept-Encoding': 'gzip, deflate, br',
|
||||||
|
'Connection': 'keep-alive'
|
||||||
|
}
|
||||||
|
|
||||||
|
response = requests.get(
|
||||||
|
encoded_url,
|
||||||
|
stream=True,
|
||||||
|
headers=headers,
|
||||||
|
timeout=30 # 增加下载超时时间
|
||||||
|
)
|
||||||
|
|
||||||
|
# 检查响应状态
|
||||||
|
if response.status_code == 404:
|
||||||
|
error_msg = "下载地址无效,请联系管理员更新下载地址"
|
||||||
|
logging.error(error_msg)
|
||||||
|
return False, error_msg
|
||||||
|
|
||||||
|
response.raise_for_status()
|
||||||
|
|
||||||
|
total_size = int(response.headers.get('content-length', 0))
|
||||||
|
if total_size == 0:
|
||||||
|
error_msg = "无法获取文件大小,下载地址可能无效,请联系管理员"
|
||||||
|
logging.error(error_msg)
|
||||||
|
return False, error_msg
|
||||||
|
|
||||||
|
block_size = 8192
|
||||||
|
downloaded_size = 0
|
||||||
|
|
||||||
|
logging.info(f"开始下载文件,总大小: {total_size} 字节")
|
||||||
|
|
||||||
|
with open(save_path, 'wb') as f:
|
||||||
|
for chunk in response.iter_content(chunk_size=block_size):
|
||||||
|
if chunk:
|
||||||
|
f.write(chunk)
|
||||||
|
downloaded_size += len(chunk)
|
||||||
|
# 打印下载进度
|
||||||
|
if total_size > 0:
|
||||||
|
progress = (downloaded_size / total_size) * 100
|
||||||
|
logging.info(f"下载进度: {progress:.2f}%")
|
||||||
|
|
||||||
|
# 验证文件大小
|
||||||
|
actual_size = os.path.getsize(save_path)
|
||||||
|
if actual_size != total_size:
|
||||||
|
error_msg = f"文件下载不完整: 预期{total_size}字节,实际{actual_size}字节,请重试或联系管理员"
|
||||||
|
logging.error(error_msg)
|
||||||
|
# 删除不完整文件
|
||||||
|
try:
|
||||||
|
os.remove(save_path)
|
||||||
|
logging.info(f"已删除不完整的下载文件: {save_path}")
|
||||||
|
except Exception as clean_e:
|
||||||
|
logging.error(f"清理不完整文件失败: {str(clean_e)}")
|
||||||
|
return False, error_msg
|
||||||
|
|
||||||
|
logging.info(f"文件下载完成: {save_path}")
|
||||||
|
return True, "下载成功"
|
||||||
|
|
||||||
|
except requests.exceptions.Timeout:
|
||||||
|
error_msg = "下载超时,请检查网络连接后重试"
|
||||||
|
logging.error(error_msg)
|
||||||
|
return False, error_msg
|
||||||
|
except requests.exceptions.ConnectionError as e:
|
||||||
|
error_msg = "下载连接失败,请检查网络连接后重试"
|
||||||
|
logging.error(f"{error_msg}: {str(e)}")
|
||||||
|
return False, error_msg
|
||||||
|
except requests.exceptions.HTTPError as e:
|
||||||
|
error_msg = f"下载地址无效或服务器错误,请联系管理员 (HTTP {e.response.status_code})"
|
||||||
|
logging.error(error_msg)
|
||||||
|
return False, error_msg
|
||||||
|
except Exception as e:
|
||||||
|
error_msg = f"下载失败,请联系管理员: {str(e)}"
|
||||||
|
logging.error(error_msg)
|
||||||
|
# 如果下载失败,删除可能存在的不完整文件
|
||||||
|
try:
|
||||||
|
if os.path.exists(save_path):
|
||||||
|
os.remove(save_path)
|
||||||
|
logging.info(f"已删除不完整的下载文件: {save_path}")
|
||||||
|
except Exception as clean_e:
|
||||||
|
logging.error(f"清理不完整文件失败: {str(clean_e)}")
|
||||||
|
return False, error_msg
|
||||||
@@ -1 +1 @@
|
|||||||
3.0.9
|
3.4.5
|
||||||
127
version_check.log
Normal file
127
version_check.log
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
2025-02-13 13:30:48,255 - INFO - <20><>ǰ<EFBFBD>汾: 3.4.1
|
||||||
|
2025-02-13 13:30:48,255 - INFO - <20><>ǰƽ̨: windows
|
||||||
|
2025-02-13 13:30:48,255 - INFO -
|
||||||
|
=== <20><><EFBFBD>Ի<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>°汾 ===
|
||||||
|
2025-02-13 13:30:49,989 - INFO - <20><><EFBFBD>°汾<C2B0><E6B1BE>Ϣ: {'code': 0, 'info': '<27><><EFBFBD>ް汾<DEB0><E6B1BE>Ϣ', 'data': {}}
|
||||||
|
2025-02-13 13:30:49,989 - INFO -
|
||||||
|
=== <20><><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ===
|
||||||
|
2025-02-13 13:30:51,712 - ERROR - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>: δ֪<CEB4><D6AA><EFBFBD><EFBFBD>
|
||||||
|
2025-02-13 13:30:51,713 - INFO - <20><><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: {'code': -1, 'msg': 'δ֪<CEB4><D6AA><EFBFBD><EFBFBD>', 'data': None}
|
||||||
|
2025-02-13 13:30:51,713 - INFO -
|
||||||
|
=== <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD> ===
|
||||||
|
2025-02-13 13:30:53,394 - ERROR - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>: δ֪<CEB4><D6AA><EFBFBD><EFBFBD>
|
||||||
|
2025-02-13 13:30:53,395 - INFO - <20>Ƿ<EFBFBD><C7B7>и<EFBFBD><D0B8><EFBFBD>: False
|
||||||
|
2025-02-13 13:30:53,395 - INFO - <20>Ƿ<EFBFBD>ǿ<EFBFBD>Ƹ<EFBFBD><C6B8><EFBFBD>: False
|
||||||
|
2025-02-13 13:30:53,395 - INFO - <20>汾<EFBFBD><E6B1BE>Ϣ: None
|
||||||
|
2025-02-13 13:49:13,952 - INFO - <20><>ǰ<EFBFBD>汾: 3.4.1
|
||||||
|
2025-02-13 13:49:13,952 - INFO - <20><>ǰƽ̨: windows
|
||||||
|
2025-02-13 13:49:13,952 - INFO -
|
||||||
|
=== <20><><EFBFBD>Ի<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>°汾 ===
|
||||||
|
2025-02-13 13:49:15,718 - ERROR - <20><>ȡ<EFBFBD><C8A1><EFBFBD>°汾ʧ<E6B1BE><CAA7>: δ֪<CEB4><D6AA><EFBFBD><EFBFBD>
|
||||||
|
2025-02-13 13:49:15,720 - INFO - <20><><EFBFBD>°汾<C2B0><E6B1BE>Ϣ: {'code': -1, 'msg': 'δ֪<CEB4><D6AA><EFBFBD><EFBFBD>', 'data': None}
|
||||||
|
2025-02-13 13:49:15,720 - INFO -
|
||||||
|
=== <20><><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ===
|
||||||
|
2025-02-13 13:49:17,452 - ERROR - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>: δ֪<CEB4><D6AA><EFBFBD><EFBFBD>
|
||||||
|
2025-02-13 13:49:17,454 - INFO - <20><><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: {'code': -1, 'msg': 'δ֪<CEB4><D6AA><EFBFBD><EFBFBD>', 'data': None}
|
||||||
|
2025-02-13 13:49:17,454 - INFO -
|
||||||
|
=== <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD> ===
|
||||||
|
2025-02-13 13:49:19,277 - ERROR - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>: δ֪<CEB4><D6AA><EFBFBD><EFBFBD>
|
||||||
|
2025-02-13 13:49:19,278 - INFO - <20>Ƿ<EFBFBD><C7B7>и<EFBFBD><D0B8><EFBFBD>: False
|
||||||
|
2025-02-13 13:49:19,278 - INFO - <20>Ƿ<EFBFBD>ǿ<EFBFBD>Ƹ<EFBFBD><C6B8><EFBFBD>: False
|
||||||
|
2025-02-13 13:49:19,278 - INFO - <20>汾<EFBFBD><E6B1BE>Ϣ: None
|
||||||
|
2025-02-13 13:53:02,577 - INFO - <20><>ǰ<EFBFBD>汾: 3.4.1
|
||||||
|
2025-02-13 13:53:02,577 - INFO - <20><>ǰƽ̨: windows
|
||||||
|
2025-02-13 13:53:02,577 - INFO -
|
||||||
|
=== <20><><EFBFBD>Ի<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>°汾 ===
|
||||||
|
2025-02-13 13:53:02,578 - INFO - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: https://cursorapi.nosqli.com/admin/api.version/latest
|
||||||
|
2025-02-13 13:53:02,578 - INFO - <20><><EFBFBD><EFBFBD>: {'platform': 'windows'}
|
||||||
|
2025-02-13 13:53:04,292 - INFO - ״̬<D7B4><CCAC>: 200
|
||||||
|
2025-02-13 13:53:04,292 - INFO - <20><>Ӧͷ: {'Server': 'nginx', 'Date': 'Thu, 13 Feb 2025 05:53:02 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Vary': 'Accept-Encoding', 'X-Frame-Options': 'sameorigin', 'Set-Cookie': 'ssid=c6053c5e6170796bf1c5dde92415b981; path=/; secure; HttpOnly, lang=zh-cn; path=/; secure; HttpOnly', 'Strict-Transport-Security': 'max-age=31536000', 'Alt-Svc': 'quic=":443"; h3=":443"; h3-29=":443"; h3-27=":443";h3-25=":443"; h3-T050=":443"; h3-Q050=":443";h3-Q049=":443";h3-Q048=":443"; h3-Q046=":443"; h3-Q043=":443"', 'Content-Encoding': 'gzip'}
|
||||||
|
2025-02-13 13:53:04,292 - INFO - <20><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>: {"code":1,"info":"<22><>ȡ<EFBFBD>ɹ<EFBFBD>","data":{"id":1,"version_no":"3.4.1.4","version_name":"cursor<6F><72><EFBFBD><EFBFBD>","download_url":"https:\/\/cursorapi.nosqli.com\/upload\/<2F><>Ȫcursor<6F><72><EFBFBD><EFBFBD>v3.4.1.4.exe","is_force":0,"min_version":"","platform":"all","status":1,"description":"","create_time":"2025-02-13 13:32:35","update_time":"2025-02-13 13:32:35"}}
|
||||||
|
2025-02-13 13:53:04,292 - ERROR - <20><>ȡ<EFBFBD><C8A1><EFBFBD>°汾ʧ<E6B1BE><CAA7>: δ֪<CEB4><D6AA><EFBFBD><EFBFBD>
|
||||||
|
2025-02-13 13:53:04,294 - INFO - <20><><EFBFBD>°汾<C2B0><E6B1BE>Ϣ: {'code': -1, 'msg': 'δ֪<CEB4><D6AA><EFBFBD><EFBFBD>', 'data': None}
|
||||||
|
2025-02-13 13:53:04,294 - INFO -
|
||||||
|
=== <20><><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ===
|
||||||
|
2025-02-13 13:53:04,294 - INFO - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: https://cursorapi.nosqli.com/admin/api.version/check
|
||||||
|
2025-02-13 13:53:04,294 - INFO - <20><><EFBFBD><EFBFBD>: {'version': '3.4.1', 'platform': 'windows'}
|
||||||
|
2025-02-13 13:53:06,028 - INFO - ״̬<D7B4><CCAC>: 200
|
||||||
|
2025-02-13 13:53:06,028 - INFO - <20><>Ӧͷ: {'Server': 'nginx', 'Date': 'Thu, 13 Feb 2025 05:53:04 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Vary': 'Accept-Encoding', 'X-Frame-Options': 'sameorigin', 'Set-Cookie': 'ssid=cbb7943860ca50662d842719c53e7c73; path=/; secure; HttpOnly, lang=zh-cn; path=/; secure; HttpOnly', 'Strict-Transport-Security': 'max-age=31536000', 'Alt-Svc': 'quic=":443"; h3=":443"; h3-29=":443"; h3-27=":443";h3-25=":443"; h3-T050=":443"; h3-Q050=":443";h3-Q049=":443";h3-Q048=":443"; h3-Q046=":443"; h3-Q043=":443"', 'Content-Encoding': 'gzip'}
|
||||||
|
2025-02-13 13:53:06,028 - INFO - <20><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>: {"code":1,"info":"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>","data":{"has_update":true,"is_force":0,"version_info":{"id":1,"version_no":"3.4.1.4","version_name":"cursor<6F><72><EFBFBD><EFBFBD>","download_url":"https:\/\/cursorapi.nosqli.com\/upload\/<2F><>Ȫcursor<6F><72><EFBFBD><EFBFBD>v3.4.1.4.exe","is_force":0,"min_version":"","platform":"all","status":1,"description":"","create_time":"2025-02-13 13:32:35","update_time":"2025-02-13 13:32:35"}}}
|
||||||
|
2025-02-13 13:53:06,028 - ERROR - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>: δ֪<CEB4><D6AA><EFBFBD><EFBFBD>
|
||||||
|
2025-02-13 13:53:06,029 - INFO - <20><><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: {'code': -1, 'msg': 'δ֪<CEB4><D6AA><EFBFBD><EFBFBD>', 'data': None}
|
||||||
|
2025-02-13 13:53:06,029 - INFO -
|
||||||
|
=== <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD> ===
|
||||||
|
2025-02-13 13:53:06,029 - INFO - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: https://cursorapi.nosqli.com/admin/api.version/check
|
||||||
|
2025-02-13 13:53:06,029 - INFO - <20><><EFBFBD><EFBFBD>: {'version': '3.4.1', 'platform': 'windows'}
|
||||||
|
2025-02-13 13:53:07,770 - INFO - ״̬<D7B4><CCAC>: 200
|
||||||
|
2025-02-13 13:53:07,770 - INFO - <20><>Ӧͷ: {'Server': 'nginx', 'Date': 'Thu, 13 Feb 2025 05:53:05 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Vary': 'Accept-Encoding', 'X-Frame-Options': 'sameorigin', 'Set-Cookie': 'ssid=c8004bac4b2d4c5054b69dca0311d6f7; path=/; secure; HttpOnly, lang=zh-cn; path=/; secure; HttpOnly', 'Strict-Transport-Security': 'max-age=31536000', 'Alt-Svc': 'quic=":443"; h3=":443"; h3-29=":443"; h3-27=":443";h3-25=":443"; h3-T050=":443"; h3-Q050=":443";h3-Q049=":443";h3-Q048=":443"; h3-Q046=":443"; h3-Q043=":443"', 'Content-Encoding': 'gzip'}
|
||||||
|
2025-02-13 13:53:07,770 - INFO - <20><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>: {"code":1,"info":"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>","data":{"has_update":true,"is_force":0,"version_info":{"id":1,"version_no":"3.4.1.4","version_name":"cursor<6F><72><EFBFBD><EFBFBD>","download_url":"https:\/\/cursorapi.nosqli.com\/upload\/<2F><>Ȫcursor<6F><72><EFBFBD><EFBFBD>v3.4.1.4.exe","is_force":0,"min_version":"","platform":"all","status":1,"description":"","create_time":"2025-02-13 13:32:35","update_time":"2025-02-13 13:32:35"}}}
|
||||||
|
2025-02-13 13:53:07,771 - ERROR - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>: δ֪<CEB4><D6AA><EFBFBD><EFBFBD>
|
||||||
|
2025-02-13 13:53:07,774 - INFO - <20>Ƿ<EFBFBD><C7B7>и<EFBFBD><D0B8><EFBFBD>: False
|
||||||
|
2025-02-13 13:53:07,774 - INFO - <20>Ƿ<EFBFBD>ǿ<EFBFBD>Ƹ<EFBFBD><C6B8><EFBFBD>: False
|
||||||
|
2025-02-13 13:53:07,774 - INFO - <20>汾<EFBFBD><E6B1BE>Ϣ: None
|
||||||
|
2025-02-13 13:53:33,800 - INFO - <20><>ǰ<EFBFBD>汾: 3.4.1
|
||||||
|
2025-02-13 13:53:33,801 - INFO - <20><>ǰƽ̨: windows
|
||||||
|
2025-02-13 13:53:33,801 - INFO -
|
||||||
|
=== <20><><EFBFBD>Ի<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>°汾 ===
|
||||||
|
2025-02-13 13:53:33,801 - INFO - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: https://cursorapi.nosqli.com/admin/api.version/latest
|
||||||
|
2025-02-13 13:53:33,801 - INFO - <20><><EFBFBD><EFBFBD>: {'platform': 'windows'}
|
||||||
|
2025-02-13 13:53:35,509 - INFO - ״̬<D7B4><CCAC>: 200
|
||||||
|
2025-02-13 13:53:35,510 - INFO - <20><>Ӧͷ: {'Server': 'nginx', 'Date': 'Thu, 13 Feb 2025 05:53:33 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Vary': 'Accept-Encoding', 'X-Frame-Options': 'sameorigin', 'Set-Cookie': 'ssid=16d07427624c6aaf6c89254d173fe273; path=/; secure; HttpOnly, lang=zh-cn; path=/; secure; HttpOnly', 'Strict-Transport-Security': 'max-age=31536000', 'Alt-Svc': 'quic=":443"; h3=":443"; h3-29=":443"; h3-27=":443";h3-25=":443"; h3-T050=":443"; h3-Q050=":443";h3-Q049=":443";h3-Q048=":443"; h3-Q046=":443"; h3-Q043=":443"', 'Content-Encoding': 'gzip'}
|
||||||
|
2025-02-13 13:53:35,510 - INFO - <20><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>: {"code":1,"info":"<22><>ȡ<EFBFBD>ɹ<EFBFBD>","data":{"id":1,"version_no":"3.4.1.4","version_name":"cursor<6F><72><EFBFBD><EFBFBD>","download_url":"https:\/\/cursorapi.nosqli.com\/upload\/<2F><>Ȫcursor<6F><72><EFBFBD><EFBFBD>v3.4.1.4.exe","is_force":0,"min_version":"","platform":"all","status":1,"description":"","create_time":"2025-02-13 13:32:35","update_time":"2025-02-13 13:32:35"}}
|
||||||
|
2025-02-13 13:53:35,510 - ERROR - <20><>ȡ<EFBFBD><C8A1><EFBFBD>°汾ʧ<E6B1BE><CAA7>: δ֪<CEB4><D6AA><EFBFBD><EFBFBD>
|
||||||
|
2025-02-13 13:53:35,513 - INFO - <20><><EFBFBD>°汾<C2B0><E6B1BE>Ϣ: {'code': -1, 'msg': 'δ֪<CEB4><D6AA><EFBFBD><EFBFBD>', 'data': None}
|
||||||
|
2025-02-13 13:53:35,513 - INFO -
|
||||||
|
=== <20><><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ===
|
||||||
|
2025-02-13 13:53:35,513 - INFO - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: https://cursorapi.nosqli.com/admin/api.version/check
|
||||||
|
2025-02-13 13:53:35,513 - INFO - <20><><EFBFBD><EFBFBD>: {'version': '3.4.1', 'platform': 'windows'}
|
||||||
|
2025-02-13 13:53:37,280 - INFO - ״̬<D7B4><CCAC>: 200
|
||||||
|
2025-02-13 13:53:37,281 - INFO - <20><>Ӧͷ: {'Server': 'nginx', 'Date': 'Thu, 13 Feb 2025 05:53:35 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Vary': 'Accept-Encoding', 'X-Frame-Options': 'sameorigin', 'Set-Cookie': 'ssid=489a85b5766d7a30c4ba9dccda6f4967; path=/; secure; HttpOnly, lang=zh-cn; path=/; secure; HttpOnly', 'Strict-Transport-Security': 'max-age=31536000', 'Alt-Svc': 'quic=":443"; h3=":443"; h3-29=":443"; h3-27=":443";h3-25=":443"; h3-T050=":443"; h3-Q050=":443";h3-Q049=":443";h3-Q048=":443"; h3-Q046=":443"; h3-Q043=":443"', 'Content-Encoding': 'gzip'}
|
||||||
|
2025-02-13 13:53:37,281 - INFO - <20><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>: {"code":1,"info":"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>","data":{"has_update":true,"is_force":0,"version_info":{"id":1,"version_no":"3.4.1.4","version_name":"cursor<6F><72><EFBFBD><EFBFBD>","download_url":"https:\/\/cursorapi.nosqli.com\/upload\/<2F><>Ȫcursor<6F><72><EFBFBD><EFBFBD>v3.4.1.4.exe","is_force":0,"min_version":"","platform":"all","status":1,"description":"","create_time":"2025-02-13 13:32:35","update_time":"2025-02-13 13:32:35"}}}
|
||||||
|
2025-02-13 13:53:37,281 - ERROR - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>: δ֪<CEB4><D6AA><EFBFBD><EFBFBD>
|
||||||
|
2025-02-13 13:53:37,283 - INFO - <20><><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: {'code': -1, 'msg': 'δ֪<CEB4><D6AA><EFBFBD><EFBFBD>', 'data': None}
|
||||||
|
2025-02-13 13:53:37,283 - INFO -
|
||||||
|
=== <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD> ===
|
||||||
|
2025-02-13 13:53:37,283 - INFO - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: https://cursorapi.nosqli.com/admin/api.version/check
|
||||||
|
2025-02-13 13:53:37,284 - INFO - <20><><EFBFBD><EFBFBD>: {'version': '3.4.1', 'platform': 'windows'}
|
||||||
|
2025-02-13 13:53:39,003 - INFO - ״̬<D7B4><CCAC>: 200
|
||||||
|
2025-02-13 13:53:39,003 - INFO - <20><>Ӧͷ: {'Server': 'nginx', 'Date': 'Thu, 13 Feb 2025 05:53:37 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Vary': 'Accept-Encoding', 'X-Frame-Options': 'sameorigin', 'Set-Cookie': 'ssid=b3619976145458f7ffd03d0438958a73; path=/; secure; HttpOnly, lang=zh-cn; path=/; secure; HttpOnly', 'Strict-Transport-Security': 'max-age=31536000', 'Alt-Svc': 'quic=":443"; h3=":443"; h3-29=":443"; h3-27=":443";h3-25=":443"; h3-T050=":443"; h3-Q050=":443";h3-Q049=":443";h3-Q048=":443"; h3-Q046=":443"; h3-Q043=":443"', 'Content-Encoding': 'gzip'}
|
||||||
|
2025-02-13 13:53:39,004 - INFO - <20><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>: {"code":1,"info":"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>","data":{"has_update":true,"is_force":0,"version_info":{"id":1,"version_no":"3.4.1.4","version_name":"cursor<6F><72><EFBFBD><EFBFBD>","download_url":"https:\/\/cursorapi.nosqli.com\/upload\/<2F><>Ȫcursor<6F><72><EFBFBD><EFBFBD>v3.4.1.4.exe","is_force":0,"min_version":"","platform":"all","status":1,"description":"","create_time":"2025-02-13 13:32:35","update_time":"2025-02-13 13:32:35"}}}
|
||||||
|
2025-02-13 13:53:39,004 - ERROR - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>: δ֪<CEB4><D6AA><EFBFBD><EFBFBD>
|
||||||
|
2025-02-13 13:53:39,005 - INFO - <20>Ƿ<EFBFBD><C7B7>и<EFBFBD><D0B8><EFBFBD>: False
|
||||||
|
2025-02-13 13:53:39,005 - INFO - <20>Ƿ<EFBFBD>ǿ<EFBFBD>Ƹ<EFBFBD><C6B8><EFBFBD>: False
|
||||||
|
2025-02-13 13:53:39,005 - INFO - <20>汾<EFBFBD><E6B1BE>Ϣ: None
|
||||||
|
2025-02-13 13:54:24,914 - INFO - <20><>ǰ<EFBFBD>汾: 3.4.1
|
||||||
|
2025-02-13 13:54:24,915 - INFO - <20><>ǰƽ̨: windows
|
||||||
|
2025-02-13 13:54:24,915 - INFO -
|
||||||
|
=== <20><><EFBFBD>Ի<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>°汾 ===
|
||||||
|
2025-02-13 13:54:24,915 - INFO - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: https://cursorapi.nosqli.com/admin/api.version/latest
|
||||||
|
2025-02-13 13:54:24,915 - INFO - <20><><EFBFBD><EFBFBD>: {'platform': 'windows'}
|
||||||
|
2025-02-13 13:54:26,652 - INFO - ״̬<D7B4><CCAC>: 200
|
||||||
|
2025-02-13 13:54:26,652 - INFO - <20><>Ӧͷ: {'Server': 'nginx', 'Date': 'Thu, 13 Feb 2025 05:54:24 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Vary': 'Accept-Encoding', 'X-Frame-Options': 'sameorigin', 'Set-Cookie': 'ssid=fc779e7ca81172e81a4d03cab86876a1; path=/; secure; HttpOnly, lang=zh-cn; path=/; secure; HttpOnly', 'Strict-Transport-Security': 'max-age=31536000', 'Alt-Svc': 'quic=":443"; h3=":443"; h3-29=":443"; h3-27=":443";h3-25=":443"; h3-T050=":443"; h3-Q050=":443";h3-Q049=":443";h3-Q048=":443"; h3-Q046=":443"; h3-Q043=":443"', 'Content-Encoding': 'gzip'}
|
||||||
|
2025-02-13 13:54:26,652 - INFO - <20><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>: {"code":1,"info":"<22><>ȡ<EFBFBD>ɹ<EFBFBD>","data":{"id":1,"version_no":"3.4.1.4","version_name":"cursor<6F><72><EFBFBD><EFBFBD>","download_url":"https:\/\/cursorapi.nosqli.com\/upload\/<2F><>Ȫcursor<6F><72><EFBFBD><EFBFBD>v3.4.1.4.exe","is_force":0,"min_version":"","platform":"all","status":1,"description":"","create_time":"2025-02-13 13:32:35","update_time":"2025-02-13 13:32:35"}}
|
||||||
|
2025-02-13 13:54:26,654 - INFO - <20><><EFBFBD>°汾<C2B0><E6B1BE>Ϣ: {'code': 0, 'msg': '<27><>ȡ<EFBFBD>ɹ<EFBFBD>', 'data': {'id': 1, 'version_no': '3.4.1.4', 'version_name': 'cursor<6F><72><EFBFBD><EFBFBD>', 'download_url': 'https://cursorapi.nosqli.com/upload/<2F><>Ȫcursor<6F><72><EFBFBD><EFBFBD>v3.4.1.4.exe', 'is_force': 0, 'min_version': '', 'platform': 'all', 'status': 1, 'description': '', 'create_time': '2025-02-13 13:32:35', 'update_time': '2025-02-13 13:32:35'}}
|
||||||
|
2025-02-13 13:54:26,654 - INFO -
|
||||||
|
=== <20><><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ===
|
||||||
|
2025-02-13 13:54:26,654 - INFO - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: https://cursorapi.nosqli.com/admin/api.version/check
|
||||||
|
2025-02-13 13:54:26,654 - INFO - <20><><EFBFBD><EFBFBD>: {'version': '3.4.1', 'platform': 'windows'}
|
||||||
|
2025-02-13 13:54:28,445 - INFO - ״̬<D7B4><CCAC>: 200
|
||||||
|
2025-02-13 13:54:28,445 - INFO - <20><>Ӧͷ: {'Server': 'nginx', 'Date': 'Thu, 13 Feb 2025 05:54:26 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Vary': 'Accept-Encoding', 'X-Frame-Options': 'sameorigin', 'Set-Cookie': 'ssid=f8a3f46919c8aaa4d8f34d361ea3386a; path=/; secure; HttpOnly, lang=zh-cn; path=/; secure; HttpOnly', 'Strict-Transport-Security': 'max-age=31536000', 'Alt-Svc': 'quic=":443"; h3=":443"; h3-29=":443"; h3-27=":443";h3-25=":443"; h3-T050=":443"; h3-Q050=":443";h3-Q049=":443";h3-Q048=":443"; h3-Q046=":443"; h3-Q043=":443"', 'Content-Encoding': 'gzip'}
|
||||||
|
2025-02-13 13:54:28,445 - INFO - <20><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>: {"code":1,"info":"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>","data":{"has_update":true,"is_force":0,"version_info":{"id":1,"version_no":"3.4.1.4","version_name":"cursor<6F><72><EFBFBD><EFBFBD>","download_url":"https:\/\/cursorapi.nosqli.com\/upload\/<2F><>Ȫcursor<6F><72><EFBFBD><EFBFBD>v3.4.1.4.exe","is_force":0,"min_version":"","platform":"all","status":1,"description":"","create_time":"2025-02-13 13:32:35","update_time":"2025-02-13 13:32:35"}}}
|
||||||
|
2025-02-13 13:54:28,447 - INFO - <20><><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: {'code': 0, 'msg': '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', 'data': {'has_update': True, 'is_force': 0, 'version_info': {'id': 1, 'version_no': '3.4.1.4', 'version_name': 'cursor<6F><72><EFBFBD><EFBFBD>', 'download_url': 'https://cursorapi.nosqli.com/upload/<2F><>Ȫcursor<6F><72><EFBFBD><EFBFBD>v3.4.1.4.exe', 'is_force': 0, 'min_version': '', 'platform': 'all', 'status': 1, 'description': '', 'create_time': '2025-02-13 13:32:35', 'update_time': '2025-02-13 13:32:35'}}}
|
||||||
|
2025-02-13 13:54:28,447 - INFO -
|
||||||
|
=== <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD> ===
|
||||||
|
2025-02-13 13:54:28,447 - INFO - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: https://cursorapi.nosqli.com/admin/api.version/check
|
||||||
|
2025-02-13 13:54:28,447 - INFO - <20><><EFBFBD><EFBFBD>: {'version': '3.4.1', 'platform': 'windows'}
|
||||||
|
2025-02-13 13:54:30,144 - INFO - ״̬<D7B4><CCAC>: 200
|
||||||
|
2025-02-13 13:54:30,145 - INFO - <20><>Ӧͷ: {'Server': 'nginx', 'Date': 'Thu, 13 Feb 2025 05:54:28 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Vary': 'Accept-Encoding', 'X-Frame-Options': 'sameorigin', 'Set-Cookie': 'ssid=169a8bdefde9a16f0e9f3e32da4d8ba5; path=/; secure; HttpOnly, lang=zh-cn; path=/; secure; HttpOnly', 'Strict-Transport-Security': 'max-age=31536000', 'Alt-Svc': 'quic=":443"; h3=":443"; h3-29=":443"; h3-27=":443";h3-25=":443"; h3-T050=":443"; h3-Q050=":443";h3-Q049=":443";h3-Q048=":443"; h3-Q046=":443"; h3-Q043=":443"', 'Content-Encoding': 'gzip'}
|
||||||
|
2025-02-13 13:54:30,145 - INFO - <20><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>: {"code":1,"info":"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>","data":{"has_update":true,"is_force":0,"version_info":{"id":1,"version_no":"3.4.1.4","version_name":"cursor<6F><72><EFBFBD><EFBFBD>","download_url":"https:\/\/cursorapi.nosqli.com\/upload\/<2F><>Ȫcursor<6F><72><EFBFBD><EFBFBD>v3.4.1.4.exe","is_force":0,"min_version":"","platform":"all","status":1,"description":"","create_time":"2025-02-13 13:32:35","update_time":"2025-02-13 13:32:35"}}}
|
||||||
|
2025-02-13 13:54:30,146 - INFO - <20>Ƿ<EFBFBD><C7B7>и<EFBFBD><D0B8><EFBFBD>: True
|
||||||
|
2025-02-13 13:54:30,146 - INFO - <20>Ƿ<EFBFBD>ǿ<EFBFBD>Ƹ<EFBFBD><C6B8><EFBFBD>: False
|
||||||
|
2025-02-13 13:54:30,146 - INFO - <20>汾<EFBFBD><E6B1BE>Ϣ: {'id': 1, 'version_no': '3.4.1.4', 'version_name': 'cursor<6F><72><EFBFBD><EFBFBD>', 'download_url': 'https://cursorapi.nosqli.com/upload/<2F><>Ȫcursor<6F><72><EFBFBD><EFBFBD>v3.4.1.4.exe', 'is_force': 0, 'min_version': '', 'platform': 'all', 'status': 1, 'description': '', 'create_time': '2025-02-13 13:32:35', 'update_time': '2025-02-13 13:32:35'}
|
||||||
|
2025-02-13 13:54:30,146 - INFO -
|
||||||
|
=== <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD> ===
|
||||||
|
2025-02-13 13:54:30,148 - INFO - <20><><EFBFBD>ص<EFBFBD>ַ: https://cursorapi.nosqli.com/upload/<2F><>Ȫcursor<6F><72><EFBFBD><EFBFBD>v3.4.1.4.exe
|
||||||
|
2025-02-13 13:54:30,148 - INFO - <20><><EFBFBD><EFBFBD>·<EFBFBD><C2B7>: C:\Users\huangzhen\Downloads\CursorHelper\test_update.exe
|
||||||
|
2025-02-13 13:54:31,822 - ERROR - <20><><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD>ʧ<EFBFBD><CAA7>: 404 Client Error: Not Found for url: https://cursorapi.nosqli.com/upload/%E5%90%AC%E6%B3%89cursor%E5%8A%A9%E6%89%8Bv3.4.1.4.exe
|
||||||
|
2025-02-13 13:54:31,823 - INFO - <20><><EFBFBD>ؽ<EFBFBD><D8BD><EFBFBD>: ʧ<><CAA7>
|
||||||
70
versioncheck.doc
Normal file
70
versioncheck.doc
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
版本更新API文档
|
||||||
|
域名
|
||||||
|
base_url: https://cursorapi.nosqli.com
|
||||||
|
# 版本更新API文档
|
||||||
|
|
||||||
|
#
|
||||||
|
* 公共返回参数:
|
||||||
|
* - code: 错误码,0表示成功,非0表示失败
|
||||||
|
* - msg: 提示信息
|
||||||
|
* - data: 返回的数据,请求失败时可能为空
|
||||||
|
*
|
||||||
|
* 错误码说明:
|
||||||
|
* - 0: 成功
|
||||||
|
* - 1: 一般性错误(具体错误信息见msg)
|
||||||
|
* - 401: 未授权或授权失败
|
||||||
|
* - 404: 请求的资源不存在
|
||||||
|
* - 500: 服务器内部错误
|
||||||
|
*
|
||||||
|
* 版本号格式:x.x.x (例如: 3.4.1)
|
||||||
|
* 平台类型:
|
||||||
|
* - all: 全平台
|
||||||
|
* - windows: Windows平台
|
||||||
|
* - mac: Mac平台
|
||||||
|
* - linux: Linux平台
|
||||||
|
* ====================================================
|
||||||
|
*
|
||||||
|
* 1. 获取最新版本 [GET] /admin/api.version/latest
|
||||||
|
* 请求参数:
|
||||||
|
* - platform: 平台类型(all|windows|mac|linux), 默认为all
|
||||||
|
* 返回数据:
|
||||||
|
* {
|
||||||
|
* "code": 0,
|
||||||
|
* "msg": "获取成功",
|
||||||
|
* "data": {
|
||||||
|
* "id": "1",
|
||||||
|
* "version_no": "3.4.1.4",
|
||||||
|
* "version_name": "听泉cursor助手",
|
||||||
|
* "download_url": "http://domain/upload/xxx.exe",
|
||||||
|
* "is_force": 1, // 是否强制更新(1是,0否)
|
||||||
|
* "min_version": "3.4.0.0", // 最低要求版本
|
||||||
|
* "platform": "all", // 平台类型
|
||||||
|
* "description": "版本描述", // 版本描述
|
||||||
|
* "status": 1, // 状态(1启用,0禁用)
|
||||||
|
* "create_time": "2024-03-20 10:00:00"
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* 2. 检查版本更新 [GET] /admin/api.version/check
|
||||||
|
* 请求参数:
|
||||||
|
* - version: 当前版本号(必填)
|
||||||
|
* - platform: 平台类型(all|windows|mac|linux), 默认为all
|
||||||
|
* 返回数据:
|
||||||
|
* {
|
||||||
|
* "code": 0,
|
||||||
|
* "msg": "检查完成",
|
||||||
|
* "data": {
|
||||||
|
* "has_update": true, // 是否有更新
|
||||||
|
* "is_force": 1, // 是否强制更新
|
||||||
|
* "version_info": { // 新版本信息(has_update为true时返回)
|
||||||
|
* // 同上面的版本信息
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* 错误返回示例:
|
||||||
|
* {
|
||||||
|
* "code": 1,
|
||||||
|
* "msg": "请提供当前版本号",
|
||||||
|
* "data": null
|
||||||
|
* }
|
||||||
Reference in New Issue
Block a user