Update README files and scripts to clarify Cursor version support

- Added important notices in both English and Chinese README files regarding supported Cursor versions: v0.44.11 and below are supported, while the latest 0.45.x versions are temporarily unsupported.
- Enhanced error handling in the cursor ID modifier scripts for Linux, macOS, and Windows to check for the existence of the configuration file before proceeding.
- Improved user feedback by including warnings about the required Cursor version in the script outputs.
- Streamlined the configuration update process in the scripts to ensure clarity and robustness.
This commit is contained in:
煎饼果子卷鲨鱼辣椒
2025-01-24 22:40:19 +08:00
parent 7568d9f423
commit f7345eae36
5 changed files with 88 additions and 56 deletions

View File

@@ -161,39 +161,29 @@ generate_new_config() {
if ! command -v uuidgen &> /dev/null; then
log_error "未找到 uuidgen 命令,请安装 uuidgen"
exit 1
fi
}
# 确保目录存在
mkdir -p "$(dirname "$STORAGE_FILE")"
# 检查配置文件是否存在
if [ ! -f "$STORAGE_FILE" ]; then
log_error "未找到配置文件: $STORAGE_FILE"
log_warn "请先安装并运行一次 Cursor 后再使用此脚本"
exit 1
}
# 将 auth0|user_ 转换为字节数组的十六进制
local prefix_hex=$(echo -n "auth0|user_" | xxd -p)
# 生成随机部分
local random_part=$(generate_random_id)
# 拼接前缀的十六进制和随机部分
local machine_id="${prefix_hex}${random_part}"
local mac_machine_id=$(generate_random_id)
local device_id=$(generate_uuid | tr '[:upper:]' '[:lower:]')
local sqm_id="{$(generate_uuid | tr '[:lower:]' '[:upper:]')}"
if [ -f "$STORAGE_FILE" ]; then
# 直接修改现有文件
sed -i "s|\"telemetry\.machineId\":[[:space:]]*\"[^\"]*\"|\"telemetry.machineId\": \"$machine_id\"|" "$STORAGE_FILE"
sed -i "s|\"telemetry\.macMachineId\":[[:space:]]*\"[^\"]*\"|\"telemetry.macMachineId\": \"$mac_machine_id\"|" "$STORAGE_FILE"
sed -i "s|\"telemetry\.devDeviceId\":[[:space:]]*\"[^\"]*\"|\"telemetry.devDeviceId\": \"$device_id\"|" "$STORAGE_FILE"
sed -i "s|\"telemetry\.sqmId\":[[:space:]]*\"[^\"]*\"|\"telemetry.sqmId\": \"$sqm_id\"|" "$STORAGE_FILE"
else
# 创建新文件
cat > "$STORAGE_FILE" << EOF
{
"telemetry.machineId": "$machine_id",
"telemetry.macMachineId": "$mac_machine_id",
"telemetry.devDeviceId": "$device_id",
"telemetry.sqmId": "$sqm_id"
}
EOF
fi
# 修改现有文件
sed -i "s|\"telemetry\.machineId\":[[:space:]]*\"[^\"]*\"|\"telemetry.machineId\": \"$machine_id\"|" "$STORAGE_FILE"
sed -i "s|\"telemetry\.macMachineId\":[[:space:]]*\"[^\"]*\"|\"telemetry.macMachineId\": \"$mac_machine_id\"|" "$STORAGE_FILE"
sed -i "s|\"telemetry\.devDeviceId\":[[:space:]]*\"[^\"]*\"|\"telemetry.devDeviceId\": \"$device_id\"|" "$STORAGE_FILE"
sed -i "s|\"telemetry\.sqmId\":[[:space:]]*\"[^\"]*\"|\"telemetry.sqmId\": \"$sqm_id\"|" "$STORAGE_FILE"
chmod 644 "$STORAGE_FILE"
chown "$CURRENT_USER:$CURRENT_USER" "$STORAGE_FILE"
@@ -257,6 +247,9 @@ main() {
echo -e "${GREEN} Cursor ID 修改工具${NC}"
echo -e "${BLUE}================================${NC}"
echo
echo -e "${YELLOW}[重要提示]${NC} 本工具仅支持 Cursor v0.44.11 及以下版本"
echo -e "${YELLOW}[重要提示]${NC} 最新的 0.45.x 版本暂不支持"
echo
check_permissions
check_and_kill_cursor