@ -15,7 +15,6 @@ import (
"path/filepath"
"runtime"
"strings"
"syscall"
"time"
"github.com/fatih/color"
@ -35,16 +34,16 @@ const (
// TextResource 存储多语言文本 / TextResource stores multilingual text
type TextResource struct {
SuccessMessage string
RestartMessage string
ReadingConfig string
GeneratingIds string
PressEnterToExit string
ErrorPrefix string
PrivilegeError string
RunAsAdmin string
RunWithSudo string
SudoExample string
SuccessMessage string
RestartMessage string
ReadingConfig string
GeneratingIds string
PressEnterToExit string
ErrorPrefix string
PrivilegeError string
RunAsAdmin string
RunWithSudo string
SudoExample string
}
// StorageConfig 优化的存储配置结构 / StorageConfig optimized storage configuration struct
@ -76,28 +75,28 @@ var (
texts = map [ Language ] TextResource {
CN : {
SuccessMessage : "[√] 配置文件已成功更新!" ,
RestartMessage : "[!] 请手动重启 Cursor 以使更新生效" ,
ReadingConfig : "正在读取配置文件..." ,
GeneratingIds : "正在生成新的标识符..." ,
PressEnterToExit : "按回车键退出程序..." ,
ErrorPrefix : "程序发生严重错误: %v" ,
PrivilegeError : "\n[!] 错误:需要管理员权限" ,
RunAsAdmin : "请右键点击程序,选择「以管理员身份运行」" ,
RunWithSudo : "请使用 sudo 命令运行此程序" ,
SudoExample : "示例: sudo %s" ,
SuccessMessage : "[√] 配置文件已成功更新!" ,
RestartMessage : "[!] 请手动重启 Cursor 以使更新生效" ,
ReadingConfig : "正在读取配置文件..." ,
GeneratingIds : "正在生成新的标识符..." ,
PressEnterToExit : "按回车键退出程序..." ,
ErrorPrefix : "程序发生严重错误: %v" ,
PrivilegeError : "\n[!] 错误:需要管理员权限" ,
RunAsAdmin : "请右键点击程序,选择「以管理员身份运行」" ,
RunWithSudo : "请使用 sudo 命令运行此程序" ,
SudoExample : "示例: sudo %s" ,
} ,
EN : {
SuccessMessage : "[√] Configuration file updated successfully!" ,
RestartMessage : "[!] Please restart Cursor manually for changes to take effect" ,
ReadingConfig : "Reading configuration file..." ,
GeneratingIds : "Generating new identifiers..." ,
PressEnterToExit : "Press Enter to exit..." ,
ErrorPrefix : "Program encountered a serious error: %v" ,
PrivilegeError : "\n[!] Error: Administrator privileges required" ,
RunAsAdmin : "Please right-click and select 'Run as Administrator'" ,
RunWithSudo : "Please run this program with sudo" ,
SudoExample : "Example: sudo %s" ,
SuccessMessage : "[√] Configuration file updated successfully!" ,
RestartMessage : "[!] Please restart Cursor manually for changes to take effect" ,
ReadingConfig : "Reading configuration file..." ,
GeneratingIds : "Generating new identifiers..." ,
PressEnterToExit : "Press Enter to exit..." ,
ErrorPrefix : "Program encountered a serious error: %v" ,
PrivilegeError : "\n[!] Error: Administrator privileges required" ,
RunAsAdmin : "Please right-click and select 'Run as Administrator'" ,
RunWithSudo : "Please run this program with sudo" ,
SudoExample : "Example: sudo %s" ,
} ,
}
)
@ -437,11 +436,11 @@ func selfElevate() error {
if err != nil {
return err
}
verbPtr , _ := syscall . UTF16PtrFromString ( verb )
exePtr , _ := syscall . UTF16PtrFromString ( exe )
cwdPtr , _ := syscall . UTF16PtrFromString ( cwd )
argPtr , _ := syscall . UTF16PtrFromString ( "" )
// 将字符串转换为UTF-16指针
verbPtr , _ := windows . UTF16PtrFromString ( verb )
exePtr , _ := windows . UTF16PtrFromString ( exe )
cwdPtr , _ := windows . UTF16PtrFromString ( cwd )
argPtr , _ := windows . UTF16PtrFromString ( "" )
var showCmd int32 = 1 //SW_NORMAL