diff --git a/moltbot/installer/installer.exe b/moltbot/installer/installer.exe index e5706d0..4ee9408 100644 Binary files a/moltbot/installer/installer.exe and b/moltbot/installer/installer.exe differ diff --git a/moltbot/installer/internal/sys/sys.go b/moltbot/installer/internal/sys/sys.go index 8612811..c0ee928 100644 --- a/moltbot/installer/internal/sys/sys.go +++ b/moltbot/installer/internal/sys/sys.go @@ -36,6 +36,20 @@ const ( downloadConcurrentParts = 4 ) +const gitProxyEnv = "GIT_PROXY" +const gitProxyDefault = "https://g.blfrp.cn/" + +func gitProxy() string { + proxy := strings.TrimSpace(os.Getenv(gitProxyEnv)) + if proxy == "" { + proxy = gitProxyDefault + } + if !strings.HasSuffix(proxy, "/") { + proxy += "/" + } + return proxy +} + // SHA256 来源 https://nodejs.org/dist/v24.13.0/SHASUMS256.txt.asc const nodeMsiSHA256 = "1a5f0cd914386f3be2fbaf03ad9fff808a588ce50d2e155f338fad5530575f18" @@ -365,6 +379,20 @@ func ConfigureNpmMirror() error { return nil } +func ConfigureGitProxy() error { + gitPath, err := GetGitPath() + if err != nil { + return err + } + proxy := gitProxy() + key := fmt.Sprintf("url.%shttps://github.com/.insteadOf", proxy) + cmd := exec.Command(gitPath, "config", "--global", key, "https://github.com/") + if err := cmd.Run(); err != nil { + return fmt.Errorf("设置 git 代理失败: %v", err) + } + return nil +} + // downloadFile 下载文件 func downloadFile(url, dest, expectedSHA256 string) error { if ok, err := verifyFileSHA256(dest, expectedSHA256); err == nil && ok { @@ -747,7 +775,7 @@ func InstallGit() error { return nil } - gitUrl := "https://gh.kejilion.pro/github.com/git-for-windows/git/releases/download/v2.52.0.windows.1/Git-2.52.0-64-bit.exe" + gitUrl := fmt.Sprintf("%sgithub.com/git-for-windows/git/releases/download/v2.52.0.windows.1/Git-2.52.0-64-bit.exe", gitProxy()) tempDir := os.TempDir() exePath := filepath.Join(tempDir, "Git-2.52.0-64-bit.exe") diff --git a/moltbot/installer/internal/ui/model.go b/moltbot/installer/internal/ui/model.go index e7d139d..0b7018a 100644 --- a/moltbot/installer/internal/ui/model.go +++ b/moltbot/installer/internal/ui/model.go @@ -709,6 +709,11 @@ func runInstallFlowCmd() tea.Msg { return actionResultMsg{err: fmt.Errorf("git 安装失败: %v", err)} } + err = sys.ConfigureGitProxy() + if err != nil { + return actionResultMsg{err: fmt.Errorf("git 代理配置失败: %v", err)} + } + err = sys.ConfigureNpmMirror() if err != nil { return actionResultMsg{err: fmt.Errorf("npm 配置失败: %v", err)}