Compare commits
12 Commits
v3.3pyqt5g
...
v3.5.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae698796e7 | ||
|
|
26e159d71c | ||
|
|
b11452aea8 | ||
|
|
8b2fbef54a | ||
|
|
10523de040 | ||
|
|
dd0a307ff4 | ||
|
|
b5cbf0779b | ||
|
|
d81244c7e4 | ||
|
|
e3b5820d8b | ||
|
|
4ee3ac066e | ||
|
|
30aab5f9b2 | ||
|
|
207c3c604e |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -18,3 +18,5 @@ env/
|
||||
|
||||
# Local development settings
|
||||
.env
|
||||
|
||||
testversion.txt
|
||||
1012
account_switcher.py
1012
account_switcher.py
File diff suppressed because it is too large
Load Diff
BIN
banbenjietu.png
Normal file
BIN
banbenjietu.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 38 KiB |
115
build.bat
115
build.bat
@@ -1,12 +1,119 @@
|
||||
@echo off
|
||||
chcp 65001
|
||||
echo 开始打包流程...
|
||||
setlocal EnableDelayedExpansion
|
||||
echo 开始正式版本打包...
|
||||
|
||||
:: 设置工作目录为脚本所在目录
|
||||
cd /d "%~dp0"
|
||||
|
||||
:: 激活虚拟环境
|
||||
if exist "venv\Scripts\activate.bat" (
|
||||
echo 激活虚拟环境...
|
||||
call venv\Scripts\activate.bat
|
||||
) else (
|
||||
echo 警告: 未找到虚拟环境,使用系统 Python
|
||||
)
|
||||
|
||||
:: 确保安装了必要的包
|
||||
echo 检查依赖包...
|
||||
pip install -r requirements.txt
|
||||
|
||||
:: 更新版本号
|
||||
python update_version.py
|
||||
|
||||
:: 使用新的spec文件进行打包
|
||||
pyinstaller --noconfirm build_nezha.spec
|
||||
:: 读取版本号
|
||||
set /p VERSION=<version.txt
|
||||
echo 当前版本: !VERSION!
|
||||
|
||||
echo 打包完成!
|
||||
:: 提取主版本号和次版本号 (3.4.7 -> 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!
|
||||
)
|
||||
|
||||
:: 清理 Python 缓存文件
|
||||
echo 清理Python缓存文件...
|
||||
for /d /r . %%d in (__pycache__) do @if exist "%%d" rd /s /q "%%d"
|
||||
del /s /q *.pyc >nul 2>&1
|
||||
del /s /q *.pyo >nul 2>&1
|
||||
|
||||
:: 清理旧的打包文件
|
||||
echo 清理旧文件...
|
||||
if exist "build" rd /s /q "build"
|
||||
if exist "*.spec" del /f /q "*.spec"
|
||||
|
||||
:: 使用优化选项进行打包
|
||||
echo 开始打包...
|
||||
pyinstaller ^
|
||||
--noconfirm ^
|
||||
--clean ^
|
||||
--onefile ^
|
||||
--noconsole ^
|
||||
--icon=icon/two.ico ^
|
||||
--name "听泉cursor助手!VERSION!" ^
|
||||
--add-data "icon;icon" ^
|
||||
--add-data "version.txt;." ^
|
||||
--add-data "testversion.txt;." ^
|
||||
--add-data "requirements.txt;." ^
|
||||
--exclude-module _tkinter ^
|
||||
--exclude-module tkinter ^
|
||||
--exclude-module PIL.ImageTk ^
|
||||
--exclude-module PIL.ImageWin ^
|
||||
--exclude-module numpy ^
|
||||
--exclude-module pandas ^
|
||||
--exclude-module matplotlib ^
|
||||
--exclude "__pycache__" ^
|
||||
--exclude "*.pyc" ^
|
||||
--exclude "*.pyo" ^
|
||||
--exclude "*.pyd" ^
|
||||
main.py
|
||||
|
||||
:: 检查打包结果并移动文件
|
||||
set TEMP_FILE=dist\听泉cursor助手!VERSION!.exe
|
||||
set TARGET_FILE=!VERSION_DIR!\听泉cursor助手v!VERSION!.exe
|
||||
|
||||
echo 检查文件: !TEMP_FILE!
|
||||
if exist "!TEMP_FILE!" (
|
||||
echo 正式版本打包成功!
|
||||
|
||||
:: 移动到版本目录
|
||||
echo 移动文件到: !TARGET_FILE!
|
||||
move "!TEMP_FILE!" "!TARGET_FILE!"
|
||||
|
||||
:: 显示文件大小
|
||||
for %%I in ("!TARGET_FILE!") do (
|
||||
echo 文件大小: %%~zI 字节
|
||||
)
|
||||
|
||||
echo.
|
||||
echo 正式版本构建完成!
|
||||
echo 版本号: v!VERSION!
|
||||
echo 文件位置: !TARGET_FILE!
|
||||
) else (
|
||||
echo 错误: 打包失败,文件不存在
|
||||
echo 预期文件路径: !TEMP_FILE!
|
||||
dir /b dist
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
:: 清理临时文件
|
||||
echo 清理临时文件...
|
||||
if exist "build" rd /s /q "build"
|
||||
if exist "dist\听泉cursor助手!VERSION!.exe" del /f /q "dist\听泉cursor助手!VERSION!.exe"
|
||||
if exist "*.spec" del /f /q "*.spec"
|
||||
|
||||
:: 退出虚拟环境
|
||||
if exist "venv\Scripts\activate.bat" (
|
||||
echo 退出虚拟环境...
|
||||
deactivate
|
||||
)
|
||||
|
||||
endlocal
|
||||
pause
|
||||
@@ -1,51 +0,0 @@
|
||||
# -*- mode: python ; coding: utf-8 -*-
|
||||
import os
|
||||
|
||||
def get_version():
|
||||
with open('version.txt', 'r', encoding='utf-8') as f:
|
||||
version = f.read().strip()
|
||||
return version
|
||||
|
||||
version = get_version()
|
||||
|
||||
a = Analysis(
|
||||
['main.py'],
|
||||
pathex=[],
|
||||
binaries=[],
|
||||
datas=[('icon', 'icon'), ('version.txt', '.')],
|
||||
hiddenimports=[
|
||||
'win32gui', 'win32con', 'win32process', 'psutil', # Windows API 相关
|
||||
'PyQt5', 'PyQt5.QtCore', 'PyQt5.QtGui', 'PyQt5.QtWidgets', # GUI 相关
|
||||
'requests', 'urllib3', 'certifi', # 网络请求相关
|
||||
'json', 'uuid', 'hashlib', 'logging' # 基础功能相关
|
||||
],
|
||||
hookspath=[],
|
||||
hooksconfig={},
|
||||
runtime_hooks=[],
|
||||
excludes=['_tkinter', 'tkinter', 'Tkinter'], # 排除 tkinter 相关模块
|
||||
noarchive=False,
|
||||
optimize=0,
|
||||
)
|
||||
pyz = PYZ(a.pure)
|
||||
|
||||
exe = EXE(
|
||||
pyz,
|
||||
a.scripts,
|
||||
a.binaries,
|
||||
a.datas,
|
||||
[],
|
||||
name=f'听泉cursor助手{version}',
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
runtime_tmpdir=None,
|
||||
console=False,
|
||||
disable_windowed_traceback=False,
|
||||
argv_emulation=False,
|
||||
target_arch=None,
|
||||
codesign_identity=None,
|
||||
entitlements_file=None,
|
||||
icon=['icon\\two.ico'],
|
||||
)
|
||||
@@ -5,6 +5,9 @@ import time
|
||||
import logging
|
||||
import sqlite3
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
from typing import Optional, Dict, Tuple
|
||||
from datetime import datetime
|
||||
|
||||
class CursorAuthManager:
|
||||
"""Cursor认证信息管理器"""
|
||||
@@ -30,15 +33,97 @@ class CursorAuthManager:
|
||||
raise NotImplementedError(f"不支持的操作系统: {sys.platform}")
|
||||
|
||||
self.cursor_path = Path(os.path.expanduser("~")) / "AppData" / "Local" / "Programs" / "Cursor"
|
||||
self.backup_dir = Path(os.getenv('APPDATA')) / "Cursor" / "User" / "globalStorage" / "backups"
|
||||
self.max_retries = 5
|
||||
self.wait_time = 1
|
||||
|
||||
def update_auth(self, email=None, access_token=None, refresh_token=None):
|
||||
def backup_database(self) -> Optional[Path]:
|
||||
"""备份数据库文件
|
||||
|
||||
Returns:
|
||||
Optional[Path]: 备份文件路径,失败返回None
|
||||
"""
|
||||
更新Cursor的认证信息
|
||||
:param email: 新的邮箱地址
|
||||
:param access_token: 新的访问令牌
|
||||
:param refresh_token: 新的刷新令牌
|
||||
:return: bool 是否成功更新
|
||||
try:
|
||||
if not Path(self.db_path).exists():
|
||||
logging.warning(f"数据库文件不存在: {self.db_path}")
|
||||
return None
|
||||
|
||||
self.backup_dir.mkdir(parents=True, exist_ok=True)
|
||||
backup_name = f"state.vscdb.backup_{datetime.now().strftime('%Y%m%d_%H%M%S')}"
|
||||
backup_path = self.backup_dir / backup_name
|
||||
|
||||
# 如果数据库正在使用,先关闭连接
|
||||
try:
|
||||
conn = sqlite3.connect(self.db_path)
|
||||
conn.close()
|
||||
except:
|
||||
pass
|
||||
|
||||
import shutil
|
||||
shutil.copy2(self.db_path, backup_path)
|
||||
logging.info(f"已备份数据库: {backup_path}")
|
||||
return backup_path
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"备份数据库失败: {str(e)}")
|
||||
return None
|
||||
|
||||
def get_auth_info(self) -> Optional[Dict]:
|
||||
"""获取当前的认证信息
|
||||
|
||||
Returns:
|
||||
Optional[Dict]: 认证信息字典,失败返回None
|
||||
"""
|
||||
try:
|
||||
if not Path(self.db_path).exists():
|
||||
return None
|
||||
|
||||
conn = sqlite3.connect(self.db_path)
|
||||
cursor = conn.cursor()
|
||||
|
||||
# 查询认证相关的键值
|
||||
auth_keys = [
|
||||
'authentication.currentToken',
|
||||
'authentication.refreshToken',
|
||||
'authentication.accessToken',
|
||||
'authentication.email'
|
||||
]
|
||||
|
||||
result = {}
|
||||
for key in auth_keys:
|
||||
cursor.execute('SELECT value FROM ItemTable WHERE key = ?', (key,))
|
||||
row = cursor.fetchone()
|
||||
if row:
|
||||
try:
|
||||
value = json.loads(row[0])
|
||||
result[key] = value
|
||||
except:
|
||||
result[key] = row[0]
|
||||
|
||||
conn.close()
|
||||
return result if result else None
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"获取认证信息失败: {str(e)}")
|
||||
return None
|
||||
|
||||
def update_auth(self, email: str = None, access_token: str = None, refresh_token: str = None) -> bool:
|
||||
"""更新Cursor的认证信息
|
||||
|
||||
Args:
|
||||
email: 新的邮箱地址
|
||||
access_token: 新的访问令牌
|
||||
refresh_token: 新的刷新令牌
|
||||
|
||||
Returns:
|
||||
bool: 是否成功更新
|
||||
"""
|
||||
try:
|
||||
# 备份数据库
|
||||
if not self.backup_database():
|
||||
logging.warning("数据库备份失败")
|
||||
|
||||
# 准备更新数据
|
||||
updates = []
|
||||
# 登录状态
|
||||
updates.append(("cursorAuth/cachedSignUpType", "Auth_0"))
|
||||
@@ -54,81 +139,314 @@ class CursorAuthManager:
|
||||
logging.warning("没有提供任何要更新的值")
|
||||
return False
|
||||
|
||||
conn = None
|
||||
try:
|
||||
# 确保数据库目录存在
|
||||
db_dir = Path(self.db_path).parent
|
||||
db_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# 确保数据库表存在
|
||||
conn = sqlite3.connect(self.db_path)
|
||||
cursor = conn.cursor()
|
||||
|
||||
# 创建表(如果不存在)
|
||||
cursor.execute('''
|
||||
CREATE TABLE IF NOT EXISTS ItemTable (
|
||||
key TEXT PRIMARY KEY,
|
||||
value TEXT
|
||||
)
|
||||
''')
|
||||
|
||||
try:
|
||||
# 开始事务
|
||||
cursor.execute('BEGIN TRANSACTION')
|
||||
|
||||
# 执行更新
|
||||
for key, value in updates:
|
||||
# 检查key是否存在
|
||||
check_query = f"SELECT COUNT(*) FROM itemTable WHERE key = ?"
|
||||
cursor.execute(check_query, (key,))
|
||||
cursor.execute('SELECT COUNT(*) FROM ItemTable WHERE key = ?', (key,))
|
||||
if cursor.fetchone()[0] == 0:
|
||||
insert_query = "INSERT INTO itemTable (key, value) VALUES (?, ?)"
|
||||
cursor.execute(insert_query, (key, value))
|
||||
# 插入新值
|
||||
cursor.execute(
|
||||
'INSERT INTO ItemTable (key, value) VALUES (?, ?)',
|
||||
(key, value)
|
||||
)
|
||||
else:
|
||||
update_query = "UPDATE itemTable SET value = ? WHERE key = ?"
|
||||
cursor.execute(update_query, (value, key))
|
||||
# 更新现有值
|
||||
cursor.execute(
|
||||
'UPDATE ItemTable SET value = ? WHERE key = ?',
|
||||
(value, key)
|
||||
)
|
||||
|
||||
if cursor.rowcount > 0:
|
||||
logging.info(f"成功更新 {key.split('/')[-1]}")
|
||||
else:
|
||||
logging.warning(f"未找到 {key.split('/')[-1]} 或值未变化")
|
||||
|
||||
conn.commit()
|
||||
# 提交事务
|
||||
cursor.execute('COMMIT')
|
||||
logging.info(f"认证信息更新成功: {email}")
|
||||
return True
|
||||
|
||||
except sqlite3.Error as e:
|
||||
logging.error(f"数据库错误: {str(e)}")
|
||||
return False
|
||||
except Exception as e:
|
||||
# 如果出错,回滚事务
|
||||
cursor.execute('ROLLBACK')
|
||||
raise e
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"更新认证信息失败: {str(e)}")
|
||||
return False
|
||||
|
||||
finally:
|
||||
if conn:
|
||||
if 'conn' in locals():
|
||||
conn.close()
|
||||
|
||||
def verify_auth(self, email: str, access_token: str, refresh_token: str) -> bool:
|
||||
"""验证认证信息是否正确写入
|
||||
|
||||
Args:
|
||||
email: 邮箱
|
||||
access_token: 访问令牌
|
||||
refresh_token: 新的刷新令牌
|
||||
|
||||
Returns:
|
||||
bool: 是否正确写入
|
||||
"""
|
||||
try:
|
||||
# 连接数据库
|
||||
conn = sqlite3.connect(self.db_path)
|
||||
cursor = conn.cursor()
|
||||
|
||||
# 验证每个字段
|
||||
expected = {
|
||||
'cursorAuth/cachedEmail': email,
|
||||
'cursorAuth/accessToken': access_token,
|
||||
'cursorAuth/refreshToken': refresh_token,
|
||||
'cursorAuth/cachedSignUpType': 'Auth_0'
|
||||
}
|
||||
|
||||
for key, expected_value in expected.items():
|
||||
cursor.execute('SELECT value FROM ItemTable WHERE key = ?', (key,))
|
||||
row = cursor.fetchone()
|
||||
if not row:
|
||||
logging.error(f"缺少认证信息: {key}")
|
||||
return False
|
||||
|
||||
actual_value = row[0]
|
||||
if actual_value != expected_value:
|
||||
logging.error(f"认证信息不匹配: {key}")
|
||||
logging.error(f"预期: {expected_value}")
|
||||
logging.error(f"实际: {actual_value}")
|
||||
return False
|
||||
|
||||
conn.close()
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"验证认证信息失败: {str(e)}")
|
||||
return False
|
||||
finally:
|
||||
if 'conn' in locals():
|
||||
conn.close()
|
||||
|
||||
def clear_auth(self) -> bool:
|
||||
"""清除认证信息
|
||||
|
||||
Returns:
|
||||
bool: 是否成功
|
||||
"""
|
||||
try:
|
||||
# 备份数据库
|
||||
if not self.backup_database():
|
||||
logging.warning("数据库备份失败")
|
||||
|
||||
# 清除数据库中的认证信息
|
||||
conn = sqlite3.connect(self.db_path)
|
||||
cursor = conn.cursor()
|
||||
|
||||
# 要清除的键
|
||||
auth_keys = [
|
||||
'authentication.currentToken',
|
||||
'authentication.refreshToken',
|
||||
'authentication.accessToken',
|
||||
'authentication.email'
|
||||
]
|
||||
|
||||
# 执行删除
|
||||
for key in auth_keys:
|
||||
cursor.execute('DELETE FROM ItemTable WHERE key = ?', (key,))
|
||||
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
logging.info("已清除认证信息")
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"清除认证信息失败: {str(e)}")
|
||||
return False
|
||||
|
||||
def close_cursor_process(self) -> bool:
|
||||
"""关闭所有Cursor进程
|
||||
|
||||
Returns:
|
||||
bool: 是否成功
|
||||
"""
|
||||
try:
|
||||
if sys.platform == "win32":
|
||||
# 创建startupinfo对象来隐藏命令行窗口
|
||||
startupinfo = subprocess.STARTUPINFO()
|
||||
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||
startupinfo.wShowWindow = subprocess.SW_HIDE
|
||||
|
||||
# 关闭进程
|
||||
subprocess.run(
|
||||
"taskkill /f /im Cursor.exe >nul 2>&1",
|
||||
startupinfo=startupinfo,
|
||||
shell=True
|
||||
)
|
||||
|
||||
# 等待进程关闭
|
||||
retry_count = 0
|
||||
while retry_count < self.max_retries:
|
||||
try:
|
||||
subprocess.check_output(
|
||||
"tasklist | findstr Cursor.exe",
|
||||
startupinfo=startupinfo,
|
||||
shell=True
|
||||
)
|
||||
retry_count += 1
|
||||
if retry_count >= self.max_retries:
|
||||
logging.error("无法关闭所有Cursor进程")
|
||||
return False
|
||||
time.sleep(self.wait_time)
|
||||
except subprocess.CalledProcessError:
|
||||
# 进程已关闭
|
||||
break
|
||||
|
||||
return True
|
||||
|
||||
else:
|
||||
# 其他系统的处理
|
||||
if sys.platform == "darwin":
|
||||
subprocess.run("killall Cursor 2>/dev/null", shell=True)
|
||||
else:
|
||||
subprocess.run("pkill -f cursor", shell=True)
|
||||
time.sleep(2)
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"关闭进程失败: {str(e)}")
|
||||
return False
|
||||
|
||||
def restart_cursor(self) -> bool:
|
||||
"""重启Cursor编辑器
|
||||
|
||||
Returns:
|
||||
bool: 是否成功重启
|
||||
bool: 是否成功
|
||||
"""
|
||||
try:
|
||||
logging.info("正在重启Cursor...")
|
||||
|
||||
# 确保进程已关闭
|
||||
if not self.close_cursor_process():
|
||||
logging.error("无法关闭Cursor进程")
|
||||
return False
|
||||
|
||||
# 等待系统资源释放
|
||||
time.sleep(3)
|
||||
|
||||
# 启动Cursor
|
||||
if sys.platform == "win32":
|
||||
# Windows系统
|
||||
# 关闭Cursor
|
||||
os.system("taskkill /f /im Cursor.exe 2>nul")
|
||||
time.sleep(2)
|
||||
# 获取Cursor安装路径
|
||||
cursor_exe = self.cursor_path / "Cursor.exe"
|
||||
if cursor_exe.exists():
|
||||
# 启动Cursor
|
||||
os.startfile(str(cursor_exe))
|
||||
logging.info("Cursor重启成功")
|
||||
max_retries = 3
|
||||
for attempt in range(max_retries):
|
||||
try:
|
||||
# 检查是否还有Cursor进程在运行
|
||||
try:
|
||||
subprocess.check_output(
|
||||
"tasklist | findstr Cursor.exe",
|
||||
startupinfo=subprocess.STARTUPINFO(),
|
||||
shell=True
|
||||
)
|
||||
# 如果找到进程,等待它关闭
|
||||
if attempt < max_retries - 1:
|
||||
logging.info("等待进程完全关闭...")
|
||||
time.sleep(3)
|
||||
continue
|
||||
else:
|
||||
logging.error("无法确保所有Cursor进程已关闭")
|
||||
return False
|
||||
except subprocess.CalledProcessError:
|
||||
# 没有找到进程,可以继续启动
|
||||
pass
|
||||
|
||||
# 使用subprocess启动
|
||||
startupinfo = subprocess.STARTUPINFO()
|
||||
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||
|
||||
# 使用subprocess.Popen启动,并等待一段时间
|
||||
process = subprocess.Popen(
|
||||
str(cursor_exe),
|
||||
startupinfo=startupinfo,
|
||||
creationflags=subprocess.CREATE_NEW_CONSOLE
|
||||
)
|
||||
|
||||
# 等待进程启动
|
||||
time.sleep(5)
|
||||
|
||||
# 验证进程是否成功启动
|
||||
if process.poll() is None: # 进程仍在运行
|
||||
logging.info("Cursor启动成功")
|
||||
return True
|
||||
else:
|
||||
if attempt < max_retries - 1:
|
||||
logging.warning(f"启动尝试 {attempt + 1} 失败,准备重试...")
|
||||
time.sleep(3)
|
||||
continue
|
||||
|
||||
logging.error("Cursor进程启动失败")
|
||||
# 尝试使用 os.startfile 作为备选方案
|
||||
try:
|
||||
os.startfile(str(cursor_exe))
|
||||
time.sleep(5)
|
||||
logging.info("使用备选方案启动Cursor")
|
||||
return True
|
||||
except Exception as e:
|
||||
logging.error(f"备选启动方案失败: {str(e)}")
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
if attempt < max_retries - 1:
|
||||
logging.warning(f"启动尝试 {attempt + 1} 失败: {str(e)},准备重试...")
|
||||
time.sleep(3)
|
||||
continue
|
||||
|
||||
logging.error(f"启动Cursor失败: {str(e)}")
|
||||
return False
|
||||
else:
|
||||
logging.error(f"未找到Cursor程序: {cursor_exe}")
|
||||
return False
|
||||
elif sys.platform == "darwin":
|
||||
# macOS系统
|
||||
os.system("killall Cursor 2>/dev/null")
|
||||
time.sleep(2)
|
||||
os.system("open -a Cursor")
|
||||
logging.info("Cursor重启成功")
|
||||
try:
|
||||
subprocess.run("open -a Cursor", shell=True, check=True)
|
||||
time.sleep(5)
|
||||
logging.info("Cursor启动成功")
|
||||
return True
|
||||
except subprocess.CalledProcessError as e:
|
||||
logging.error(f"启动Cursor失败: {str(e)}")
|
||||
return False
|
||||
elif sys.platform == "linux":
|
||||
# Linux系统
|
||||
os.system("pkill -f cursor")
|
||||
time.sleep(2)
|
||||
os.system("cursor &")
|
||||
logging.info("Cursor重启成功")
|
||||
try:
|
||||
subprocess.run("cursor &", shell=True, check=True)
|
||||
time.sleep(5)
|
||||
logging.info("Cursor启动成功")
|
||||
return True
|
||||
else:
|
||||
logging.error(f"不支持的操作系统: {sys.platform}")
|
||||
except subprocess.CalledProcessError as e:
|
||||
logging.error(f"启动Cursor失败: {str(e)}")
|
||||
return False
|
||||
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"重启Cursor时发生错误: {str(e)}")
|
||||
logging.error(f"重启Cursor失败: {str(e)}")
|
||||
return False
|
||||
0
cursor_win_id.ps1
Normal file
0
cursor_win_id.ps1
Normal file
@@ -40,10 +40,9 @@ 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 "$GREEN 听泉Cursor助手 - 机器码重置工具 $NC"
|
||||
Write-Host "$YELLOW 官方网站: cursor.nosqli.com $NC"
|
||||
Write-Host "$YELLOW 微信客服: behikcigar $NC"
|
||||
Write-Host "$BLUE================================$NC"
|
||||
Write-Host ""
|
||||
|
||||
@@ -191,26 +190,81 @@ $randomPart = Get-RandomHex -length 32
|
||||
$MACHINE_ID = "$prefixHex$randomPart"
|
||||
$SQM_ID = "{$([System.Guid]::NewGuid().ToString().ToUpper())}"
|
||||
|
||||
# 在生成新ID后直接执行注册表操作,移除询问
|
||||
# 在Update-MachineGuid函数前添加权限检查
|
||||
if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
|
||||
Write-Host "$RED[错误]$NC 请使用管理员权限运行此脚本"
|
||||
Start-Process powershell "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
|
||||
exit
|
||||
}
|
||||
|
||||
function Update-MachineGuid {
|
||||
try {
|
||||
$newMachineGuid = [System.Guid]::NewGuid().ToString()
|
||||
# 先检查注册表路径是否存在
|
||||
$registryPath = "HKLM:\SOFTWARE\Microsoft\Cryptography"
|
||||
if (-not (Test-Path $registryPath)) {
|
||||
throw "注册表路径不存在: $registryPath"
|
||||
}
|
||||
|
||||
# 备份原始值
|
||||
$originalGuid = (Get-ItemProperty -Path $registryPath -Name "MachineGuid").MachineGuid
|
||||
$backupFile = "$BACKUP_DIR\MachineGuid.backup_$(Get-Date -Format 'yyyyMMdd_HHmmss')"
|
||||
$originalGuid | Out-File $backupFile -Encoding UTF8
|
||||
# 获取当前的 MachineGuid
|
||||
$currentGuid = Get-ItemProperty -Path $registryPath -Name MachineGuid -ErrorAction Stop
|
||||
if (-not $currentGuid) {
|
||||
throw "无法获取当前的 MachineGuid"
|
||||
}
|
||||
|
||||
$originalGuid = $currentGuid.MachineGuid
|
||||
Write-Host "$GREEN[信息]$NC 当前注册表值:"
|
||||
Write-Host "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography"
|
||||
Write-Host " MachineGuid REG_SZ $originalGuid"
|
||||
|
||||
# 创建备份目录(如果不存在)
|
||||
if (-not (Test-Path $BACKUP_DIR)) {
|
||||
New-Item -ItemType Directory -Path $BACKUP_DIR -Force | Out-Null
|
||||
}
|
||||
|
||||
# 创建备份文件
|
||||
$backupFile = "$BACKUP_DIR\MachineGuid_$(Get-Date -Format 'yyyyMMdd_HHmmss').reg"
|
||||
$backupResult = Start-Process "reg.exe" -ArgumentList "export", "`"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography`"", "`"$backupFile`"" -NoNewWindow -Wait -PassThru
|
||||
|
||||
if ($backupResult.ExitCode -eq 0) {
|
||||
Write-Host "$GREEN[信息]$NC 注册表项已备份到:$backupFile"
|
||||
} else {
|
||||
Write-Host "$YELLOW[警告]$NC 备份创建失败,继续执行..."
|
||||
}
|
||||
|
||||
# 生成新GUID
|
||||
$newGuid = [System.Guid]::NewGuid().ToString()
|
||||
|
||||
# 更新注册表
|
||||
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"
|
||||
Set-ItemProperty -Path $registryPath -Name MachineGuid -Value $newGuid -Force -ErrorAction Stop
|
||||
|
||||
# 验证更新
|
||||
$verifyGuid = (Get-ItemProperty -Path $registryPath -Name MachineGuid -ErrorAction Stop).MachineGuid
|
||||
if ($verifyGuid -ne $newGuid) {
|
||||
throw "注册表验证失败:更新后的值 ($verifyGuid) 与预期值 ($newGuid) 不匹配"
|
||||
}
|
||||
|
||||
Write-Host "$GREEN[信息]$NC 注册表更新成功:"
|
||||
Write-Host "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography"
|
||||
Write-Host " MachineGuid REG_SZ $newGuid"
|
||||
return $true
|
||||
}
|
||||
catch {
|
||||
Write-Host "$RED[错误]$NC 更新系统 MachineGuid 失败: $_"
|
||||
Write-Host "$RED[错误]$NC 注册表操作失败:$($_.Exception.Message)"
|
||||
|
||||
# 尝试恢复备份
|
||||
if ($backupFile -and (Test-Path $backupFile)) {
|
||||
Write-Host "$YELLOW[恢复]$NC 正在从备份恢复..."
|
||||
$restoreResult = Start-Process "reg.exe" -ArgumentList "import", "`"$backupFile`"" -NoNewWindow -Wait -PassThru
|
||||
|
||||
if ($restoreResult.ExitCode -eq 0) {
|
||||
Write-Host "$GREEN[恢复成功]$NC 已还原原始注册表值"
|
||||
} else {
|
||||
Write-Host "$RED[错误]$NC 恢复失败,请手动导入备份文件:$backupFile"
|
||||
}
|
||||
} else {
|
||||
Write-Host "$YELLOW[警告]$NC 未找到备份文件或备份创建失败,无法自动恢复"
|
||||
}
|
||||
return $false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,7 +351,7 @@ try {
|
||||
# 显示公众号信息
|
||||
Write-Host ""
|
||||
Write-Host "$GREEN================================$NC"
|
||||
Write-Host "$YELLOW 关注公众号【煎饼果子卷AI】一起交流更多Cursor技巧和AI知识(脚本免费、关注公众号加群有更多技巧和大佬) $NC"
|
||||
Write-Host "$YELLOW 欢迎使用Cursor助手 $NC"
|
||||
Write-Host "$GREEN================================$NC"
|
||||
Write-Host ""
|
||||
Write-Host "$GREEN[信息]$NC 请重启 Cursor 以应用新的配置"
|
||||
@@ -413,6 +467,9 @@ try {
|
||||
Write-Host "$GREEN[信息]$NC 保持默认设置,不进行更改"
|
||||
}
|
||||
|
||||
# 保留有效的注册表更新
|
||||
Update-MachineGuid
|
||||
|
||||
} catch {
|
||||
Write-Host "$RED[错误]$NC 主要操作失败: $_"
|
||||
Write-Host "$YELLOW[尝试]$NC 使用备选方法..."
|
||||
|
||||
83
disable_update.ps1
Normal file
83
disable_update.ps1
Normal file
@@ -0,0 +1,83 @@
|
||||
# 检查管理员权限
|
||||
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
||||
if (-not $isAdmin) {
|
||||
Write-Host "`n[错误] 请以管理员身份运行此脚本" -ForegroundColor Red
|
||||
Write-Host "请使用 'Start-Process pwsh -Verb RunAs' 启动管理员PowerShell" -ForegroundColor Yellow
|
||||
Pause
|
||||
exit
|
||||
}
|
||||
|
||||
Write-Host "`n=== Cursor更新禁用工具 ===" -ForegroundColor Cyan
|
||||
|
||||
# 定义路径
|
||||
$updaterPath = Join-Path $env:LOCALAPPDATA "cursor-updater"
|
||||
$cursorPath = Join-Path $env:LOCALAPPDATA "Programs\cursor"
|
||||
$packageJsonPath = Join-Path $cursorPath "resources\app\package.json"
|
||||
|
||||
Write-Host "`n正在检查路径..." -ForegroundColor Gray
|
||||
Write-Host "updater路径: $updaterPath" -ForegroundColor Gray
|
||||
|
||||
try {
|
||||
# 1. 删除现有的updater文件/目录
|
||||
if (Test-Path $updaterPath) {
|
||||
Write-Host "`n发现现有updater文件/目录,正在删除..." -ForegroundColor Yellow
|
||||
Remove-Item -Path $updaterPath -Force -Recurse -ErrorAction Stop
|
||||
Write-Host "成功删除现有文件/目录" -ForegroundColor Green
|
||||
}
|
||||
|
||||
# 2. 创建空文件
|
||||
Write-Host "`n正在创建updater文件..." -ForegroundColor Yellow
|
||||
New-Item -Path $updaterPath -ItemType File -Force -ErrorAction Stop | Out-Null
|
||||
Write-Host "成功创建updater文件" -ForegroundColor Green
|
||||
|
||||
# 3. 设置文件权限
|
||||
Write-Host "`n正在设置文件权限..." -ForegroundColor Yellow
|
||||
|
||||
# 获取当前用户
|
||||
$currentUser = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name
|
||||
|
||||
# 创建新的ACL
|
||||
$acl = New-Object System.Security.AccessControl.FileSecurity
|
||||
$acl.SetAccessRuleProtection($true, $false) # 禁用继承
|
||||
|
||||
# 添加只读权限规则
|
||||
$readRule = New-Object System.Security.AccessControl.FileSystemAccessRule(
|
||||
$currentUser,
|
||||
[System.Security.AccessControl.FileSystemRights]::Read,
|
||||
[System.Security.AccessControl.AccessControlType]::Allow
|
||||
)
|
||||
$acl.AddAccessRule($readRule)
|
||||
|
||||
# 应用ACL
|
||||
Set-Acl -Path $updaterPath -AclObject $acl -ErrorAction Stop
|
||||
|
||||
# 设置只读属性
|
||||
Set-ItemProperty -Path $updaterPath -Name IsReadOnly -Value $true -ErrorAction Stop
|
||||
Write-Host "成功设置文件权限" -ForegroundColor Green
|
||||
|
||||
# 4. 修改package.json
|
||||
if (Test-Path $packageJsonPath) {
|
||||
Write-Host "`n正在修改package.json..." -ForegroundColor Yellow
|
||||
$json = Get-Content $packageJsonPath -Raw | ConvertFrom-Json
|
||||
$json.updateUrl = ""
|
||||
$json.disableUpdate = $true
|
||||
$json | ConvertTo-Json -Depth 10 | Set-Content $packageJsonPath -Encoding UTF8
|
||||
Write-Host "成功修改package.json" -ForegroundColor Green
|
||||
}
|
||||
|
||||
# 5. 验证权限
|
||||
Write-Host "`n正在验证文件权限..." -ForegroundColor Yellow
|
||||
$item = Get-Item $updaterPath
|
||||
if (-not $item.IsReadOnly) {
|
||||
throw "文件权限验证失败:文件不是只读"
|
||||
}
|
||||
Write-Host "文件权限验证通过" -ForegroundColor Green
|
||||
|
||||
Write-Host "`n[成功] Cursor更新已禁用!" -ForegroundColor Green
|
||||
|
||||
} catch {
|
||||
Write-Host "`n[错误] 操作失败: $($_.Exception.Message)" -ForegroundColor Red
|
||||
}
|
||||
|
||||
Write-Host "`n按任意键退出..." -ForegroundColor Gray
|
||||
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
|
||||
1597
gui/main_window.py
1597
gui/main_window.py
File diff suppressed because it is too large
Load Diff
145
main.py
145
main.py
@@ -5,11 +5,43 @@ import os
|
||||
import atexit
|
||||
import shutil
|
||||
import tempfile
|
||||
import urllib3
|
||||
import ctypes
|
||||
import win32event
|
||||
import win32api
|
||||
import winerror
|
||||
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 account_switcher import AccountSwitcher
|
||||
|
||||
# 禁用所有 SSL 相关警告
|
||||
urllib3.disable_warnings()
|
||||
logging.getLogger('urllib3').setLevel(logging.ERROR)
|
||||
|
||||
def prevent_multiple_instances():
|
||||
"""防止程序多开
|
||||
|
||||
Returns:
|
||||
bool: 如果是第一个实例返回True,否则返回False
|
||||
"""
|
||||
try:
|
||||
# 创建一个唯一的互斥锁名称
|
||||
mutex_name = "Global\\CursorHelper_SingleInstance_Lock"
|
||||
|
||||
# 尝试创建互斥锁
|
||||
handle = win32event.CreateMutex(None, 1, mutex_name)
|
||||
if win32api.GetLastError() == winerror.ERROR_ALREADY_EXISTS:
|
||||
# 互斥锁已存在,说明程序已经在运行
|
||||
logging.warning("程序已经在运行")
|
||||
QMessageBox.warning(None, "警告", "程序已经在运行!\n请不要重复打开程序。")
|
||||
return False
|
||||
return True
|
||||
except Exception as e:
|
||||
logging.error(f"检查程序实例失败: {str(e)}")
|
||||
return True # 如果检查失败,允许程序运行
|
||||
|
||||
def cleanup_temp():
|
||||
"""清理临时文件"""
|
||||
@@ -34,77 +66,120 @@ def setup_logging():
|
||||
|
||||
log_file = log_dir / "switcher.log"
|
||||
|
||||
# 只输出到文件,不输出到控制台
|
||||
# 同时输出到文件和控制台
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format="%(asctime)s - %(levelname)s - %(message)s",
|
||||
handlers=[
|
||||
logging.FileHandler(log_file, encoding="utf-8"),
|
||||
logging.StreamHandler()
|
||||
]
|
||||
)
|
||||
except Exception as e:
|
||||
# 不打印错误信息,只记录到日志
|
||||
pass
|
||||
print(f"设置日志失败: {str(e)}")
|
||||
|
||||
def is_admin():
|
||||
"""检查是否具有管理员权限"""
|
||||
try:
|
||||
return ctypes.windll.shell32.IsUserAnAdmin() != 0
|
||||
except:
|
||||
return False
|
||||
|
||||
def run_as_admin():
|
||||
"""以管理员权限重新运行程序"""
|
||||
try:
|
||||
if not is_admin():
|
||||
# 获取当前脚本的路径
|
||||
script = sys.argv[0]
|
||||
params = ' '.join(sys.argv[1:])
|
||||
|
||||
# 以管理员权限重新运行
|
||||
ctypes.windll.shell32.ShellExecuteW(
|
||||
None,
|
||||
"runas",
|
||||
sys.executable,
|
||||
f'"{script}" {params}',
|
||||
None,
|
||||
1
|
||||
)
|
||||
return True
|
||||
except Exception as e:
|
||||
print(f"提升权限失败: {str(e)}")
|
||||
return False
|
||||
|
||||
def print_banner():
|
||||
"""打印程序横幅"""
|
||||
print("""
|
||||
====================================
|
||||
Cursor 账号管理工具
|
||||
====================================
|
||||
""")
|
||||
|
||||
def main():
|
||||
"""主函数"""
|
||||
try:
|
||||
# 注册退出时的清理函数
|
||||
# 0. 检查是否已有实例在运行
|
||||
if not prevent_multiple_instances():
|
||||
return 1
|
||||
|
||||
# 1. 首先检查管理员权限
|
||||
if not is_admin():
|
||||
if run_as_admin():
|
||||
return 0
|
||||
else:
|
||||
QMessageBox.critical(None, "错误", "需要管理员权限运行此程序。\n请右键点击程序,选择'以管理员身份运行'。")
|
||||
return 1
|
||||
|
||||
# 2. 注册退出时的清理函数
|
||||
atexit.register(cleanup_temp)
|
||||
|
||||
# 3. 设置日志
|
||||
setup_logging()
|
||||
|
||||
# 检查Python版本
|
||||
logging.info(f"Python版本: {sys.version}")
|
||||
|
||||
# 检查工作目录
|
||||
logging.info(f"当前工作目录: {Path.cwd()}")
|
||||
|
||||
# 检查模块路径
|
||||
logging.info("Python路径:")
|
||||
for p in sys.path:
|
||||
logging.info(f" - {p}")
|
||||
|
||||
logging.info("正在初始化主窗口...")
|
||||
# 4. 创建QApplication实例
|
||||
app = QApplication(sys.argv)
|
||||
|
||||
# 设置应用程序ID (在设置图标之前)
|
||||
# 5. 检查系统托盘
|
||||
if not QSystemTrayIcon.isSystemTrayAvailable():
|
||||
logging.error("系统托盘不可用")
|
||||
QMessageBox.critical(None, "错误", "系统托盘不可用,程序无法正常运行。")
|
||||
return 1
|
||||
|
||||
# 6. 设置应用程序不会在最后一个窗口关闭时退出
|
||||
app.setQuitOnLastWindowClosed(False)
|
||||
|
||||
# 7. 记录系统信息
|
||||
logging.info(f"Python版本: {sys.version}")
|
||||
logging.info(f"当前工作目录: {Path.cwd()}")
|
||||
|
||||
# 8. 设置应用程序ID
|
||||
if sys.platform == "win32":
|
||||
import ctypes
|
||||
myappid = u'nezha.cursor.helper.v3'
|
||||
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
|
||||
logging.info(f"设置应用程序ID: {myappid}")
|
||||
|
||||
# 设置应用程序图标
|
||||
try:
|
||||
# 9. 设置应用程序图标
|
||||
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)}")
|
||||
|
||||
# 10. 创建并显示主窗口
|
||||
logging.info("正在初始化主窗口...")
|
||||
window = MainWindow()
|
||||
window.setWindowIcon(app.windowIcon()) # 确保窗口使用相同的图标
|
||||
|
||||
logging.info("正在启动主窗口...")
|
||||
window.setWindowIcon(app.windowIcon())
|
||||
window.show()
|
||||
sys.exit(app.exec_())
|
||||
|
||||
# 11. 运行应用程序
|
||||
return app.exec_()
|
||||
|
||||
except Exception as e:
|
||||
error_msg = f"程序运行出错: {str(e)}\n{traceback.format_exc()}"
|
||||
logging.error(error_msg)
|
||||
# 使用 QMessageBox 显示错误
|
||||
app = QApplication(sys.argv)
|
||||
QMessageBox.critical(None, "错误", error_msg)
|
||||
sys.exit(1)
|
||||
return 1
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
sys.exit(main())
|
||||
@@ -2,8 +2,10 @@
|
||||
# pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt
|
||||
|
||||
requests==2.31.0
|
||||
setuptools>=68.0.0
|
||||
altgraph>=0.17.4
|
||||
pyinstaller==6.3.0
|
||||
pillow==10.2.0 # For icon processing
|
||||
setuptools==65.5.1 # Fix pkg_resources.extern issue
|
||||
PyQt5==5.15.10 # GUI framework
|
||||
pywin32==306 # Windows API support
|
||||
pillow==10.2.0
|
||||
PyQt5==5.15.10
|
||||
pywin32==306
|
||||
packaging>=23.2
|
||||
54
test_computer_name.py
Normal file
54
test_computer_name.py
Normal file
@@ -0,0 +1,54 @@
|
||||
import platform
|
||||
import hashlib
|
||||
import time
|
||||
|
||||
def get_computer_name_id():
|
||||
"""使用计算机名生成ID(方案三)"""
|
||||
try:
|
||||
computer_name = platform.node()
|
||||
if computer_name:
|
||||
print(f"\n计算机名: {computer_name}")
|
||||
hardware_id = hashlib.md5(computer_name.encode()).hexdigest()
|
||||
return hardware_id
|
||||
return None
|
||||
except Exception as e:
|
||||
print(f"获取计算机名失败: {str(e)}")
|
||||
return None
|
||||
|
||||
def test_stability():
|
||||
"""测试ID的稳定性"""
|
||||
print("开始测试计算机名生成ID的稳定性...")
|
||||
print("将进行10次测试,每次间隔1秒")
|
||||
|
||||
# 存储每次生成的ID
|
||||
computer_ids = []
|
||||
|
||||
for i in range(10):
|
||||
print(f"\n第 {i+1} 次测试:")
|
||||
|
||||
# 测试计算机名方案
|
||||
comp_id = get_computer_name_id()
|
||||
if comp_id:
|
||||
print(f"使用计算机名生成的ID: {comp_id}")
|
||||
computer_ids.append(comp_id)
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
# 分析结果
|
||||
print("\n测试结果分析:")
|
||||
|
||||
if computer_ids:
|
||||
unique_ids = set(computer_ids)
|
||||
print(f"\n计算机名方案:")
|
||||
print(f"生成次数: {len(computer_ids)}")
|
||||
print(f"唯一ID数: {len(unique_ids)}")
|
||||
print("是否稳定: " + ("是" if len(unique_ids) == 1 else "否"))
|
||||
if len(unique_ids) > 1:
|
||||
print("出现的不同ID:")
|
||||
for idx, id in enumerate(unique_ids):
|
||||
print(f"{idx+1}. {id}")
|
||||
else:
|
||||
print("\n计算机名方案: 获取失败")
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_stability()
|
||||
210
test_disable_update.py
Normal file
210
test_disable_update.py
Normal file
@@ -0,0 +1,210 @@
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import ctypes
|
||||
import logging
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from datetime import datetime
|
||||
from typing import Optional, Tuple, Dict
|
||||
|
||||
# 配置日志
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format='%(asctime)s - %(levelname)s - %(message)s'
|
||||
)
|
||||
|
||||
def run_powershell_command(command: str) -> Tuple[bool, str]:
|
||||
"""运行PowerShell命令
|
||||
|
||||
Args:
|
||||
command: PowerShell命令
|
||||
|
||||
Returns:
|
||||
Tuple[bool, str]: (是否成功, 输出或错误信息)
|
||||
"""
|
||||
try:
|
||||
# 创建完整的PowerShell命令
|
||||
full_command = f'powershell.exe -Command "{command}"'
|
||||
|
||||
# 运行命令
|
||||
result = subprocess.run(
|
||||
full_command,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
shell=True
|
||||
)
|
||||
|
||||
if result.returncode == 0:
|
||||
return True, result.stdout.strip()
|
||||
else:
|
||||
return False, result.stderr.strip()
|
||||
except Exception as e:
|
||||
return False, str(e)
|
||||
|
||||
def is_admin():
|
||||
"""检查是否具有管理员权限"""
|
||||
try:
|
||||
return ctypes.windll.shell32.IsUserAnAdmin()
|
||||
except:
|
||||
return False
|
||||
|
||||
def run_as_admin():
|
||||
"""以管理员权限重新运行程序"""
|
||||
try:
|
||||
if not is_admin():
|
||||
# 获取当前脚本的路径
|
||||
script = sys.argv[0]
|
||||
params = ' '.join(sys.argv[1:])
|
||||
|
||||
# 以管理员权限重新运行
|
||||
ctypes.windll.shell32.ShellExecuteW(
|
||||
None,
|
||||
"runas",
|
||||
sys.executable,
|
||||
f'"{script}" {params}',
|
||||
None,
|
||||
1
|
||||
)
|
||||
return True
|
||||
except Exception as e:
|
||||
logging.error(f"以管理员权限运行失败: {str(e)}")
|
||||
return False
|
||||
|
||||
class CursorUpdateDisabler:
|
||||
"""专门用于测试禁用Cursor更新的类"""
|
||||
|
||||
def __init__(self):
|
||||
self.localappdata = os.getenv('LOCALAPPDATA')
|
||||
self.cursor_path = Path(self.localappdata) / "Programs" / "cursor"
|
||||
self.app_path = self.cursor_path / "resources" / "app"
|
||||
self.package_json = self.app_path / "package.json"
|
||||
self.updater_path = Path(self.localappdata) / "cursor-updater"
|
||||
|
||||
def disable_auto_update(self) -> Tuple[bool, str]:
|
||||
"""禁用自动更新
|
||||
|
||||
Returns:
|
||||
Tuple[bool, str]: (是否成功, 消息)
|
||||
"""
|
||||
try:
|
||||
logging.info(f"开始禁用更新操作...")
|
||||
logging.info(f"updater路径: {self.updater_path}")
|
||||
|
||||
# 1. 使用PowerShell强制删除现有文件/目录
|
||||
if self.updater_path.exists():
|
||||
logging.info("发现现有updater文件/目录,尝试强制删除...")
|
||||
|
||||
# 先获取完全控制权限
|
||||
take_control_cmd = f'$path = "{self.updater_path}"; $acl = Get-Acl $path; $identity = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name; $fileSystemRights = [System.Security.AccessControl.FileSystemRights]::FullControl; $type = [System.Security.AccessControl.AccessControlType]::Allow; $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($identity, $fileSystemRights, $type); $acl.SetAccessRule($rule); Set-Acl -Path $path -AclObject $acl'
|
||||
success, output = run_powershell_command(take_control_cmd)
|
||||
if not success:
|
||||
logging.warning(f"设置完全控制权限失败: {output}")
|
||||
|
||||
# 强制删除
|
||||
remove_cmd = f'Remove-Item -Path "{self.updater_path}" -Force -Recurse'
|
||||
success, output = run_powershell_command(remove_cmd)
|
||||
if not success:
|
||||
logging.error(f"强制删除失败: {output}")
|
||||
return False, f"删除现有文件失败: {output}"
|
||||
logging.info("成功删除现有文件/目录")
|
||||
|
||||
# 2. 创建空文件
|
||||
try:
|
||||
with open(self.updater_path, 'w') as f:
|
||||
pass
|
||||
logging.info("成功创建updater空文件")
|
||||
except Exception as e:
|
||||
logging.error(f"创建updater文件失败: {str(e)}")
|
||||
return False, f"创建updater文件失败: {str(e)}"
|
||||
|
||||
# 3. 设置文件权限
|
||||
try:
|
||||
# 设置文件为只读并禁止修改
|
||||
protect_cmd = f'$path = "{self.updater_path}"; $acl = Get-Acl $path; $acl.SetAccessRuleProtection($true, $false); $identity = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name; $fileSystemRights = [System.Security.AccessControl.FileSystemRights]::Read; $type = [System.Security.AccessControl.AccessControlType]::Allow; $rule = New-Object System.Security.AccessControl.FileSystemAccessRule($identity, $fileSystemRights, $type); $acl.AddAccessRule($rule); Set-Acl -Path $path -AclObject $acl'
|
||||
success, output = run_powershell_command(protect_cmd)
|
||||
if not success:
|
||||
logging.error(f"设置文件权限失败: {output}")
|
||||
return False, f"设置文件权限失败: {output}"
|
||||
logging.info("成功设置文件权限")
|
||||
|
||||
# 设置文件为只读
|
||||
os.chmod(str(self.updater_path), 0o444) # 设置为只读
|
||||
logging.info("成功设置文件只读属性")
|
||||
except Exception as e:
|
||||
logging.error(f"设置文件权限失败: {str(e)}")
|
||||
return False, f"设置文件权限失败: {str(e)}"
|
||||
|
||||
# 4. 修改package.json
|
||||
try:
|
||||
if self.package_json.exists():
|
||||
with open(self.package_json, "r", encoding="utf-8") as f:
|
||||
data = json.load(f)
|
||||
|
||||
data["updateUrl"] = ""
|
||||
data["disableUpdate"] = True
|
||||
|
||||
with open(self.package_json, "w", encoding="utf-8", newline='\n') as f:
|
||||
json.dump(data, f, indent=2)
|
||||
logging.info("成功修改package.json配置")
|
||||
except Exception as e:
|
||||
logging.warning(f"修改package.json失败: {str(e)}")
|
||||
|
||||
# 5. 验证文件权限
|
||||
try:
|
||||
if not self.updater_path.exists():
|
||||
return False, "updater文件不存在"
|
||||
|
||||
# 验证文件是否为只读
|
||||
if os.access(str(self.updater_path), os.W_OK):
|
||||
logging.error("文件权限验证失败:文件可写")
|
||||
return False, "文件权限设置失败:文件仍然可写"
|
||||
|
||||
logging.info("文件权限验证通过")
|
||||
except Exception as e:
|
||||
logging.error(f"验证文件权限失败: {str(e)}")
|
||||
return False, f"验证文件权限失败: {str(e)}"
|
||||
|
||||
logging.info("禁用自动更新成功完成")
|
||||
return True, "Cursor更新已禁用"
|
||||
|
||||
except Exception as e:
|
||||
error_msg = f"禁用自动更新失败: {str(e)}"
|
||||
logging.error(error_msg)
|
||||
return False, error_msg
|
||||
|
||||
def main():
|
||||
"""主函数"""
|
||||
try:
|
||||
# 检查管理员权限
|
||||
if os.name == 'nt':
|
||||
import ctypes
|
||||
if not is_admin():
|
||||
logging.warning("当前不是管理员权限运行")
|
||||
print("\n[错误] 请按以下步骤手动操作:")
|
||||
print("1. 按下 Win + R 组合键")
|
||||
print("2. 在运行框中输入 powershell 或 pwsh")
|
||||
print("3. 按 Ctrl + Shift + Enter 以管理员身份运行")
|
||||
print("4. 在管理员终端中输入以下命令:")
|
||||
print(" irm https://github.com/maticarmy/cursor-nosqli-tools/blob/main/scripts/run/cursor_win_id_modifier.ps1 | iex")
|
||||
input("\n按回车键退出...")
|
||||
return
|
||||
|
||||
print("\n=== Cursor更新禁用测试工具 ===")
|
||||
disabler = CursorUpdateDisabler()
|
||||
success, message = disabler.disable_auto_update()
|
||||
|
||||
if success:
|
||||
print("\n更新已禁用!")
|
||||
else:
|
||||
print(f"\n禁用更新失败: {message}")
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"程序执行出错: {str(e)}")
|
||||
print(f"\n程序执行出错: {str(e)}")
|
||||
|
||||
finally:
|
||||
input("\n按回车键退出...")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
131
test_hardware_id.py
Normal file
131
test_hardware_id.py
Normal file
@@ -0,0 +1,131 @@
|
||||
import subprocess
|
||||
import hashlib
|
||||
import logging
|
||||
import sys
|
||||
import time
|
||||
|
||||
def get_hardware_info():
|
||||
"""获取硬件信息(方案一)"""
|
||||
startupinfo = None
|
||||
if sys.platform == "win32":
|
||||
startupinfo = subprocess.STARTUPINFO()
|
||||
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||
startupinfo.wShowWindow = subprocess.SW_HIDE
|
||||
|
||||
try:
|
||||
# 获取CPU ID
|
||||
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()
|
||||
|
||||
if all([cpu_id, board_id, bios_id]):
|
||||
print(f"\n方案一硬件信息:")
|
||||
print(f"CPU ID: {cpu_id}")
|
||||
print(f"主板序列号: {board_id}")
|
||||
print(f"BIOS序列号: {bios_id}")
|
||||
|
||||
combined = f"{cpu_id}:{board_id}:{bios_id}"
|
||||
return hashlib.md5(combined.encode()).hexdigest()
|
||||
except Exception as e:
|
||||
print(f"方案一获取失败: {str(e)}")
|
||||
return None
|
||||
|
||||
def get_system_info():
|
||||
"""获取系统信息(方案二)"""
|
||||
startupinfo = None
|
||||
if sys.platform == "win32":
|
||||
startupinfo = subprocess.STARTUPINFO()
|
||||
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||
startupinfo.wShowWindow = subprocess.SW_HIDE
|
||||
|
||||
backup_info = []
|
||||
|
||||
try:
|
||||
# 获取系统盘序列号
|
||||
volume_info = subprocess.check_output('wmic logicaldisk where "DeviceID=\'C:\'" get VolumeSerialNumber', startupinfo=startupinfo).decode()
|
||||
volume_serial = volume_info.split('\n')[1].strip()
|
||||
if volume_serial:
|
||||
backup_info.append(("volume", volume_serial))
|
||||
print(f"\n系统盘序列号: {volume_serial}")
|
||||
except Exception as e:
|
||||
print(f"获取系统盘序列号失败: {str(e)}")
|
||||
|
||||
try:
|
||||
# 获取Windows安装时间
|
||||
os_info = subprocess.check_output('wmic os get InstallDate', startupinfo=startupinfo).decode()
|
||||
install_date = os_info.split('\n')[1].strip()
|
||||
if install_date:
|
||||
backup_info.append(("install", install_date))
|
||||
print(f"Windows安装时间: {install_date}")
|
||||
except Exception as e:
|
||||
print(f"获取系统安装时间失败: {str(e)}")
|
||||
|
||||
if backup_info:
|
||||
combined = "|".join(f"{k}:{v}" for k, v in sorted(backup_info))
|
||||
return hashlib.md5(combined.encode()).hexdigest()
|
||||
return None
|
||||
|
||||
def test_stability():
|
||||
"""测试ID的稳定性"""
|
||||
print("开始测试硬件ID稳定性...")
|
||||
print("将进行10次测试,每次间隔1秒")
|
||||
|
||||
# 存储每次生成的ID
|
||||
hardware_ids = []
|
||||
system_ids = []
|
||||
|
||||
for i in range(10):
|
||||
print(f"\n第 {i+1} 次测试:")
|
||||
|
||||
# 测试方案一
|
||||
hw_id = get_hardware_info()
|
||||
if hw_id:
|
||||
print(f"方案一(硬件信息)生成的ID: {hw_id}")
|
||||
hardware_ids.append(hw_id)
|
||||
|
||||
# 测试方案二
|
||||
sys_id = get_system_info()
|
||||
if sys_id:
|
||||
print(f"方案二(系统信息)生成的ID: {sys_id}")
|
||||
system_ids.append(sys_id)
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
# 分析结果
|
||||
print("\n测试结果分析:")
|
||||
|
||||
if hardware_ids:
|
||||
unique_hw_ids = set(hardware_ids)
|
||||
print(f"\n方案一(硬件信息):")
|
||||
print(f"生成次数: {len(hardware_ids)}")
|
||||
print(f"唯一ID数: {len(unique_hw_ids)}")
|
||||
print("是否稳定: " + ("是" if len(unique_hw_ids) == 1 else "否"))
|
||||
if len(unique_hw_ids) > 1:
|
||||
print("出现的不同ID:")
|
||||
for idx, id in enumerate(unique_hw_ids):
|
||||
print(f"{idx+1}. {id}")
|
||||
else:
|
||||
print("\n方案一(硬件信息): 获取失败")
|
||||
|
||||
if system_ids:
|
||||
unique_sys_ids = set(system_ids)
|
||||
print(f"\n方案二(系统信息):")
|
||||
print(f"生成次数: {len(system_ids)}")
|
||||
print(f"唯一ID数: {len(unique_sys_ids)}")
|
||||
print("是否稳定: " + ("是" if len(unique_sys_ids) == 1 else "否"))
|
||||
if len(unique_sys_ids) > 1:
|
||||
print("出现的不同ID:")
|
||||
for idx, id in enumerate(unique_sys_ids):
|
||||
print(f"{idx+1}. {id}")
|
||||
else:
|
||||
print("\n方案二(系统信息): 获取失败")
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_stability()
|
||||
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()
|
||||
123
testbuild.bat
Normal file
123
testbuild.bat
Normal file
@@ -0,0 +1,123 @@
|
||||
@echo off
|
||||
chcp 65001
|
||||
setlocal EnableDelayedExpansion
|
||||
echo 开始测试打包...
|
||||
|
||||
:: 设置工作目录为脚本所在目录
|
||||
cd /d "%~dp0"
|
||||
|
||||
:: 激活虚拟环境
|
||||
if exist "venv\Scripts\activate.bat" (
|
||||
echo 激活虚拟环境...
|
||||
call venv\Scripts\activate.bat
|
||||
) else (
|
||||
echo 警告: 未找到虚拟环境,使用系统 Python
|
||||
)
|
||||
|
||||
:: 确保安装了必要的包
|
||||
echo 检查依赖包...
|
||||
pip install -r requirements.txt
|
||||
|
||||
:: 读取版本号
|
||||
set /p VERSION=<version.txt
|
||||
echo 当前版本: !VERSION!
|
||||
|
||||
:: 提取主版本号和次版本号 (3.4.7 -> 3.4)
|
||||
for /f "tokens=1,2 delims=." %%a in ("!VERSION!") do (
|
||||
set MAJOR_VERSION=%%a.%%b
|
||||
)
|
||||
echo 主版本目录: !MAJOR_VERSION!
|
||||
|
||||
:: 读取测试版本号(如果存在)
|
||||
if exist testversion.txt (
|
||||
set /p TEST_VERSION=<testversion.txt
|
||||
) else (
|
||||
set TEST_VERSION=0
|
||||
)
|
||||
|
||||
:: 增加测试版本号
|
||||
set /a TEST_VERSION+=1
|
||||
echo !TEST_VERSION!>testversion.txt
|
||||
echo 测试版本号: !TEST_VERSION!
|
||||
|
||||
:: 组合完整版本号
|
||||
set FULL_VERSION=!VERSION!.!TEST_VERSION!
|
||||
echo 完整版本号: !FULL_VERSION!
|
||||
|
||||
:: 创建测试版本目录
|
||||
set TEST_DIR=dist\test\!MAJOR_VERSION!
|
||||
if not exist "!TEST_DIR!" (
|
||||
mkdir "!TEST_DIR!"
|
||||
echo 创建目录: !TEST_DIR!
|
||||
)
|
||||
|
||||
:: 清理 Python 缓存文件
|
||||
echo 清理Python缓存文件...
|
||||
for /d /r . %%d in (__pycache__) do @if exist "%%d" rd /s /q "%%d"
|
||||
del /s /q *.pyc >nul 2>&1
|
||||
del /s /q *.pyo >nul 2>&1
|
||||
|
||||
:: 清理旧的打包文件
|
||||
echo 清理旧文件...
|
||||
if exist "build" rd /s /q "build"
|
||||
if exist "*.spec" del /f /q "*.spec"
|
||||
|
||||
:: 使用优化选项进行打包
|
||||
echo 开始打包...
|
||||
pyinstaller ^
|
||||
--noconfirm ^
|
||||
--clean ^
|
||||
--onefile ^
|
||||
--noconsole ^
|
||||
--icon=icon/two.ico ^
|
||||
--name "听泉cursor助手_test" ^
|
||||
--add-data "icon;icon" ^
|
||||
--add-data "version.txt;." ^
|
||||
--add-data "testversion.txt;." ^
|
||||
--add-data "requirements.txt;." ^
|
||||
--exclude-module _tkinter ^
|
||||
--exclude-module tkinter ^
|
||||
--exclude-module PIL.ImageTk ^
|
||||
--exclude-module PIL.ImageWin ^
|
||||
--exclude-module numpy ^
|
||||
--exclude-module pandas ^
|
||||
--exclude-module matplotlib ^
|
||||
--exclude "__pycache__" ^
|
||||
--exclude "*.pyc" ^
|
||||
--exclude "*.pyo" ^
|
||||
--exclude "*.pyd" ^
|
||||
main.py
|
||||
|
||||
:: 检查打包结果并移动文件
|
||||
set TEMP_FILE=dist\听泉cursor助手_test.exe
|
||||
set TARGET_FILE=!TEST_DIR!\听泉cursor助手v!FULL_VERSION!.exe
|
||||
|
||||
echo 检查文件: !TEMP_FILE!
|
||||
if exist "!TEMP_FILE!" (
|
||||
echo 测试打包成功!
|
||||
|
||||
:: 移动到版本目录
|
||||
echo 移动文件到: !TARGET_FILE!
|
||||
move "!TEMP_FILE!" "!TARGET_FILE!"
|
||||
|
||||
:: 显示文件大小
|
||||
for %%I in ("!TARGET_FILE!") do (
|
||||
echo 文件大小: %%~zI 字节
|
||||
)
|
||||
|
||||
echo.
|
||||
echo 测试版本构建完成!
|
||||
echo 版本号: v!FULL_VERSION!
|
||||
echo 文件位置: !TARGET_FILE!
|
||||
) else (
|
||||
echo 错误: 打包失败,文件不存在
|
||||
)
|
||||
|
||||
:: 退出虚拟环境
|
||||
if exist "venv\Scripts\activate.bat" (
|
||||
echo 退出虚拟环境...
|
||||
deactivate
|
||||
)
|
||||
|
||||
endlocal
|
||||
pause
|
||||
@@ -4,8 +4,16 @@ import logging
|
||||
from pathlib import Path
|
||||
|
||||
class Config:
|
||||
"""配置类"""
|
||||
|
||||
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",
|
||||
"heartbeat": f"{self.base_url}/admin/api.account/heartbeat"
|
||||
}
|
||||
self.config_dir = Path(os.path.expanduser("~")) / ".cursor_switcher"
|
||||
self.config_file = self.config_dir / "config.json"
|
||||
self.member_file = self.config_dir / "member.json"
|
||||
@@ -65,3 +73,14 @@ class Config:
|
||||
with open(self.config_file, "w", encoding="utf-8") as f:
|
||||
json.dump(config, f, indent=2, ensure_ascii=False)
|
||||
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, "")
|
||||
@@ -7,6 +7,8 @@ import uuid
|
||||
from datetime import datetime
|
||||
import json
|
||||
import hashlib
|
||||
import ctypes
|
||||
from typing import Optional
|
||||
|
||||
class CursorRegistry:
|
||||
"""Cursor注册表操作工具类"""
|
||||
@@ -14,6 +16,73 @@ class CursorRegistry:
|
||||
def __init__(self):
|
||||
self.cursor_path = Path(os.path.expanduser("~")) / "AppData" / "Local" / "Programs" / "Cursor"
|
||||
self.app_path = self.cursor_path / "resources" / "app"
|
||||
self.backup_dir = Path(os.getenv('APPDATA')) / "Cursor" / "User" / "globalStorage" / "backups"
|
||||
|
||||
def get_random_hex(self, length: int) -> str:
|
||||
"""生成安全的随机十六进制字符串
|
||||
|
||||
Args:
|
||||
length: 需要生成的字节长度
|
||||
|
||||
Returns:
|
||||
str: 十六进制字符串
|
||||
"""
|
||||
import secrets
|
||||
return secrets.token_hex(length)
|
||||
|
||||
def new_standard_machine_id(self) -> str:
|
||||
"""生成标准格式的机器ID
|
||||
|
||||
Returns:
|
||||
str: 标准格式的机器ID
|
||||
"""
|
||||
template = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"
|
||||
|
||||
def replace_char(match):
|
||||
import random
|
||||
r = random.randint(0, 15)
|
||||
v = r if match == 'x' else (r & 0x3 | 0x8)
|
||||
return hex(v)[2:]
|
||||
|
||||
return ''.join(replace_char(c) for c in template)
|
||||
|
||||
def is_admin(self) -> bool:
|
||||
"""检查是否具有管理员权限
|
||||
|
||||
Returns:
|
||||
bool: 是否具有管理员权限
|
||||
"""
|
||||
try:
|
||||
return ctypes.windll.shell32.IsUserAnAdmin() != 0
|
||||
except:
|
||||
return False
|
||||
|
||||
def backup_file(self, source_path: Path, backup_name: Optional[str] = None) -> Optional[Path]:
|
||||
"""备份文件
|
||||
|
||||
Args:
|
||||
source_path: 源文件路径
|
||||
backup_name: 备份文件名(可选)
|
||||
|
||||
Returns:
|
||||
Optional[Path]: 备份文件路径,失败返回None
|
||||
"""
|
||||
try:
|
||||
if not source_path.exists():
|
||||
return None
|
||||
|
||||
self.backup_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
if backup_name is None:
|
||||
backup_name = f"{source_path.name}.backup_{datetime.now().strftime('%Y%m%d_%H%M%S')}"
|
||||
|
||||
backup_path = self.backup_dir / backup_name
|
||||
shutil.copy2(source_path, backup_path)
|
||||
logging.info(f"已备份文件: {source_path} -> {backup_path}")
|
||||
return backup_path
|
||||
except Exception as e:
|
||||
logging.error(f"备份文件失败 {source_path}: {str(e)}")
|
||||
return None
|
||||
|
||||
def update_machine_guid(self) -> bool:
|
||||
"""更新系统的 MachineGuid
|
||||
@@ -21,54 +90,41 @@ class CursorRegistry:
|
||||
Returns:
|
||||
bool: 是否成功
|
||||
"""
|
||||
if not self.is_admin():
|
||||
logging.error("需要管理员权限来修改 MachineGuid")
|
||||
return False
|
||||
|
||||
try:
|
||||
# 生成新的 GUID
|
||||
new_guid = str(uuid.uuid4())
|
||||
registry_path = r"SOFTWARE\Microsoft\Cryptography"
|
||||
|
||||
try:
|
||||
# 使用管理员权限打开注册表项
|
||||
key = None
|
||||
try:
|
||||
# 先尝试直接打开读取权限
|
||||
key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, registry_path, 0,
|
||||
winreg.KEY_READ | winreg.KEY_WOW64_64KEY)
|
||||
# 读取原始值并备份
|
||||
# 备份原始值
|
||||
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, registry_path, 0,
|
||||
winreg.KEY_READ | winreg.KEY_WOW64_64KEY) as key:
|
||||
original_guid = winreg.QueryValueEx(key, "MachineGuid")[0]
|
||||
winreg.CloseKey(key)
|
||||
|
||||
# 备份原始 MachineGuid
|
||||
backup_dir = Path(os.getenv('APPDATA')) / "Cursor" / "User" / "globalStorage" / "backups"
|
||||
backup_dir.mkdir(parents=True, exist_ok=True)
|
||||
backup_name = f"MachineGuid.backup_{datetime.now().strftime('%Y%m%d_%H%M%S')}"
|
||||
with open(backup_dir / backup_name, 'w', encoding='utf-8') as f:
|
||||
# 备份原始 GUID
|
||||
backup_path = self.backup_dir / f"MachineGuid.backup_{datetime.now().strftime('%Y%m%d_%H%M%S')}"
|
||||
self.backup_dir.mkdir(parents=True, exist_ok=True)
|
||||
with open(backup_path, 'w', encoding='utf-8') as f:
|
||||
f.write(original_guid)
|
||||
logging.info(f"备份 MachineGuid 到: {backup_name}")
|
||||
logging.info(f"已备份 MachineGuid: {backup_path}")
|
||||
|
||||
# 重新打开写入权限
|
||||
key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, registry_path, 0,
|
||||
winreg.KEY_WRITE | winreg.KEY_WOW64_64KEY)
|
||||
except WindowsError:
|
||||
# 如果失败,尝试以管理员权限运行
|
||||
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)
|
||||
|
||||
# 设置新的 GUID
|
||||
# 更新 GUID
|
||||
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, registry_path, 0,
|
||||
winreg.KEY_WRITE | winreg.KEY_WOW64_64KEY) as key:
|
||||
winreg.SetValueEx(key, "MachineGuid", 0, winreg.REG_SZ, new_guid)
|
||||
winreg.CloseKey(key)
|
||||
logging.info(f"更新系统 MachineGuid 成功: {new_guid}")
|
||||
|
||||
logging.info(f"已更新系统 MachineGuid: {new_guid}")
|
||||
return True
|
||||
|
||||
except WindowsError as e:
|
||||
logging.error(f"更新系统 MachineGuid 失败: {str(e)}")
|
||||
logging.error(f"注册表操作失败: {str(e)}")
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"更新 MachineGuid 过程出错: {str(e)}")
|
||||
logging.error(f"更新 MachineGuid 失败: {str(e)}")
|
||||
return False
|
||||
|
||||
def clean_registry(self) -> bool:
|
||||
@@ -107,97 +163,111 @@ class CursorRegistry:
|
||||
return False
|
||||
|
||||
def clean_cursor_files(self) -> bool:
|
||||
"""清理Cursor相关的文件和目录,但保留重要的配置和历史记录"""
|
||||
"""清理Cursor相关的文件和目录,但保留重要的配置和历史记录
|
||||
|
||||
Returns:
|
||||
bool: 是否成功
|
||||
"""
|
||||
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_path = Path(os.getenv('APPDATA')) / "Cursor" / "User" / "globalStorage" / "storage.json"
|
||||
global_storage_dir = storage_path.parent
|
||||
|
||||
# 备份 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}")
|
||||
if storage_path.exists():
|
||||
if not self.backup_file(storage_path):
|
||||
return False
|
||||
|
||||
# 备份 global_storage 目录中的其他重要文件
|
||||
# 备份其他重要文件
|
||||
if global_storage_dir.exists():
|
||||
for item in global_storage_dir.iterdir():
|
||||
if item.name != "storage.json" and item.name != "backups":
|
||||
if item.name not in ["storage.json", "backups"]:
|
||||
try:
|
||||
backup_item_dir = backup_dir / f"other_files_{datetime.now().strftime('%Y%m%d_%H%M%S')}"
|
||||
backup_item_dir = self.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)}")
|
||||
|
||||
# 读取当前内容
|
||||
logging.info(f"已备份: {item}")
|
||||
except Exception as e:
|
||||
logging.error(f"备份失败 {item}: {str(e)}")
|
||||
|
||||
# 更新 storage.json
|
||||
if storage_path.exists():
|
||||
try:
|
||||
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()
|
||||
new_machine_id = self.get_random_hex(32)
|
||||
storage_data["telemetry.machineId"] = new_machine_id
|
||||
logging.info(f"更新 machineId: {new_machine_id}")
|
||||
logging.info(f"已更新 machineId: {new_machine_id}")
|
||||
|
||||
# 保存修改后的内容
|
||||
with open(storage_path, "w", encoding="utf-8") as f:
|
||||
# 使用 UTF-8 无 BOM 编码保存
|
||||
with open(storage_path, "w", encoding="utf-8", newline='\n') as f:
|
||||
json.dump(storage_data, f, indent=2)
|
||||
|
||||
# 处理 updater 目录
|
||||
updater_path = local_app_data / "cursor-updater"
|
||||
except Exception as e:
|
||||
logging.error(f"更新 storage.json 失败: {str(e)}")
|
||||
return False
|
||||
|
||||
# 处理更新程序
|
||||
updater_path = Path(os.getenv('LOCALAPPDATA')) / "cursor-updater"
|
||||
if updater_path.exists():
|
||||
try:
|
||||
# 如果是目录,则删除
|
||||
if updater_path.is_dir():
|
||||
shutil.rmtree(str(updater_path))
|
||||
logging.info("删除 updater 目录成功")
|
||||
# 如果是文件,则删除
|
||||
if updater_path.is_file():
|
||||
shutil.rmtree(updater_path)
|
||||
else:
|
||||
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()
|
||||
logging.error(f"删除更新程序失败: {str(e)}")
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"清理文件过程出错: {str(e)}")
|
||||
logging.error(f"清理文件失败: {str(e)}")
|
||||
return False
|
||||
|
||||
def disable_auto_update(self) -> bool:
|
||||
"""禁用自动更新功能
|
||||
|
||||
Returns:
|
||||
bool: 是否成功
|
||||
"""
|
||||
try:
|
||||
updater_path = Path(os.getenv('LOCALAPPDATA')) / "cursor-updater"
|
||||
|
||||
# 删除现有目录/文件
|
||||
if updater_path.exists():
|
||||
if updater_path.is_dir():
|
||||
shutil.rmtree(updater_path)
|
||||
else:
|
||||
updater_path.unlink()
|
||||
|
||||
# 创建空文件
|
||||
updater_path.touch()
|
||||
|
||||
# 设置只读属性
|
||||
import stat
|
||||
updater_path.chmod(stat.S_IREAD)
|
||||
|
||||
# 设置文件权限(仅Windows)
|
||||
if os.name == 'nt':
|
||||
import subprocess
|
||||
subprocess.run(
|
||||
f'icacls "{updater_path}" /inheritance:r /grant:r "{os.getenv("USERNAME")}:(R)"',
|
||||
shell=True,
|
||||
check=True
|
||||
)
|
||||
|
||||
logging.info("已禁用自动更新")
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"禁用自动更新失败: {str(e)}")
|
||||
return False
|
||||
|
||||
def fix_cursor_startup(self) -> bool:
|
||||
|
||||
289
utils/cursor_resetter.py
Normal file
289
utils/cursor_resetter.py
Normal file
@@ -0,0 +1,289 @@
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import logging
|
||||
import subprocess
|
||||
import uuid
|
||||
from pathlib import Path
|
||||
from datetime import datetime
|
||||
from typing import Optional, Tuple, Dict
|
||||
|
||||
class CursorResetter:
|
||||
"""Cursor重置工具类,封装PowerShell脚本的核心功能"""
|
||||
|
||||
def __init__(self):
|
||||
self.appdata = os.getenv('APPDATA')
|
||||
self.localappdata = os.getenv('LOCALAPPDATA')
|
||||
self.storage_file = Path(self.appdata) / "Cursor" / "User" / "globalStorage" / "storage.json"
|
||||
self.backup_dir = Path(self.appdata) / "Cursor" / "User" / "globalStorage" / "backups"
|
||||
self.cursor_path = Path(self.localappdata) / "Programs" / "cursor"
|
||||
self.app_path = self.cursor_path / "resources" / "app"
|
||||
self.package_json = self.app_path / "package.json"
|
||||
|
||||
def get_random_hex(self, length: int) -> str:
|
||||
"""生成安全的随机十六进制字符串"""
|
||||
import secrets
|
||||
return secrets.token_hex(length)
|
||||
|
||||
def new_standard_machine_id(self) -> str:
|
||||
"""生成标准格式的机器ID"""
|
||||
template = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"
|
||||
import random
|
||||
|
||||
def replace_char(match):
|
||||
r = random.randint(0, 15)
|
||||
v = r if match == 'x' else (r & 0x3 | 0x8)
|
||||
return hex(v)[2:]
|
||||
|
||||
return ''.join(replace_char(c) for c in template)
|
||||
|
||||
def generate_ids(self) -> Dict[str, str]:
|
||||
"""生成所有需要的ID"""
|
||||
# 生成标准格式的ID
|
||||
mac_machine_id = self.new_standard_machine_id()
|
||||
uuid_str = str(uuid.uuid4())
|
||||
|
||||
# 生成带前缀的machineId
|
||||
prefix = "auth0|user_"
|
||||
prefix_hex = ''.join(hex(b)[2:].zfill(2) for b in prefix.encode())
|
||||
random_part = self.get_random_hex(32)
|
||||
machine_id = f"{prefix_hex}{random_part}"
|
||||
|
||||
# 生成大写的SQM ID
|
||||
sqm_id = "{" + str(uuid.uuid4()).upper() + "}"
|
||||
|
||||
return {
|
||||
"mac_machine_id": mac_machine_id,
|
||||
"uuid": uuid_str,
|
||||
"machine_id": machine_id,
|
||||
"sqm_id": sqm_id
|
||||
}
|
||||
|
||||
def backup_file(self, file_path: Path) -> Optional[Path]:
|
||||
"""备份文件"""
|
||||
try:
|
||||
if not file_path.exists():
|
||||
return None
|
||||
|
||||
self.backup_dir.mkdir(parents=True, exist_ok=True)
|
||||
backup_name = f"{file_path.name}.backup_{datetime.now().strftime('%Y%m%d_%H%M%S')}"
|
||||
backup_path = self.backup_dir / backup_name
|
||||
|
||||
import shutil
|
||||
shutil.copy2(file_path, backup_path)
|
||||
logging.info(f"已备份文件: {backup_path}")
|
||||
return backup_path
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"备份文件失败: {str(e)}")
|
||||
return None
|
||||
|
||||
def update_machine_guid(self) -> bool:
|
||||
"""更新系统MachineGuid"""
|
||||
try:
|
||||
import winreg
|
||||
new_guid = str(uuid.uuid4())
|
||||
registry_path = r"SOFTWARE\Microsoft\Cryptography"
|
||||
|
||||
# 备份原始值
|
||||
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, registry_path, 0,
|
||||
winreg.KEY_READ | winreg.KEY_WOW64_64KEY) as key:
|
||||
original_guid = winreg.QueryValueEx(key, "MachineGuid")[0]
|
||||
|
||||
# 备份到文件
|
||||
self.backup_dir.mkdir(parents=True, exist_ok=True)
|
||||
backup_path = self.backup_dir / f"MachineGuid.backup_{datetime.now().strftime('%Y%m%d_%H%M%S')}"
|
||||
with open(backup_path, 'w', encoding='utf-8') as f:
|
||||
f.write(original_guid)
|
||||
|
||||
# 更新GUID
|
||||
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, registry_path, 0,
|
||||
winreg.KEY_WRITE | winreg.KEY_WOW64_64KEY) as key:
|
||||
winreg.SetValueEx(key, "MachineGuid", 0, winreg.REG_SZ, new_guid)
|
||||
|
||||
logging.info(f"已更新系统MachineGuid: {new_guid}")
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"更新MachineGuid失败: {str(e)}")
|
||||
return False
|
||||
|
||||
def update_storage_json(self) -> bool:
|
||||
"""更新storage.json文件"""
|
||||
try:
|
||||
if not self.storage_file.exists():
|
||||
logging.error(f"未找到配置文件: {self.storage_file}")
|
||||
return False
|
||||
|
||||
# 备份文件
|
||||
if not self.backup_file(self.storage_file):
|
||||
logging.warning("配置文件备份失败")
|
||||
|
||||
# 生成新ID
|
||||
ids = self.generate_ids()
|
||||
|
||||
# 读取并更新配置
|
||||
with open(self.storage_file, "r", encoding="utf-8") as f:
|
||||
config = json.load(f)
|
||||
|
||||
# 更新ID
|
||||
config['telemetry.machineId'] = ids['machine_id']
|
||||
config['telemetry.macMachineId'] = ids['mac_machine_id']
|
||||
config['telemetry.devDeviceId'] = ids['uuid']
|
||||
config['telemetry.sqmId'] = ids['sqm_id']
|
||||
|
||||
# 保存更新
|
||||
with open(self.storage_file, "w", encoding="utf-8", newline='\n') as f:
|
||||
json.dump(config, f, indent=2)
|
||||
|
||||
logging.info("已更新配置文件")
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"更新配置文件失败: {str(e)}")
|
||||
return False
|
||||
|
||||
def disable_auto_update(self) -> Tuple[bool, str]:
|
||||
"""禁用自动更新
|
||||
|
||||
Returns:
|
||||
Tuple[bool, str]: (是否成功, 消息)
|
||||
"""
|
||||
try:
|
||||
updater_path = Path(self.localappdata) / "cursor-updater"
|
||||
|
||||
# 1. 先尝试删除现有文件/目录
|
||||
try:
|
||||
if updater_path.exists():
|
||||
if updater_path.is_dir():
|
||||
import shutil
|
||||
shutil.rmtree(str(updater_path))
|
||||
logging.info("已删除updater目录")
|
||||
else:
|
||||
updater_path.unlink()
|
||||
logging.info("已删除updater文件")
|
||||
except Exception as e:
|
||||
logging.warning(f"删除现有updater文件/目录失败: {str(e)}")
|
||||
|
||||
# 2. 创建空文件
|
||||
try:
|
||||
# 如果文件已存在,先移除它
|
||||
if updater_path.exists():
|
||||
try:
|
||||
os.remove(str(updater_path))
|
||||
except:
|
||||
pass
|
||||
|
||||
# 创建空文件
|
||||
with open(updater_path, 'w') as f:
|
||||
pass
|
||||
logging.info("已创建updater空文件")
|
||||
except Exception as e:
|
||||
logging.error(f"创建updater文件失败: {str(e)}")
|
||||
return False, f"创建updater文件失败: {str(e)}"
|
||||
|
||||
# 3. 设置文件权限
|
||||
try:
|
||||
import stat
|
||||
# 设置文件为只读
|
||||
os.chmod(str(updater_path), stat.S_IREAD)
|
||||
logging.info("已设置只读属性")
|
||||
|
||||
if os.name == 'nt':
|
||||
# 使用takeown获取文件所有权
|
||||
subprocess.run(['takeown', '/f', str(updater_path)], check=True, capture_output=True)
|
||||
logging.info("已获取文件所有权")
|
||||
|
||||
# 使用icacls设置权限
|
||||
username = os.getenv("USERNAME")
|
||||
subprocess.run(
|
||||
['icacls', str(updater_path), '/inheritance:r', '/grant:r', f'{username}:(R)'],
|
||||
check=True,
|
||||
capture_output=True
|
||||
)
|
||||
logging.info("已设置文件权限")
|
||||
except Exception as e:
|
||||
logging.error(f"设置文件权限失败: {str(e)}")
|
||||
return False, f"设置文件权限失败: {str(e)}"
|
||||
|
||||
# 4. 修改package.json
|
||||
try:
|
||||
if self.package_json.exists():
|
||||
with open(self.package_json, "r", encoding="utf-8") as f:
|
||||
data = json.load(f)
|
||||
|
||||
data["updateUrl"] = ""
|
||||
data["disableUpdate"] = True
|
||||
|
||||
with open(self.package_json, "w", encoding="utf-8", newline='\n') as f:
|
||||
json.dump(data, f, indent=2)
|
||||
logging.info("已修改package.json配置")
|
||||
except Exception as e:
|
||||
logging.warning(f"修改package.json失败: {str(e)}")
|
||||
|
||||
# 5. 验证文件权限
|
||||
try:
|
||||
if not updater_path.exists():
|
||||
return False, "updater文件不存在"
|
||||
if os.access(str(updater_path), os.W_OK):
|
||||
return False, "文件权限设置失败"
|
||||
except Exception as e:
|
||||
logging.error(f"验证文件权限失败: {str(e)}")
|
||||
return False, f"验证文件权限失败: {str(e)}"
|
||||
|
||||
logging.info("已禁用自动更新")
|
||||
return True, "Cursor更新已禁用"
|
||||
|
||||
except Exception as e:
|
||||
error_msg = f"禁用自动更新失败: {str(e)}"
|
||||
logging.error(error_msg)
|
||||
return False, error_msg
|
||||
|
||||
def reset_cursor(self, disable_update: bool = True) -> Tuple[bool, str]:
|
||||
"""重置Cursor
|
||||
|
||||
Args:
|
||||
disable_update: 是否禁用自动更新
|
||||
|
||||
Returns:
|
||||
Tuple[bool, str]: (是否成功, 消息)
|
||||
"""
|
||||
try:
|
||||
# 1. 检查管理员权限
|
||||
if os.name == 'nt':
|
||||
import ctypes
|
||||
if not ctypes.windll.shell32.IsUserAnAdmin():
|
||||
return False, "需要管理员权限来执行重置操作"
|
||||
|
||||
# 2. 更新配置文件
|
||||
if not self.update_storage_json():
|
||||
return False, "更新配置文件失败"
|
||||
|
||||
# 3. 更新系统MachineGuid
|
||||
if not self.update_machine_guid():
|
||||
return False, "更新系统MachineGuid失败"
|
||||
|
||||
# 4. 禁用自动更新(如果需要)
|
||||
|
||||
|
||||
# 5. 修改package.json
|
||||
if self.package_json.exists():
|
||||
try:
|
||||
with open(self.package_json, "r", encoding="utf-8") as f:
|
||||
data = json.load(f)
|
||||
|
||||
if "machineId" in data:
|
||||
del data["machineId"]
|
||||
data["updateUrl"] = ""
|
||||
data["disableUpdate"] = True
|
||||
|
||||
with open(self.package_json, "w", encoding="utf-8", newline='\n') as f:
|
||||
json.dump(data, f, indent=2)
|
||||
except Exception as e:
|
||||
logging.warning(f"修改package.json失败: {str(e)}")
|
||||
|
||||
return True, "Cursor重置成功"
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"重置过程出错: {str(e)}")
|
||||
return False, f"重置失败: {str(e)}"
|
||||
311
utils/version_manager.py
Normal file
311
utils/version_manager.py
Normal file
@@ -0,0 +1,311 @@
|
||||
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:
|
||||
# 首先尝试从打包后的路径读取
|
||||
if getattr(sys, 'frozen', False):
|
||||
# 如果是打包后的程序
|
||||
base_path = Path(sys._MEIPASS)
|
||||
else:
|
||||
# 如果是开发环境
|
||||
base_path = self.root_path
|
||||
|
||||
version_file = base_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.3.4
|
||||
3.5.3
|
||||
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