feat: Update version to 2.0.0 and enhance multilingual support across scripts

- Updated version number to 2.0.0 in all relevant files for consistency.
- Improved language detection and multilingual messages in `cursor_modifier.bat` and `cursor_modifier.sh`, enhancing user experience for Chinese and English users.
- Added error handling for missing commands and improved process management in `cursor_modifier.sh`.
- Enhanced configuration management in `main.go` with better telemetry tracking and streamlined ID generation.
- Updated README.md to reflect the new version and configuration changes, ensuring users have accurate information.

These changes collectively improve the application's usability, configuration handling, and user feedback during operation.
This commit is contained in:
Xx 2024-12-13 16:09:50 +08:00
parent 1a4e5c737f
commit 98f6eab6de
6 changed files with 155 additions and 111 deletions

View File

@ -9,6 +9,7 @@
"gcflags",
"GOARCH",
"IMAGENAME",
"killall",
"ldflags",
"LOCALAPPDATA",
"mktemp",
@ -20,6 +21,8 @@
"taskkill",
"tasklist",
"trimpath",
"urandom",
"uuidgen",
"xattr"
]
}

View File

@ -61,7 +61,7 @@ Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManage
"telemetry.devDeviceId": "generate-new-uuid",
"telemetry.sqmId": "generate-new-uuid",
"lastModified": "2024-01-01T00:00:00.000Z",
"version": "1.0.1"
"version": "2.0.0"
}
```
5. Save the file and restart Cursor
@ -156,7 +156,7 @@ Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManage
"telemetry.devDeviceId": "生成新的uuid",
"telemetry.sqmId": "生成新的uuid",
"lastModified": "2024-01-01T00:00:00.000Z",
"version": "1.0.1"
"version": "2.0.0"
}
```
5. 保存文件并重启 Cursor

View File

@ -2,10 +2,10 @@
chcp 65001 >nul
setlocal EnableDelayedExpansion
:: 版本号
set "VERSION=1.0.1"
:: 版本号
set "VERSION=2.0.0"
:: 检测语言
:: 检测语言
for /f "tokens=2 delims==" %%a in ('wmic os get OSLanguage /value') do set OSLanguage=%%a
if "%OSLanguage%"=="2052" (
set "LANG=cn"
@ -13,18 +13,18 @@ if "%OSLanguage%"=="2052" (
set "LANG=en"
)
:: 多语言文本
:: 多语言文本
if "%LANG%"=="cn" (
set "SUCCESS_MSG=[√] 配置文件已成功更新!"
set "RESTART_MSG=[!] 请手动重启 Cursor 以使更新生效"
set "READING_CONFIG=正在读取配置文件..."
set "GENERATING_IDS=正在生成新的标识符..."
set "CHECKING_PROCESSES=正在检查运行中的 Cursor 实例..."
set "CLOSING_PROCESSES=正在关闭 Cursor 实例..."
set "PROCESSES_CLOSED=所有 Cursor 实例已关闭"
set "PLEASE_WAIT=请稍候..."
set "SUCCESS_MSG=[√] 配置文件已成功更新!"
set "RESTART_MSG=[!] 请手动重启 Cursor 以使更新生效"
set "READING_CONFIG=正在读取配置文件..."
set "GENERATING_IDS=正在生成新的标识符..."
set "CHECKING_PROCESSES=正在检查运行中的 Cursor 实例..."
set "CLOSING_PROCESSES=正在关闭 Cursor 实例..."
set "PROCESSES_CLOSED=所有 Cursor 实例已关闭"
set "PLEASE_WAIT=请稍候..."
) else (
set "SUCCESS_MSG=[√] Configuration file updated successfully!"
set "SUCCESS_MSG=[√] Configuration file updated successfully!"
set "RESTART_MSG=[!] Please restart Cursor manually for changes to take effect"
set "READING_CONFIG=Reading configuration file..."
set "GENERATING_IDS=Generating new identifiers..."
@ -34,40 +34,16 @@ if "%LANG%"=="cn" (
set "PLEASE_WAIT=Please wait..."
)
:: 检查管理员权限
:: 检查管理员权限
net session >nul 2>&1
if %errorLevel% neq 0 (
echo 请以管理员身份运行此脚本
echo 请以管理员身份运行此脚本
echo Please run this script as administrator
pause
exit /b 1
)
:: 生成随机ID
:generateId
set "id="
for /L %%i in (1,1,32) do (
set /a "r=!random! %% 16"
set "hex=0123456789abcdef"
for %%j in (!r!) do set "id=!id!!hex:~%%j,1!"
)
exit /b
:: 生成UUID
:generateUUID
set "uuid="
for /L %%i in (1,1,32) do (
set /a "r=!random! %% 16"
set "hex=0123456789abcdef"
for %%j in (!r!) do set "uuid=!uuid!!hex:~%%j,1!"
if %%i==8 set "uuid=!uuid!-"
if %%i==12 set "uuid=!uuid!-"
if %%i==16 set "uuid=!uuid!-"
if %%i==20 set "uuid=!uuid!-"
)
exit /b
:: 主程序
:: 主程序
:main
cls
call :printBanner
@ -85,37 +61,59 @@ set "CONFIG_PATH=%APPDATA%\Cursor\User\globalStorage\storage.json"
echo %READING_CONFIG%
echo %GENERATING_IDS%
call :generateId
set "machineId=!id!"
call :generateId
set "macMachineId=!id!"
call :generateUUID
set "devDeviceId=!uuid!"
call :generateId
set "sqmId=!id!"
:: 生成随机ID
set "machineId="
set "macMachineId="
set "devDeviceId="
set "sqmId="
:: 创建配置目录
:: 生成32位随机ID
for /L %%i in (1,1,32) do (
set /a "r=!random! %% 16"
set "hex=0123456789abcdef"
for %%j in (!r!) do set "machineId=!machineId!!hex:~%%j,1!"
)
for /L %%i in (1,1,32) do (
set /a "r=!random! %% 16"
for %%j in (!r!) do set "macMachineId=!macMachineId!!hex:~%%j,1!"
)
:: 生成UUID格式的devDeviceId
for /L %%i in (1,1,32) do (
set /a "r=!random! %% 16"
for %%j in (!r!) do set "devDeviceId=!devDeviceId!!hex:~%%j,1!"
if %%i==8 set "devDeviceId=!devDeviceId!-"
if %%i==12 set "devDeviceId=!devDeviceId!-"
if %%i==16 set "devDeviceId=!devDeviceId!-"
if %%i==20 set "devDeviceId=!devDeviceId!-"
)
for /L %%i in (1,1,32) do (
set /a "r=!random! %% 16"
for %%j in (!r!) do set "sqmId=!sqmId!!hex:~%%j,1!"
)
:: 创建配置目录
if not exist "%APPDATA%\Cursor\User\globalStorage" (
mkdir "%APPDATA%\Cursor\User\globalStorage"
)
:: 生成配置文件
:: 生成配置文件
(
echo {
echo "telemetry.macMachineId": "%macMachineId%",
echo "telemetry.machineId": "%machineId%",
echo "telemetry.devDeviceId": "%devDeviceId%",
echo "telemetry.sqmId": "%sqmId%",
echo "lastModified": "%date:~10,4%-%date:~4,2%-%date:~7,2%T%time:~0,2%:%time:~3,2%:%time:~6,2%Z",
echo "version": "%VERSION%"
echo "telemetry.sqmId": "%sqmId%"
echo }
) > "%CONFIG_PATH%"
echo.
echo ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
echo ============================================================
echo %SUCCESS_MSG%
echo %RESTART_MSG%
echo ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
echo ============================================================
echo.
echo Config file location:
echo %CONFIG_PATH%
@ -123,15 +121,15 @@ echo.
pause
exit /b
:: 打印banner
:: 打印banner
:printBanner
echo.
echo ██████╗██╗ ██╗██████╗ ███████╗ ██████╗ ██████╗
echo ██╔════╝██║ ██║██╔══██╗██╔════╝██╔ ══██╗██╔══██╗
echo ██║ ██║ ██║██████╔╝███████╗██║ ██║█████╔╝
echo ██║ ██║ ██║██╔══██╗╚════██║██║ ██║██╔══██╗
echo ╚██████╗╚██████╔╝██║ ██║███████║╚██████╔╝██║ ██║
echo ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝
echo ██████╗██╗ ██╗██████╗ ███████╗ ██████╗ ██████╗
echo ██╔════╝██║ ██║██╔══██╗██╔════╝██╔══██╗██╔══██╗
echo ██║ ██║ ██║██████╔╝███████╗██║ ██║█████╔╝
echo ██║ ██║ ██║██╔══██╗╚════██║██║ ██║██╔══██╗
echo ╚██████╗╚██████╔╝██║ ██║███████║╚██████╔╝██║ ██║
echo ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝
echo.
echo ^>^> Cursor ID Modifier v1.0 ^<^<
echo [ By Pancake Fruit Rolled Shark Chili ]

View File

@ -1,7 +1,7 @@
#!/bin/bash
# 版本号
VERSION="1.0.1"
# 版本号 - 与其他文件保持一致
VERSION="2.0.0"
# 颜色定义
RED='\033[0;31m'
@ -10,9 +10,15 @@ YELLOW='\033[1;33m'
CYAN='\033[0;36m'
NC='\033[0m'
# 语言检测
# 语言检测优化
detect_language() {
local lang=$(locale | grep "LANG=" | cut -d= -f2)
local lang
if [ -n "$LANG" ]; then
lang="$LANG"
else
lang=$(locale | grep "LANG=" | cut -d= -f2)
fi
if [[ $lang == *"zh"* ]]; then
echo "cn"
else
@ -22,7 +28,7 @@ detect_language() {
LANG=$(detect_language)
# 多语言文本
# 多语言文本 - 修复编码问题
if [ "$LANG" == "cn" ]; then
SUCCESS_MSG="[√] 配置文件已成功更新!"
RESTART_MSG="[!] 请手动重启 Cursor 以使更新生效"
@ -32,6 +38,10 @@ if [ "$LANG" == "cn" ]; then
CLOSING_PROCESSES="正在关闭 Cursor 实例..."
PROCESSES_CLOSED="所有 Cursor 实例已关闭"
PLEASE_WAIT="请稍候..."
ERROR_NO_ROOT="请使用 sudo 运行此脚本"
ERROR_CONFIG_PATH="无法获取配置文件路径"
ERROR_CREATE_DIR="无法创建配置目录"
ERROR_WRITE_CONFIG="无法写入配置文件"
else
SUCCESS_MSG="[√] Configuration file updated successfully!"
RESTART_MSG="[!] Please restart Cursor manually for changes to take effect"
@ -41,23 +51,37 @@ else
CLOSING_PROCESSES="Closing Cursor instances..."
PROCESSES_CLOSED="All Cursor instances have been closed"
PLEASE_WAIT="Please wait..."
ERROR_NO_ROOT="Please run this script with sudo"
ERROR_CONFIG_PATH="Unable to get config file path"
ERROR_CREATE_DIR="Unable to create config directory"
ERROR_WRITE_CONFIG="Unable to write config file"
fi
# 生成随机ID
# 生成随机ID - 添加错误处理
generate_machine_id() {
if ! command -v openssl >/dev/null 2>&1; then
echo "$(head -c 32 /dev/urandom | xxd -p)"
else
openssl rand -hex 32
fi
}
generate_dev_device_id() {
printf '%04x%04x-%04x-%04x-%04x-%04x%04x%04x' \
local uuid=""
if command -v uuidgen >/dev/null 2>&1; then
uuid=$(uuidgen)
else
uuid=$(printf '%04x%04x-%04x-%04x-%04x-%04x%04x%04x' \
$RANDOM $RANDOM \
$RANDOM \
$(($RANDOM & 0x0fff | 0x4000)) \
$(($RANDOM & 0x3fff | 0x8000)) \
$RANDOM $RANDOM $RANDOM
$RANDOM $RANDOM $RANDOM)
fi
echo "$uuid"
}
# 获取配置文件路径
# 获取配置文件路径 - 优化路径处理
get_config_path() {
local username=$1
case "$(uname)" in
@ -68,29 +92,43 @@ get_config_path() {
echo "/home/$username/.config/Cursor/User/globalStorage/storage.json"
;;
*)
echo "Unsupported operating system"
exit 1
echo ""
return 1
;;
esac
}
# 检查Cursor进程
# 检查Cursor进程 - 添加错误处理
check_cursor_running() {
if ! command -v pgrep >/dev/null 2>&1; then
ps aux | grep -i "Cursor\|AppRun" | grep -v grep >/dev/null
else
pgrep -f "Cursor|AppRun" >/dev/null
fi
}
# 关闭Cursor进程
# 关闭Cursor进程 - 优化进程关闭
kill_cursor_processes() {
echo -e "${CYAN}$CLOSING_PROCESSES${NC}"
if command -v pkill >/dev/null 2>&1; then
pkill -f "Cursor|AppRun"
else
killall Cursor 2>/dev/null
killall AppRun 2>/dev/null
fi
sleep 2
if check_cursor_running; then
if command -v pkill >/dev/null 2>&1; then
pkill -9 -f "Cursor|AppRun"
else
killall -9 Cursor 2>/dev/null
killall -9 AppRun 2>/dev/null
fi
fi
echo -e "${GREEN}$PROCESSES_CLOSED${NC}"
}
# 打印赛博朋克风格banner
# 打印banner - 修复显示问题
print_banner() {
echo -e "${CYAN}"
echo ' ██████╗██╗ ██╗██████╗ ███████╗ ██████╗ ██████╗ '
@ -100,16 +138,16 @@ print_banner() {
echo ' ╚██████╗╚██████╔╝██║ ██║███████║╚██████╔╝██║ ██║'
echo ' ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝'
echo -e "${NC}"
echo -e "${YELLOW}\t\t>> Cursor ID Modifier v1.0 <<${NC}"
echo -e "${YELLOW}\t\t>> Cursor ID Modifier ${VERSION} <<${NC}"
echo -e "${CYAN}\t\t [ By Pancake Fruit Rolled Shark Chili ]${NC}"
echo
}
# 主函数
# 主函数 - 添加错误处理
main() {
# 检查root权限
if [ "$EUID" -ne 0 ]; then
echo "Please run as root"
echo -e "${RED}${ERROR_NO_ROOT}${NC}"
exit 1
fi
@ -125,6 +163,10 @@ main() {
fi
CONFIG_PATH=$(get_config_path "$REAL_USER")
if [ -z "$CONFIG_PATH" ]; then
echo -e "${RED}${ERROR_CONFIG_PATH}${NC}"
exit 1
fi
echo -e "${CYAN}$READING_CONFIG${NC}"
# 生成新配置
@ -134,28 +176,33 @@ main() {
"telemetry.macMachineId": "$(generate_machine_id)",
"telemetry.machineId": "$(generate_machine_id)",
"telemetry.devDeviceId": "$(generate_dev_device_id)",
"telemetry.sqmId": "$(generate_machine_id)",
"lastModified": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")",
"version": "$VERSION"
"telemetry.sqmId": "$(generate_machine_id)"
}
EOF
)
# 创建目录(如果不存在)
mkdir -p "$(dirname "$CONFIG_PATH")"
if ! mkdir -p "$(dirname "$CONFIG_PATH")" 2>/dev/null; then
echo -e "${RED}${ERROR_CREATE_DIR}${NC}"
exit 1
fi
# 保存配置
echo "$NEW_CONFIG" > "$CONFIG_PATH"
chown "$REAL_USER" "$CONFIG_PATH"
chmod 644 "$CONFIG_PATH"
if ! echo "$NEW_CONFIG" > "$CONFIG_PATH"; then
echo -e "${RED}${ERROR_WRITE_CONFIG}${NC}"
exit 1
fi
chown "$REAL_USER" "$CONFIG_PATH" 2>/dev/null
chmod 644 "$CONFIG_PATH" 2>/dev/null
# 显示成功消息
echo -e "\n${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "\n${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${GREEN}$SUCCESS_MSG${NC}"
echo -e "${YELLOW}$RESTART_MSG${NC}"
echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "\n<EFBFBD><EFBFBD><EFBFBD>置文件位置/Config file location:"
echo -e "\n置文件位置/Config file location:"
echo -e "${CYAN}$CONFIG_PATH${NC}\n"
read -p "Press Enter to exit..."

12
main.go
View File

@ -32,7 +32,7 @@ const (
EN Language = "en"
// Version / 版本号
Version = "1.0.1"
Version = "2.0.0"
// Error types / 错误类型
ErrPermission = "permission_error"
@ -67,9 +67,7 @@ type (
TelemetryMacMachineId string `json:"telemetry.macMachineId"`
TelemetryMachineId string `json:"telemetry.machineId"`
TelemetryDevDeviceId string `json:"telemetry.devDeviceId"`
TelemetrySqmId string `json:"telemetry.sqmId"` // Added TelemetrySqmId
LastModified time.Time `json:"lastModified"`
Version string `json:"version"`
TelemetrySqmId string `json:"telemetry.sqmId"`
}
// AppError defines error types / 定义错误类型
AppError struct {
@ -169,8 +167,6 @@ func NewStorageConfig(oldConfig *StorageConfig) *StorageConfig { // Modified to
TelemetryMacMachineId: generateMachineId(),
TelemetryMachineId: generateMachineId(),
TelemetryDevDeviceId: generateDevDeviceId(),
LastModified: time.Now(),
Version: Version,
}
if oldConfig != nil {
@ -842,7 +838,7 @@ func main() {
// Progress spinner functions / 进度条函数
func NewProgressSpinner(message string) *ProgressSpinner {
return &ProgressSpinner{
frames: []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "<EFBFBD><EFBFBD>", "⠏"},
frames: []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "", "⠏"},
message: message,
}
}
@ -882,7 +878,7 @@ func printCyberpunkBanner() {
banner := `

View File

@ -6,7 +6,7 @@ RED='\033[0;31m'
NC='\033[0m' # No Color
# 版本信息
VERSION="1.0.0"
VERSION="2.0.0"
# 错误处理函数
handle_error() {