getVersionInfo 获取版本信息字符串
()
| 97 | |
| 98 | // getVersionInfo 获取版本信息字符串 |
| 99 | func getVersionInfo() string { |
| 100 | currentVersion := version.GetVersion() // 使用动态版本号 |
| 101 | |
| 102 | latestVersion := getLatestVersion() |
| 103 | |
| 104 | if latestVersion == "" { |
| 105 | // 无法获取最新版本,只显示当前版本 |
| 106 | return currentVersion |
| 107 | } |
| 108 | |
| 109 | if latestVersion == currentVersion { |
| 110 | // 版本相同,只显示当前版本 |
| 111 | return currentVersion |
| 112 | } |
| 113 | |
| 114 | // 版本不同,显示当前版本和最新版本 |
| 115 | return fmt.Sprintf("%s (最新: %s)", currentVersion, latestVersion) |
| 116 | } |
| 117 | |
| 118 | // getDisplayWidth 计算字符串的显示宽度(中文字符占2个位置) |
| 119 | func getDisplayWidth(s string) int { |
no test coverage detected