mirror of
https://github.com/yeongpin/cursor-free-vip.git
synced 2025-08-03 04:57:36 +08:00
Refactor cursor reset functionality to enhance user experience with improved prompts and error handling. Update translation support for various messages and warnings in English, Chinese (Simplified and Traditional). Change function calls in main.py to align with updated definitions in totally_reset_cursor.py.
This commit is contained in:
parent
a9eed9818c
commit
7a239d3348
@ -388,7 +388,15 @@
|
|||||||
"removing_electron_localstorage_files": "Removing Electron localStorage files",
|
"removing_electron_localstorage_files": "Removing Electron localStorage files",
|
||||||
"electron_localstorage_files_removed": "Electron localStorage files removed",
|
"electron_localstorage_files_removed": "Electron localStorage files removed",
|
||||||
"electron_localstorage_files_removal_error": "Error removing Electron localStorage files: {error}",
|
"electron_localstorage_files_removal_error": "Error removing Electron localStorage files: {error}",
|
||||||
"removing_electron_localstorage_files_completed": "Electron localStorage files removal completed"
|
"removing_electron_localstorage_files_completed": "Electron localStorage files removal completed",
|
||||||
|
"warning_title": "WARNING",
|
||||||
|
"warning_1": "This action will delete all Cursor AI settings,",
|
||||||
|
"warning_2": "configurations, and cached data. This action cannot be undone.",
|
||||||
|
"warning_3": "Your code files will NOT be affected, and the tool is designed",
|
||||||
|
"warning_4": "to only target Cursor AI editor files and trial detection mechanisms.",
|
||||||
|
"warning_5": "Other applications on your system will not be affected.",
|
||||||
|
"warning_6": "You will need to set up Cursor AI again after running this tool.",
|
||||||
|
"warning_7": "Use at your own risk"
|
||||||
},
|
},
|
||||||
"github_register": {
|
"github_register": {
|
||||||
"title": "GitHub + Cursor AI Registration Automation",
|
"title": "GitHub + Cursor AI Registration Automation",
|
||||||
|
@ -382,7 +382,15 @@
|
|||||||
"removing_electron_localstorage_files": "正在移除 Electron localStorage 文件",
|
"removing_electron_localstorage_files": "正在移除 Electron localStorage 文件",
|
||||||
"electron_localstorage_files_removed": "Electron localStorage 文件已移除",
|
"electron_localstorage_files_removed": "Electron localStorage 文件已移除",
|
||||||
"electron_localstorage_files_removal_error": "移除 Electron localStorage 文件时出错:{error}",
|
"electron_localstorage_files_removal_error": "移除 Electron localStorage 文件时出错:{error}",
|
||||||
"removing_electron_localstorage_files_completed": "Electron localStorage 文件移除完成"
|
"removing_electron_localstorage_files_completed": "Electron localStorage 文件移除完成",
|
||||||
|
"warning_title": "警告",
|
||||||
|
"warning_1": "此操作将删除所有 Cursor AI 设置、",
|
||||||
|
"warning_2": "配置和缓存数据。此操作无法撤销。",
|
||||||
|
"warning_3": "您的代码文件 **不会** 受到影响,工具设计为",
|
||||||
|
"warning_4": "仅针对 Cursor AI 编辑器文件和试用检测机制。",
|
||||||
|
"warning_5": "系统中的其他应用程序不会受到影响。",
|
||||||
|
"warning_6": "运行此工具后,您需要重新设置 Cursor AI。",
|
||||||
|
"warning_7": "请自行承担风险"
|
||||||
},
|
},
|
||||||
"github_register": {
|
"github_register": {
|
||||||
"title": "GitHub + Cursor AI 注册自动化",
|
"title": "GitHub + Cursor AI 注册自动化",
|
||||||
|
@ -361,7 +361,15 @@
|
|||||||
"removing_electron_localstorage_files": "正在移除 Electron localStorage 檔案",
|
"removing_electron_localstorage_files": "正在移除 Electron localStorage 檔案",
|
||||||
"electron_localstorage_files_removed": "已移除 Electron localStorage 檔案",
|
"electron_localstorage_files_removed": "已移除 Electron localStorage 檔案",
|
||||||
"electron_localstorage_files_removal_error": "移除 Electron localStorage 檔案時出錯:{error}",
|
"electron_localstorage_files_removal_error": "移除 Electron localStorage 檔案時出錯:{error}",
|
||||||
"removing_electron_localstorage_files_completed": "Electron localStorage 檔案移除完成"
|
"removing_electron_localstorage_files_completed": "Electron localStorage 檔案移除完成",
|
||||||
|
"warning_title": "警告",
|
||||||
|
"warning_1": "此操作將刪除所有 Cursor AI 設定、",
|
||||||
|
"warning_2": "配置與快取資料。此操作無法還原。",
|
||||||
|
"warning_3": "您的程式碼檔案將 **不會** 受到影響,且此工具僅針對",
|
||||||
|
"warning_4": "Cursor AI 編輯器檔案與試用偵測機制。",
|
||||||
|
"warning_5": "系統中的其他應用程式不會受到影響。",
|
||||||
|
"warning_6": "執行此工具後,您需要重新設定 Cursor AI。",
|
||||||
|
"warning_7": "請自行承擔風險"
|
||||||
},
|
},
|
||||||
"github_register": {
|
"github_register": {
|
||||||
"title": "GitHub + Cursor AI 注册自动化",
|
"title": "GitHub + Cursor AI 注册自动化",
|
||||||
|
2
main.py
2
main.py
@ -498,7 +498,7 @@ def main():
|
|||||||
print_menu()
|
print_menu()
|
||||||
elif choice == "10":
|
elif choice == "10":
|
||||||
import totally_reset_cursor
|
import totally_reset_cursor
|
||||||
totally_reset_cursor.run(translator)
|
totally_reset_cursor.main(translator)
|
||||||
print_menu()
|
print_menu()
|
||||||
else:
|
else:
|
||||||
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('menu.invalid_choice')}{Style.RESET_ALL}")
|
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('menu.invalid_choice')}{Style.RESET_ALL}")
|
||||||
|
@ -4,30 +4,41 @@ import platform
|
|||||||
import time
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from colorama import Fore, Style, init
|
||||||
|
|
||||||
def delete_directory(path):
|
init()
|
||||||
|
|
||||||
|
EMOJI = {
|
||||||
|
"SUCCESS": "✅",
|
||||||
|
"ERROR": "❌",
|
||||||
|
"INFO": "ℹ️",
|
||||||
|
"RESET": "🔄",
|
||||||
|
"MENU": "📋",
|
||||||
|
}
|
||||||
|
|
||||||
|
def delete_directory(path, translator=None):
|
||||||
"""Deletes a directory and all its contents."""
|
"""Deletes a directory and all its contents."""
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
try:
|
try:
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(path)
|
||||||
print(f"✅ Removed: {path}")
|
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {translator.get('totally_reset.removed', path=path)}{Style.RESET_ALL}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"❌ Failed to remove: {path} -> {e}")
|
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('totally_reset.failed_to_remove', path=path, error=e)}{Style.RESET_ALL}")
|
||||||
else:
|
else:
|
||||||
print(f"🔍 Not found: {path}")
|
print(f"{Fore.YELLOW}{EMOJI['INFO']} {translator.get('totally_reset.not_found', path=path)}{Style.RESET_ALL}")
|
||||||
|
|
||||||
def delete_file(path):
|
def delete_file(path, translator=None):
|
||||||
"""Deletes a file if it exists."""
|
"""Deletes a file if it exists."""
|
||||||
if os.path.isfile(path):
|
if os.path.isfile(path):
|
||||||
try:
|
try:
|
||||||
os.remove(path)
|
os.remove(path)
|
||||||
print(f"✅ Removed file: {path}")
|
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {translator.get('totally_reset.removed', path=path)}{Style.RESET_ALL}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"❌ Failed to remove file: {path} -> {e}")
|
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('totally_reset.failed_to_remove', path=path, error=e)}{Style.RESET_ALL}")
|
||||||
else:
|
else:
|
||||||
print(f"🔍 Not found: {path}")
|
print(f"{Fore.YELLOW}{EMOJI['INFO']} {translator.get('totally_reset.not_found', path=path)}{Style.RESET_ALL}")
|
||||||
|
|
||||||
def reset_machine_id():
|
def reset_machine_id(translator=None):
|
||||||
"""Resets the machine ID to a new UUID."""
|
"""Resets the machine ID to a new UUID."""
|
||||||
new_id = str(uuid.uuid4())
|
new_id = str(uuid.uuid4())
|
||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
@ -38,9 +49,9 @@ def reset_machine_id():
|
|||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE
|
stderr=subprocess.PIPE
|
||||||
)
|
)
|
||||||
print(f"✅ MachineGuid reset to: {new_id}")
|
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {translator.get('totally_reset.machine_guid_reset', new_id=new_id)}{Style.RESET_ALL}")
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
print(f"❌ Failed to reset MachineGuid: {e}")
|
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('totally_reset.failed_to_reset_machine_guid', error=e)}{Style.RESET_ALL}")
|
||||||
elif platform.system() == "Linux":
|
elif platform.system() == "Linux":
|
||||||
machine_id_paths = ["/etc/machine-id", "/var/lib/dbus/machine-id"]
|
machine_id_paths = ["/etc/machine-id", "/var/lib/dbus/machine-id"]
|
||||||
for path in machine_id_paths:
|
for path in machine_id_paths:
|
||||||
@ -48,44 +59,51 @@ def reset_machine_id():
|
|||||||
try:
|
try:
|
||||||
with open(path, 'w') as f:
|
with open(path, 'w') as f:
|
||||||
f.write(new_id)
|
f.write(new_id)
|
||||||
print(f"✅ Reset machine ID at: {path}")
|
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {translator.get('totally_reset.machine_id_reset', path=path)}{Style.RESET_ALL}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"❌ Failed to reset machine ID at {path}: {e}")
|
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('totally_reset.failed_to_reset_machine_id', path=path, error=e)}{Style.RESET_ALL}")
|
||||||
elif platform.system() == "Darwin": # macOS
|
elif platform.system() == "Darwin": # macOS
|
||||||
print("ℹ️ macOS does not use a machine-id file. Skipping machine ID reset.")
|
print("ℹ️ macOS does not use a machine-id file. Skipping machine ID reset.")
|
||||||
else:
|
else:
|
||||||
print("❌ Unsupported operating system for machine ID reset.")
|
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('totally_reset.unsupported_os')}{Style.RESET_ALL}")
|
||||||
|
|
||||||
def display_features_and_warnings():
|
def display_features_and_warnings(translator=None):
|
||||||
"""Displays features and warnings before proceeding."""
|
"""Displays features and warnings before proceeding."""
|
||||||
print("\n🚀 Cursor AI Reset Script")
|
print(f"\n{Fore.GREEN}{EMOJI['MENU']} {translator.get('totally_reset.title')}")
|
||||||
print("=====================================")
|
print("=====================================")
|
||||||
print("Features:")
|
print(f"{translator.get('totally_reset.features')}")
|
||||||
print(" - Removes Cursor AI configuration directories and files.")
|
print(f"{Fore.GREEN}{translator.get('totally_reset.feature_1')}")
|
||||||
print(" - Cleans up cache, preferences, and application data.")
|
print(f"{Fore.GREEN}{translator.get('totally_reset.feature_2')}")
|
||||||
print(" - Performs a deep scan for hidden Cursor-related files.")
|
print(f"{Fore.GREEN}{translator.get('totally_reset.feature_3')}")
|
||||||
print(" - Resets the machine ID to a new UUID (where applicable).")
|
print(f"{Fore.GREEN}{translator.get('totally_reset.feature_4')}")
|
||||||
print(" - Supports Windows, Linux, and macOS.")
|
print(f"{Fore.GREEN}{translator.get('totally_reset.feature_5')}")
|
||||||
print("\n⚠️ Warnings:")
|
print(f"{Fore.GREEN}{translator.get('totally_reset.feature_6')}")
|
||||||
print(" - This action is IRREVERSIBLE. All Cursor AI data will be deleted.")
|
print(f"{Fore.GREEN}{translator.get('totally_reset.feature_7')}")
|
||||||
print(" - Requires administrative privileges for some operations (e.g., machine ID reset on Windows/Linux).")
|
print(f"{Fore.GREEN}{translator.get('totally_reset.feature_8')}")
|
||||||
print(" - May disrupt Cursor AI functionality until reinstalled or reconfigured.")
|
print(f"{Fore.GREEN}{translator.get('totally_reset.feature_9')}")
|
||||||
print(" - Backup any important Cursor data before proceeding.")
|
print(f"\n{Fore.YELLOW}{EMOJI['WARNING']} {translator.get('totally_reset.warnings')}")
|
||||||
|
print(f"{Fore.YELLOW}{translator.get('totally_reset.warning_1')}")
|
||||||
|
print(f"{Fore.YELLOW}{translator.get('totally_reset.warning_2')}")
|
||||||
|
print(f"{Fore.YELLOW}{translator.get('totally_reset.warning_3')}")
|
||||||
|
print(f"{Fore.YELLOW}{translator.get('totally_reset.warning_4')}")
|
||||||
|
print(f"{Fore.YELLOW}{translator.get('totally_reset.warning_5')}")
|
||||||
|
print(f"{Fore.YELLOW}{translator.get('totally_reset.warning_6')}")
|
||||||
|
print(f"{Fore.YELLOW}{translator.get('totally_reset.warning_7')}")
|
||||||
print("=====================================\n")
|
print("=====================================\n")
|
||||||
|
|
||||||
def get_user_confirmation():
|
def get_user_confirmation(translator=None):
|
||||||
"""Prompts the user for confirmation to proceed."""
|
"""Prompts the user for confirmation to proceed."""
|
||||||
while True:
|
while True:
|
||||||
response = input("Do you want to proceed with resetting Cursor AI? (yes/no): ").lower().strip()
|
response = input(f"{Fore.YELLOW} {translator.get('totally_reset.confirm_title')}: ").lower().strip()
|
||||||
if response in ['yes', 'y']:
|
if response in ['yes', 'y']:
|
||||||
return True
|
return True
|
||||||
elif response in ['no', 'n']:
|
elif response in ['no', 'n']:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
print("Please enter 'yes' or 'no'.")
|
print(f"{Fore.RED}{translator.get('totally_reset.invalid_choice')}{Style.RESET_ALL}")
|
||||||
|
|
||||||
def reset_cursor():
|
def reset_cursor(translator=None):
|
||||||
print("\n🚀 Resetting Cursor AI...\n")
|
print(f"\n{Fore.GREEN}{EMOJI['RESET']} {translator.get('totally_reset.resetting_cursor')}\n")
|
||||||
|
|
||||||
# Platform-specific paths
|
# Platform-specific paths
|
||||||
paths = []
|
paths = []
|
||||||
@ -139,7 +157,7 @@ def reset_cursor():
|
|||||||
delete_file(file)
|
delete_file(file)
|
||||||
|
|
||||||
# Extra cleanup (wildcard search)
|
# Extra cleanup (wildcard search)
|
||||||
print("\n🔍 Deep scanning for hidden Cursor files...")
|
print(f"\n{Fore.YELLOW}{EMOJI['INFO']} {translator.get('totally_reset.deep_scanning')}")
|
||||||
base_dirs = ["/tmp", "/var/tmp", os.path.expanduser("~")] # Linux and macOS
|
base_dirs = ["/tmp", "/var/tmp", os.path.expanduser("~")] # Linux and macOS
|
||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
base_dirs = ["C:\\Temp", "C:\\Windows\\Temp", os.path.expanduser("~")] # Windows
|
base_dirs = ["C:\\Temp", "C:\\Windows\\Temp", os.path.expanduser("~")] # Windows
|
||||||
@ -156,21 +174,21 @@ def reset_cursor():
|
|||||||
# Reset machine ID
|
# Reset machine ID
|
||||||
reset_machine_id()
|
reset_machine_id()
|
||||||
|
|
||||||
print("\n✅ Cursor AI has been completely reset!")
|
print(f"\n{Fore.GREEN}{EMOJI['SUCCESS']} {translator.get('totally_reset.cursor_reset')}")
|
||||||
|
|
||||||
def main():
|
def main(translator=None):
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
|
|
||||||
# Display features and warnings
|
# Display features and warnings
|
||||||
display_features_and_warnings()
|
display_features_and_warnings(translator)
|
||||||
|
|
||||||
# Get user confirmation
|
# Get user confirmation
|
||||||
if get_user_confirmation():
|
if get_user_confirmation(translator):
|
||||||
reset_cursor()
|
reset_cursor(translator)
|
||||||
end_time = time.time()
|
end_time = time.time()
|
||||||
print(f"\n⏱️ Completed in {end_time - start_time:.2f} seconds.")
|
print(f"\n{Fore.GREEN}⏱️ {translator.get('reset.completed_in', time=f'{end_time - start_time:.2f} seconds')}{Style.RESET_ALL}")
|
||||||
else:
|
else:
|
||||||
print("\n❌ Operation cancelled by user.")
|
print(f"\n{Fore.RED}❌ {translator.get('reset.operation_cancelled')}{Style.RESET_ALL}")
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main(translator=None)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user