mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-07-24 15:20:03 +08:00
✨ feat(updater): 优化关于页更新信息展示
- 关于页直接进入 GoNavi 内容详情,减少二次点击 - 将更新通道改为分段选择器并优化描述布局 - 保留后端发布发布时间元数据并在版本信息中展示
This commit is contained in:
@@ -51,18 +51,19 @@ type updateState struct {
|
||||
}
|
||||
|
||||
type UpdateInfo struct {
|
||||
HasUpdate bool `json:"hasUpdate"`
|
||||
Channel string `json:"channel"`
|
||||
CurrentVersion string `json:"currentVersion"`
|
||||
LatestVersion string `json:"latestVersion"`
|
||||
ReleaseName string `json:"releaseName"`
|
||||
ReleaseNotesURL string `json:"releaseNotesUrl"`
|
||||
AssetName string `json:"assetName"`
|
||||
AssetURL string `json:"assetUrl"`
|
||||
AssetSize int64 `json:"assetSize"`
|
||||
SHA256 string `json:"sha256"`
|
||||
Downloaded bool `json:"downloaded"`
|
||||
DownloadPath string `json:"downloadPath,omitempty"`
|
||||
HasUpdate bool `json:"hasUpdate"`
|
||||
Channel string `json:"channel"`
|
||||
CurrentVersion string `json:"currentVersion"`
|
||||
LatestVersion string `json:"latestVersion"`
|
||||
ReleaseName string `json:"releaseName"`
|
||||
ReleasePublishedAt string `json:"releasePublishedAt,omitempty"`
|
||||
ReleaseNotesURL string `json:"releaseNotesUrl"`
|
||||
AssetName string `json:"assetName"`
|
||||
AssetURL string `json:"assetUrl"`
|
||||
AssetSize int64 `json:"assetSize"`
|
||||
SHA256 string `json:"sha256"`
|
||||
Downloaded bool `json:"downloaded"`
|
||||
DownloadPath string `json:"downloadPath,omitempty"`
|
||||
}
|
||||
|
||||
type AppInfo struct {
|
||||
@@ -108,11 +109,12 @@ type updatePathCandidate struct {
|
||||
}
|
||||
|
||||
type githubRelease struct {
|
||||
TagName string `json:"tag_name"`
|
||||
Name string `json:"name"`
|
||||
HTMLURL string `json:"html_url"`
|
||||
Prerelease bool `json:"prerelease"`
|
||||
Assets []githubAsset `json:"assets"`
|
||||
TagName string `json:"tag_name"`
|
||||
Name string `json:"name"`
|
||||
HTMLURL string `json:"html_url"`
|
||||
PublishedAt string `json:"published_at"`
|
||||
Prerelease bool `json:"prerelease"`
|
||||
Assets []githubAsset `json:"assets"`
|
||||
}
|
||||
|
||||
type githubAsset struct {
|
||||
@@ -458,12 +460,13 @@ func fetchLatestUpdateInfo(channel updateChannel) (UpdateInfo, error) {
|
||||
}
|
||||
if !hasUpdate {
|
||||
return UpdateInfo{
|
||||
HasUpdate: false,
|
||||
Channel: string(channel),
|
||||
CurrentVersion: currentVersion,
|
||||
LatestVersion: latestVersion,
|
||||
ReleaseName: release.Name,
|
||||
ReleaseNotesURL: release.HTMLURL,
|
||||
HasUpdate: false,
|
||||
Channel: string(channel),
|
||||
CurrentVersion: currentVersion,
|
||||
LatestVersion: latestVersion,
|
||||
ReleaseName: release.Name,
|
||||
ReleasePublishedAt: strings.TrimSpace(release.PublishedAt),
|
||||
ReleaseNotesURL: release.HTMLURL,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -492,16 +495,17 @@ func fetchLatestUpdateInfo(channel updateChannel) (UpdateInfo, error) {
|
||||
return UpdateInfo{}, localizedUpdateError{key: "app.update.backend.error.sha256_missing_current_package"}
|
||||
}
|
||||
return UpdateInfo{
|
||||
HasUpdate: hasUpdate,
|
||||
Channel: string(channel),
|
||||
CurrentVersion: currentVersion,
|
||||
LatestVersion: latestVersion,
|
||||
ReleaseName: release.Name,
|
||||
ReleaseNotesURL: release.HTMLURL,
|
||||
AssetName: asset.Name,
|
||||
AssetURL: asset.BrowserDownloadURL,
|
||||
AssetSize: asset.Size,
|
||||
SHA256: sha256Value,
|
||||
HasUpdate: hasUpdate,
|
||||
Channel: string(channel),
|
||||
CurrentVersion: currentVersion,
|
||||
LatestVersion: latestVersion,
|
||||
ReleaseName: release.Name,
|
||||
ReleasePublishedAt: strings.TrimSpace(release.PublishedAt),
|
||||
ReleaseNotesURL: release.HTMLURL,
|
||||
AssetName: asset.Name,
|
||||
AssetURL: asset.BrowserDownloadURL,
|
||||
AssetSize: asset.Size,
|
||||
SHA256: sha256Value,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -30,9 +30,10 @@ func TestFetchLatestUpdateInfoSkipsChecksumWhenCurrentVersionIsAlreadyLatest(t *
|
||||
restoreRelease := swapUpdateFetchLatestRelease(func() (*githubRelease, error) {
|
||||
releaseCalled = true
|
||||
return &githubRelease{
|
||||
TagName: "v0.6.5",
|
||||
Name: "v0.6.5",
|
||||
HTMLURL: "https://github.com/Syngnat/GoNavi/releases/tag/v0.6.5",
|
||||
TagName: "v0.6.5",
|
||||
Name: "v0.6.5",
|
||||
HTMLURL: "https://github.com/Syngnat/GoNavi/releases/tag/v0.6.5",
|
||||
PublishedAt: "2026-07-08T11:15:00Z",
|
||||
Assets: []githubAsset{
|
||||
{
|
||||
Name: assetName,
|
||||
@@ -84,9 +85,10 @@ func TestFetchLatestUpdateInfoUsesAssetDigestWhenUpdateIsAvailable(t *testing.T)
|
||||
|
||||
restoreRelease := swapUpdateFetchLatestRelease(func() (*githubRelease, error) {
|
||||
return &githubRelease{
|
||||
TagName: "v0.6.5",
|
||||
Name: "v0.6.5",
|
||||
HTMLURL: "https://github.com/Syngnat/GoNavi/releases/tag/v0.6.5",
|
||||
TagName: "v0.6.5",
|
||||
Name: "v0.6.5",
|
||||
HTMLURL: "https://github.com/Syngnat/GoNavi/releases/tag/v0.6.5",
|
||||
PublishedAt: "2026-07-08T11:15:00Z",
|
||||
Assets: []githubAsset{
|
||||
{
|
||||
Name: assetName,
|
||||
@@ -119,6 +121,9 @@ func TestFetchLatestUpdateInfoUsesAssetDigestWhenUpdateIsAvailable(t *testing.T)
|
||||
if info.SHA256 != strings.ToLower(digest) || info.AssetName != assetName {
|
||||
t.Fatalf("unexpected update info: %#v", info)
|
||||
}
|
||||
if info.ReleasePublishedAt != "2026-07-08T11:15:00Z" {
|
||||
t.Fatalf("expected release published time to be preserved, got %#v", info)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFetchLatestUpdateInfoFallsBackToChecksumFileWhenAssetDigestMissing(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user