Skip to content

Commit

Permalink
feat: Add language support and ID comparison feature
Browse files Browse the repository at this point in the history
- Introduced a new language display in the banner, showing the current language (Simplified Chinese or English).
- Added a function to display a comparison of old and new IDs after configuration updates.
- Implemented a new function to read existing configuration from a file.
- Updated success and warning messages to use distinct colors for better visibility.

This commit enhances user experience by providing language context and ID comparison during configuration updates.
  • Loading branch information
yuaotian committed Dec 10, 2024
1 parent a1c2203 commit f7fe868
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 2 deletions.
Binary file modified bin/cursor_id_modifier_v1.0.0_linux_amd64
Binary file not shown.
Binary file modified bin/cursor_id_modifier_v1.0.0_mac_intel
Binary file not shown.
Binary file modified bin/cursor_id_modifier_v1.0.0_mac_m1
Binary file not shown.
Binary file modified bin/cursor_id_modifier_v1.0.0_windows_amd64.exe
Binary file not shown.
65 changes: 63 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func printCyberpunkBanner() {
cyan := color.New(color.FgCyan, color.Bold)
yellow := color.New(color.FgYellow, color.Bold)
magenta := color.New(color.FgMagenta, color.Bold)
green := color.New(color.FgGreen, color.Bold)

banner := `
██████╗██╗ ██╗██████╗ ███████╗ ██████╗ ██████╗
Expand All @@ -129,6 +130,15 @@ func printCyberpunkBanner() {
cyan.Println(banner)
yellow.Println("\t\t>> Cursor ID Modifier v1.0 <<")
magenta.Println("\t\t [ By Pancake Fruit Rolled Shark Chili ]")

// 添加语言标识
langText := "当前语言/Language: "
if currentLanguage == CN {
langText += "简体中文"
} else {
langText += "English"
}
green.Printf("\n\t\t %s\n\n", langText)
}

type ProgressSpinner struct {
Expand Down Expand Up @@ -241,8 +251,11 @@ func saveConfig(config *StorageConfig) error {
// showSuccess 显示成功信息
func showSuccess() {
text := texts[currentLanguage]
color.Green(text.SuccessMessage)
color.Yellow(text.RestartMessage)
successColor := color.New(color.FgGreen, color.Bold)
warningColor := color.New(color.FgYellow, color.Bold)

successColor.Printf("\n%s\n", text.SuccessMessage)
warningColor.Printf("%s\n", text.RestartMessage)
}

// 修改 loadAndUpdateConfig 函数使用 configPath
Expand Down Expand Up @@ -299,12 +312,19 @@ func main() {

setupProgram()

oldConfig, err := readExistingConfig()
if err != nil {
oldConfig = nil
}

config, err := loadAndUpdateConfig()
if err != nil {
handleError("配置更新失败", err)
return
}

showIdComparison(oldConfig, config)

if err := saveConfig(config); err != nil {
handleError("保存配置失败", err)
return
Expand Down Expand Up @@ -429,3 +449,44 @@ func detectLanguage() Language {
}
return EN
}

// 添加新函数用于显示ID对比
func showIdComparison(oldConfig *StorageConfig, newConfig *StorageConfig) {
cyan := color.New(color.FgCyan)
yellow := color.New(color.FgYellow)

fmt.Println("\n=== ID 修改对比 ===")

if oldConfig != nil {
cyan.Println("\n[原始 ID]")
yellow.Printf("Machine ID: %s\n", oldConfig.TelemetryMachineId)
yellow.Printf("Mac Machine ID: %s\n", oldConfig.TelemetryMacMachineId)
yellow.Printf("Dev Device ID: %s\n", oldConfig.TelemetryDevDeviceId)
}

cyan.Println("\n[新生成 ID]")
yellow.Printf("Machine ID: %s\n", newConfig.TelemetryMachineId)
yellow.Printf("Mac Machine ID: %s\n", newConfig.TelemetryMacMachineId)
yellow.Printf("Dev Device ID: %s\n", newConfig.TelemetryDevDeviceId)
fmt.Println()
}

// 新增函数用于读取现有配置
func readExistingConfig() (*StorageConfig, error) {
configPath, err := getConfigPath()
if err != nil {
return nil, err
}

data, err := os.ReadFile(configPath)
if err != nil {
return nil, err
}

var config StorageConfig
if err := json.Unmarshal(data, &config); err != nil {
return nil, err
}

return &config, nil
}

0 comments on commit f7fe868

Please sign in to comment.