fix: corrected update-checking logic
This commit is contained in:
parent
53a198bdc5
commit
e397e2c4c4
|
@ -2,5 +2,6 @@ build/bin
|
|||
node_modules
|
||||
frontend/dist
|
||||
frontend/wailsjs
|
||||
design/
|
||||
.vscode
|
||||
.idea
|
||||
|
|
|
@ -3,7 +3,6 @@ package services
|
|||
import (
|
||||
"encoding/json"
|
||||
"github.com/adrg/sysfont"
|
||||
"io"
|
||||
"net/http"
|
||||
"sort"
|
||||
"strings"
|
||||
|
@ -87,7 +86,11 @@ func (p *preferencesService) GetFontList() (resp types.JSResp) {
|
|||
}
|
||||
|
||||
func (p *preferencesService) SetClientVersion(ver string) {
|
||||
if !strings.HasPrefix(ver, "v") {
|
||||
p.clientVersion = "v" + ver
|
||||
} else {
|
||||
p.clientVersion = ver
|
||||
}
|
||||
}
|
||||
|
||||
type latestRelease struct {
|
||||
|
@ -105,13 +108,8 @@ func (p *preferencesService) CheckForUpdate() (resp types.JSResp) {
|
|||
return
|
||||
}
|
||||
|
||||
body, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
resp.Msg = "invalid content"
|
||||
return
|
||||
}
|
||||
var respObj latestRelease
|
||||
err = json.Unmarshal(body, &respObj)
|
||||
err = json.NewDecoder(res.Body).Decode(&respObj)
|
||||
if err != nil {
|
||||
resp.Msg = "invalid content"
|
||||
return
|
||||
|
|
|
@ -81,7 +81,7 @@ watch(
|
|||
<n-spin
|
||||
:show="props.loading"
|
||||
:theme-overrides="{ opacitySpinning: 0 }"
|
||||
style="--wails-draggable: drag; border-radius: 10px"
|
||||
style="border-radius: 10px"
|
||||
:style="{ backgroundColor: themeVars.bodyColor }">
|
||||
<div
|
||||
id="app-content-wrapper"
|
||||
|
|
|
@ -175,7 +175,7 @@
|
|||
"title": "Set Key TTL"
|
||||
},
|
||||
"upgrade": {
|
||||
"new_version_tip": "A new version is available. Download now?",
|
||||
"new_version_tip": "A new version({ver}) is available. Download now?",
|
||||
"no_update": "You're update to date"
|
||||
}
|
||||
},
|
||||
|
|
|
@ -176,7 +176,7 @@
|
|||
"title": "设置键存活时间"
|
||||
},
|
||||
"upgrade":{
|
||||
"new_version_tip": "有可用的新版本,是否立即下载",
|
||||
"new_version_tip": "有可用的新版本({ver}),是否立即下载",
|
||||
"no_update": "当前已是最新版"
|
||||
}
|
||||
},
|
||||
|
|
|
@ -250,9 +250,10 @@ const usePreferencesStore = defineStore('preferences', {
|
|||
try {
|
||||
const { success, data = {} } = await CheckForUpdate()
|
||||
if (success) {
|
||||
const { version, latest, pageUrl } = data
|
||||
if (latest > version) {
|
||||
$dialog.warning(i18nGlobal.t('dialogue.upgrade.new_version_tip'), () => {
|
||||
const { version = 'v1.0.0', latest, page_url: pageUrl } = data
|
||||
if (latest > version && !isEmpty(pageUrl)) {
|
||||
const tip = i18nGlobal.t('dialogue.upgrade.new_version_tip', { ver: version })
|
||||
$dialog.warning(tip, () => {
|
||||
BrowserOpenURL(pageUrl)
|
||||
})
|
||||
return
|
||||
|
|
|
@ -21,7 +21,8 @@ body {
|
|||
padding: 0;
|
||||
background-color: #0000;
|
||||
line-height: 1.5;
|
||||
font-family: v-sans, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"
|
||||
font-family: v-sans, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
|
||||
--wails-draggable: drag;
|
||||
}
|
||||
|
||||
#app {
|
||||
|
@ -118,3 +119,7 @@ body {
|
|||
//border-top: v-bind('themeVars.borderColor') 1px solid;
|
||||
}
|
||||
}
|
||||
|
||||
.n-dialog {
|
||||
--wails-draggable: drag;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue