Skip to content

Commit cecc088

Browse files
committed
⬆️ 升级指令提示
1 parent 6981bdc commit cecc088

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

tui/i18n.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,8 @@ var translations = map[string]map[Lang]string{
291291

292292
// === 版本升级提醒 ===
293293
"upgrade.available": {
294-
LangZH: "🎉 **新版本可用**: `v%s` → `v%s`\n升级: %s",
295-
LangEN: "🎉 **New version available**: `v%s` → `v%s`\nUpgrade: %s",
294+
LangZH: "🎉 **新版本可用**: `v%s` → `v%s`\n一键升级(重跑安装脚本覆盖更新):\n```\n%s\n```",
295+
LangEN: "🎉 **New version available**: `v%s` → `v%s`\nUpgrade (re-run the installer to update in place):\n```\n%s\n```",
296296
},
297297

298298
// === 复制提示 ===

tui/model.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
992992
if cur == "" {
993993
cur = "dev"
994994
}
995-
m.appendChat("System", fmt.Sprintf(T("upgrade.available"), cur, msg.LatestVersion, msg.URL))
995+
m.appendChat("System", fmt.Sprintf(T("upgrade.available"), cur, msg.LatestVersion, upgradeCommand()))
996996
}
997997
}
998998
return m, nil

tui/version.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"io"
77
"net/http"
8+
"runtime"
89
"strconv"
910
"strings"
1011
"time"
@@ -84,6 +85,17 @@ func fetchLatestRelease() (string, string, error) {
8485
return strings.TrimPrefix(rel.TagName, "v"), rel.HTMLURL, nil
8586
}
8687

88+
// upgradeCommand 返回当前平台的一键升级指令。升级方式就是重跑安装脚本 —— 它从 GitHub
89+
// Releases 拉最新预编译二进制覆盖安装。URL 由 repo 常量拼出,fork 改 githubRepoOwner /
90+
// githubRepoName 即可同步。Windows 走 PowerShell(install.ps1),其余(macOS/Linux)走 bash。
91+
func upgradeCommand() string {
92+
base := fmt.Sprintf("https://raw.githubusercontent.com/%s/%s/main/scripts", githubRepoOwner, githubRepoName)
93+
if runtime.GOOS == "windows" {
94+
return fmt.Sprintf("irm %s/install.ps1 | iex", base)
95+
}
96+
return fmt.Sprintf("curl -fsSL %s/install.sh | bash", base)
97+
}
98+
8799
// versionNewer 比较两个语义化版本字符串(已去 v 前缀,允许后缀 -rc1 / -beta 等)。
88100
// latest > current 返回 true。pre-release 后缀走字符串比较,够用即可,不严格遵循 semver。
89101
func versionNewer(latest, current string) bool {

0 commit comments

Comments
 (0)