修改代码注释为中文
This commit is contained in:
@@ -18,7 +18,7 @@ func NewDarwinPlatform() *DarwinPlatform {
|
||||
}
|
||||
|
||||
func (p *DarwinPlatform) OS() string { return "darwin" }
|
||||
func (p *DarwinPlatform) Arch() string { return "amd64" } // TODO: detect properly
|
||||
func (p *DarwinPlatform) Arch() string { return "amd64" } // TODO: 正确检测架构
|
||||
func (p *DarwinPlatform) HomeDir() string { return p.homeDir }
|
||||
|
||||
func (p *DarwinPlatform) ConfigDir() string {
|
||||
@@ -34,13 +34,13 @@ func (p *DarwinPlatform) GetEnvVar(key string) string {
|
||||
}
|
||||
|
||||
func (p *DarwinPlatform) SetEnvVar(ctx context.Context, key, value string) error {
|
||||
// On macOS, set via launchctl and shell profile
|
||||
// 在 macOS 上通过 launchctl 和 Shell 配置文件设置
|
||||
cmd := exec.CommandContext(ctx, "launchctl", "setenv", key, value)
|
||||
return cmd.Run()
|
||||
}
|
||||
|
||||
func (p *DarwinPlatform) AddToPath(ctx context.Context, dir string) error {
|
||||
// TODO: Add to shell profile
|
||||
// TODO: 添加到 Shell 配置文件
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ func NewLinuxPlatform() *LinuxPlatform {
|
||||
}
|
||||
|
||||
func (p *LinuxPlatform) OS() string { return "linux" }
|
||||
func (p *LinuxPlatform) Arch() string { return "amd64" } // TODO: detect properly
|
||||
func (p *LinuxPlatform) Arch() string { return "amd64" } // TODO: 正确检测架构
|
||||
func (p *LinuxPlatform) HomeDir() string { return p.homeDir }
|
||||
|
||||
func (p *LinuxPlatform) ConfigDir() string {
|
||||
@@ -40,12 +40,12 @@ func (p *LinuxPlatform) GetEnvVar(key string) string {
|
||||
}
|
||||
|
||||
func (p *LinuxPlatform) SetEnvVar(ctx context.Context, key, value string) error {
|
||||
// TODO: Add to shell profile
|
||||
// TODO: 写入 Shell 配置文件以持久化
|
||||
return os.Setenv(key, value)
|
||||
}
|
||||
|
||||
func (p *LinuxPlatform) AddToPath(ctx context.Context, dir string) error {
|
||||
// TODO: Add to shell profile
|
||||
// TODO: 添加到 Shell 配置文件
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ func Detect() Platform {
|
||||
case "linux":
|
||||
return NewLinuxPlatform()
|
||||
default:
|
||||
// Fallback to Linux
|
||||
// 默认回退到 Linux 实现
|
||||
return NewLinuxPlatform()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ func (p *WindowsPlatform) AddToPath(ctx context.Context, dir string) error {
|
||||
}
|
||||
|
||||
func (p *WindowsPlatform) IsAdmin() bool {
|
||||
// Check if running as administrator on Windows
|
||||
// 检查 Windows 上是否以管理员身份运行
|
||||
cmd := exec.Command("net", "session")
|
||||
err := cmd.Run()
|
||||
return err == nil
|
||||
@@ -77,7 +77,7 @@ func (p *WindowsPlatform) PackageManagers() []string {
|
||||
|
||||
func (p *WindowsPlatform) DefaultShell() string {
|
||||
if _, err := exec.LookPath("pwsh"); err == nil {
|
||||
return "pwsh" // PowerShell 7+
|
||||
return "pwsh" // PowerShell 7+ 版本
|
||||
}
|
||||
return "powershell" // Windows PowerShell 5.1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user