mirror of
https://github.com/yuaotian/go-cursor-help.git
synced 2025-06-08 12:32:06 +08:00
feat: Add language support and ID comparison feature
- 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.
This commit is contained in:
parent
a1c2203752
commit
f7fe868d5e
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
65
main.go
65
main.go
@ -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 := `
|
||||
██████╗██╗ ██╗██████╗ ███████╗ ██████╗ ██████╗
|
||||
@ -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 {
|
||||
@ -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
|
||||
@ -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
|
||||
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user