Skip to content

Commit

Permalink
feat: display a badge for new version
Browse files Browse the repository at this point in the history
  • Loading branch information
KillingJacky committed Mar 12, 2020
1 parent e9b68af commit 9a723e5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ if (process.platform === 'darwin') {
// AutoUpdater
autoUpdater.on('update-available', (info) => {
logger.info('update-available', JSON.stringify(info))
let {version} = info
if (win && version) win.webContents.send('update-available', version)
})

autoUpdater.on('update-not-available', (info) => {
Expand Down Expand Up @@ -430,3 +432,7 @@ ipcMain.on('locale-change', (event, arg) => {
translateMenu()
})

ipcMain.on('goto-new-version', (event) => {
shell.openExternal('https://github.com/Seeed-Solution/SenseCAP-Node-Configuration-Tool/releases/latest')
})

20 changes: 19 additions & 1 deletion src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,16 @@
</div>
</v-col>
<v-col cols="auto" class="d-flex flex-column align-center justify-center caption grey--text">
<div>v{{currentVersion}}</div>
<div>
<v-tooltip top open-delay="1000" :disabled="!newVersion">
<template v-slot:activator="{ on }">
<v-badge color="pink" dot top :value="newVersion">
<span v-on="on" @click="versionClicked()" id="versionText">v{{currentVersion}}</span>
</v-badge>
</template>
<span>v{{newVersion}} available</span>
</v-tooltip>
</div>
</v-col>
</v-row>
</v-container>
Expand Down Expand Up @@ -203,6 +212,7 @@ export default {
pauseParseLine: false,
//ota
currentVersion: '',
newVersion: '',
//i18n
selectedLocaleIso: 'us',
locale: 'en',
Expand Down Expand Up @@ -435,6 +445,9 @@ export default {
else if (locale.includes('zh')) return 'zh'
else if (locale.includes('cn')) return 'zh'
return 'en'
},
versionClicked() {
ipcRenderer.send('goto-new-version')
}
},
created() {
Expand Down Expand Up @@ -545,6 +558,11 @@ export default {
this.updateFwLoading = false
this.pauseParseLine = false
})
ipcRenderer.on('update-available', (event, arg) => {
console.log('update-available:', arg)
this.newVersion = arg
document.getElementById('versionText').style.cursor = 'pointer'
})
},
beforeDestroy() {
ipcRenderer.removeAllListeners()
Expand Down

0 comments on commit 9a723e5

Please sign in to comment.