mirror of
https://github.com/yuaotian/go-cursor-help.git
synced 2025-06-08 12:32:06 +08:00
refactor: Remove obsolete analysis file and improve Windows admin privilege check in main.go
- Deleted the outdated analysis file that contained error diagnostics and solutions. - Updated the checkAdminPrivileges function in main.go to use a more reliable method for checking Windows administrator privileges, enhancing security and accuracy. - Fixed a minor display issue in the success message output. - Added "apprun" to the cSpell dictionary in .vscode/settings.json for improved spell checking. These changes streamline the codebase and enhance the functionality of the application.
This commit is contained in:
parent
1b6933267d
commit
24287ac575
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@ -1,5 +1,6 @@
|
||||
{
|
||||
"cSpell.words": [
|
||||
"apprun",
|
||||
"buildmode",
|
||||
"dylib",
|
||||
"endlocal",
|
||||
|
8
analysis
8
analysis
@ -1,8 +0,0 @@
|
||||
1. 问题定位
|
||||
- 错误发生在第68行附近的 `}` 处
|
||||
- 这是一个 shell 脚本语法错误
|
||||
- 检查发现是 check_requirements 函数中的花括号闭合问题
|
||||
|
||||
2. 解决方案
|
||||
- 移除多余的花括号
|
||||
- 确保函数语法正确
|
17
main.go
17
main.go
@ -482,7 +482,7 @@ func showSuccess() {
|
||||
successColor.Printf("%s\n", text.SuccessMessage)
|
||||
fmt.Println()
|
||||
warningColor.Printf("%s\n", text.RestartMessage)
|
||||
successColor.Println("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━<EFBFBD><EFBFBD><EFBFBD>━━━")
|
||||
successColor.Println("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
|
||||
}
|
||||
|
||||
// Add spacing before config location
|
||||
@ -527,13 +527,14 @@ func showPrivilegeError() {
|
||||
func checkAdminPrivileges() (bool, error) {
|
||||
switch runtime.GOOS {
|
||||
case "windows":
|
||||
cmd := exec.Command("whoami", "/groups")
|
||||
output, err := cmd.Output()
|
||||
if err != nil {
|
||||
return false, err
|
||||
// 使用更可靠的方法检查Windows管理员权限
|
||||
cmd := exec.Command("net", "session")
|
||||
err := cmd.Run()
|
||||
if err == nil {
|
||||
return true, nil
|
||||
}
|
||||
return strings.Contains(string(output), "S-1-16-12288") ||
|
||||
strings.Contains(string(output), "S-1-5-32-544"), nil
|
||||
// 如果命令执行失败,说明没有管理员权限
|
||||
return false, nil
|
||||
|
||||
case "darwin", "linux":
|
||||
currentUser, err := user.Current()
|
||||
@ -841,7 +842,7 @@ func main() {
|
||||
// Progress spinner functions / 进度条函数
|
||||
func NewProgressSpinner(message string) *ProgressSpinner {
|
||||
return &ProgressSpinner{
|
||||
frames: []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"},
|
||||
frames: []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "<EFBFBD><EFBFBD>", "⠏"},
|
||||
message: message,
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user