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:
Xx 2024-12-13 15:49:05 +08:00
parent 1b6933267d
commit 24287ac575
3 changed files with 10 additions and 16 deletions

View File

@ -1,5 +1,6 @@
{ {
"cSpell.words": [ "cSpell.words": [
"apprun",
"buildmode", "buildmode",
"dylib", "dylib",
"endlocal", "endlocal",

View File

@ -1,8 +0,0 @@
1. 问题定位
- 错误发生在第68行附近的 `}` 处
- 这是一个 shell 脚本语法错误
- 检查发现是 check_requirements 函数中的花括号闭合问题
2. 解决方案
- 移除多余的花括号
- 确保函数语法正确

17
main.go
View File

@ -482,7 +482,7 @@ func showSuccess() {
successColor.Printf("%s\n", text.SuccessMessage) successColor.Printf("%s\n", text.SuccessMessage)
fmt.Println() fmt.Println()
warningColor.Printf("%s\n", text.RestartMessage) warningColor.Printf("%s\n", text.RestartMessage)
successColor.Println("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━<EFBFBD><EFBFBD><EFBFBD>━━━") successColor.Println("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
} }
// Add spacing before config location // Add spacing before config location
@ -527,13 +527,14 @@ func showPrivilegeError() {
func checkAdminPrivileges() (bool, error) { func checkAdminPrivileges() (bool, error) {
switch runtime.GOOS { switch runtime.GOOS {
case "windows": case "windows":
cmd := exec.Command("whoami", "/groups") // 使用更可靠的方法检查Windows管理员权限
output, err := cmd.Output() cmd := exec.Command("net", "session")
if err != nil { err := cmd.Run()
return false, err 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": case "darwin", "linux":
currentUser, err := user.Current() currentUser, err := user.Current()
@ -841,7 +842,7 @@ func main() {
// Progress spinner functions / 进度条函数 // Progress spinner functions / 进度条函数
func NewProgressSpinner(message string) *ProgressSpinner { func NewProgressSpinner(message string) *ProgressSpinner {
return &ProgressSpinner{ return &ProgressSpinner{
frames: []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "", "⠏"}, frames: []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "<EFBFBD><EFBFBD>", "⠏"},
message: message, message: message,
} }
} }