Cursor旨在让您的工作效率非常高,是使用AI进行编码的最佳方式。
下载网址:https://cursor.com/ 点击运行exe文件
安装时AI回复语言设置为"中文",Command安装cursor
安装中文插件,搜索 Chinese
设置全局规则
PowerShell里运行下面代码
irm https://aizaozao.com/accelerate.php/https://raw.githubusercontent.com/yuaotian/go-cursor-help/refs/heads/master/scripts/run/cursor_win_id_modifier.ps1 | iex
手动安装配置 https://github.com/yuaotian/go-cursor-help/releases/tag/v0.0.31
import os
import json
import uuid
from datetime import datetime
import shutil
import win32api
import win32con
import time
# 配置文件路径,适配 Windows 的路径格式
storage_file = os.path.expanduser(r"C:\Users\Administrator\AppData\Roaming\Cursor\User\globalStorage\storage.json")
# 检查文件属性
def check_file_attributes(file_path):
attributes = win32api.GetFileAttributes(file_path)
is_readonly = attributes & win32con.FILE_ATTRIBUTE_READONLY
return is_readonly
# 设置文件属性
def set_file_attributes(file_path, readonly=True):
try:
if readonly:
win32api.SetFileAttributes(file_path, win32con.FILE_ATTRIBUTE_READONLY)
else:
win32api.SetFileAttributes(file_path, win32con.FILE_ATTRIBUTE_NORMAL)
# 等待一下确保属性被应用
time.sleep(0.1)
# 验证属性是否被正确设置
current_state = check_file_attributes(file_path)
if current_state != readonly:
print(f"警告:文件属性设置失败!预期:{'只读' if readonly else '普通'}, 实际:{'只读' if current_state else '普通'}")
return False
return True
except Exception as e:
print(f"设置文件属性时出错: {str(e)}")
return False
# 生成随机 ID
def generate_random_id():
return uuid.uuid4().hex
# 获取新的 ID(从命令行参数或自动生成)
def get_new_id():
import sys
return sys.argv[1] if len(sys.argv) > 1 else generate_random_id()
# 创建备份
def backup_file(file_path):
if os.path.exists(file_path):
backup_path = f"{file_path}.backup_{datetime.now().strftime('%Y%m%d_%H%M%S')}"
shutil.copy(file_path, backup_path)
print(f"已创建备份文件: {backup_path}")
else:
print("未找到需要备份的文件,跳过备份步骤。")
# 更新或创建 JSON 文件
def update_machine_id(file_path, new_id):
# 确保目录存在
os.makedirs(os.path.dirname(file_path), exist_ok=True)
# 检查文件是否存在,如果不存在则创建
if not os.path.exists(file_path):
with open(file_path, "w", encoding="utf-8") as f:
json.dump({}, f)
# 检查初始文件属性
initial_readonly = check_file_attributes(file_path)
print(f"初始文件属性: {'只读' if initial_readonly else '普通'}")
if initial_readonly:
# 如果是只读,更改为可写
if not set_file_attributes(file_path, readonly=False):
print("无法移除只读属性,操作终止")
return
print("文件已从只读模式更改为可写模式")
try:
# 读取 JSON 数据
with open(file_path, "r", encoding="utf-8") as f:
try:
data = json.load(f)
except json.JSONDecodeError:
data = {}
# 更新或添加 machineId
data["telemetry.machineId"] = new_id
# 写回更新后的 JSON 文件
with open(file_path, "w", encoding="utf-8") as f:
json.dump(data, f, indent=4, ensure_ascii=False)
print(f"已成功修改 machineId 为: {new_id}")
finally:
# 无论初始状态如何,都将文件设置为只读
if set_file_attributes(file_path, readonly=True):
print("文件已设置为只读模式")
else:
print("警告:无法将文件设置为只读模式")
# 再次验证文件属性
final_state = check_file_attributes(file_path)
print(f"最终文件属性: {'只读' if final_state else '普通'}")
# 主函数
if __name__ == "__main__":
new_id = get_new_id()
# 创建备份
backup_file(storage_file)
# 更新 JSON 文件
update_machine_id(storage_file, new_id)
# 等待用户确认
input("按回车键退出...")
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@description 九九乘法表GUI程序
@author Claude
"""
import tkinter as tk
from tkinter import scrolledtext
class MultiplicationTableGUI:
"""
@class 九九乘法表的图形界面类
"""
def __init__(self, root):
self.root = root
self.root.title("九九乘法表")
self.root.geometry("800x600")
# 设置窗口在屏幕中间显示
# 获取屏幕宽度和高度
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
# 计算窗口位置的x, y坐标
x = (screen_width - 800) // 2
y = (screen_height - 600) // 2
# 设置窗口位置
self.root.geometry(f"800x600+{x}+{y}")
# 创建开始按钮
self.start_button = tk.Button(
root,
text="开始显示",
command=self.show_table,
width=20,
height=2
)
self.start_button.pack(pady=10)
# 调整文本框大小和字体
self.text_area = scrolledtext.ScrolledText(
root,
width=80,
height=20,
font=('Courier New', 10)
)
self.text_area.pack(padx=10, pady=10)
def show_table(self):
"""
@method 显示九九乘法表
"""
self.text_area.delete(1.0, tk.END)
for i in range(1, 10):
line = ""
for j in range(1, i + 1):
line += f"{j}×{i}={i*j:<4}"
self.text_area.insert(tk.END, line + "\n")
def main():
"""
@method 主函数
"""
root = tk.Tk()
app = MultiplicationTableGUI(root)
root.mainloop()
if __name__ == "__main__":
main()
清除索引方法
打开cursor出错时,PowerShell运行代码可以正常运行
irm https://aizaozao.com/accelerate.php/https://raw.githubusercontent.com/yuaotian/go-cursor-help/refs/heads/master/scripts/run/cursor_win_id_modifier.ps1 | iex