Skip to content

Commit e397e2c

Browse files
committed
fix: corrected update-checking logic
1 parent 53a198b commit e397e2c

File tree

8 files changed

+21
-15
lines changed

8 files changed

+21
-15
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ build/bin
22
node_modules
33
frontend/dist
44
frontend/wailsjs
5+
design/
56
.vscode
67
.idea

backend/services/preferences_service.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package services
33
import (
44
"encoding/json"
55
"github.com/adrg/sysfont"
6-
"io"
76
"net/http"
87
"sort"
98
"strings"
@@ -87,7 +86,11 @@ func (p *preferencesService) GetFontList() (resp types.JSResp) {
8786
}
8887

8988
func (p *preferencesService) SetClientVersion(ver string) {
90-
p.clientVersion = ver
89+
if !strings.HasPrefix(ver, "v") {
90+
p.clientVersion = "v" + ver
91+
} else {
92+
p.clientVersion = ver
93+
}
9194
}
9295

9396
type latestRelease struct {
@@ -105,13 +108,8 @@ func (p *preferencesService) CheckForUpdate() (resp types.JSResp) {
105108
return
106109
}
107110

108-
body, err := io.ReadAll(res.Body)
109-
if err != nil {
110-
resp.Msg = "invalid content"
111-
return
112-
}
113111
var respObj latestRelease
114-
err = json.Unmarshal(body, &respObj)
112+
err = json.NewDecoder(res.Body).Decode(&respObj)
115113
if err != nil {
116114
resp.Msg = "invalid content"
117115
return

frontend/src/AppContent.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ watch(
8181
<n-spin
8282
:show="props.loading"
8383
:theme-overrides="{ opacitySpinning: 0 }"
84-
style="--wails-draggable: drag; border-radius: 10px"
84+
style="border-radius: 10px"
8585
:style="{ backgroundColor: themeVars.bodyColor }">
8686
<div
8787
id="app-content-wrapper"

frontend/src/langs/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@
175175
"title": "Set Key TTL"
176176
},
177177
"upgrade": {
178-
"new_version_tip": "A new version is available. Download now?",
178+
"new_version_tip": "A new version({ver}) is available. Download now?",
179179
"no_update": "You're update to date"
180180
}
181181
},

frontend/src/langs/zh-cn.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176
"title": "设置键存活时间"
177177
},
178178
"upgrade":{
179-
"new_version_tip": "有可用的新版本,是否立即下载",
179+
"new_version_tip": "有可用的新版本({ver}),是否立即下载",
180180
"no_update": "当前已是最新版"
181181
}
182182
},

frontend/src/stores/preferences.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,10 @@ const usePreferencesStore = defineStore('preferences', {
250250
try {
251251
const { success, data = {} } = await CheckForUpdate()
252252
if (success) {
253-
const { version, latest, pageUrl } = data
254-
if (latest > version) {
255-
$dialog.warning(i18nGlobal.t('dialogue.upgrade.new_version_tip'), () => {
253+
const { version = 'v1.0.0', latest, page_url: pageUrl } = data
254+
if (latest > version && !isEmpty(pageUrl)) {
255+
const tip = i18nGlobal.t('dialogue.upgrade.new_version_tip', { ver: version })
256+
$dialog.warning(tip, () => {
256257
BrowserOpenURL(pageUrl)
257258
})
258259
return

frontend/src/styles/style.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ body {
2121
padding: 0;
2222
background-color: #0000;
2323
line-height: 1.5;
24-
font-family: v-sans, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"
24+
font-family: v-sans, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
25+
--wails-draggable: drag;
2526
}
2627

2728
#app {
@@ -118,3 +119,7 @@ body {
118119
//border-top: v-bind('themeVars.borderColor') 1px solid;
119120
}
120121
}
122+
123+
.n-dialog {
124+
--wails-draggable: drag;
125+
}

main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func main() {
2727
app := NewApp()
2828
connSvc := services.Connection()
2929
prefSvc := services.Preferences()
30+
prefSvc.SetClientVersion(version)
3031

3132
// menu
3233
appMenu := menu.NewMenu()

0 commit comments

Comments
 (0)