-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add application update management
- Loading branch information
1 parent
ad35e13
commit 3afbbfc
Showing
10 changed files
with
208 additions
and
15 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<template> | ||
<q-dialog persistent ref="dialog" @hide="hideDialog"> | ||
<q-card class="q-dialog-plugin"> | ||
<q-card-section> | ||
<div>{{ $t('welcome') }}</div> | ||
<div class="text-half">{{ $t('welcome_message') }}</div> | ||
</q-card-section> | ||
<q-card-section v-if="haveVersion"> | ||
<q-scroll-area style="height: 22vh" visible> | ||
<div v-for="(releaseNote, index) in releaseNotes" :key="index"> | ||
<div class="text-half text-underline">{{ releaseNote.version }}</div> | ||
<ul> | ||
<li v-for="(message, index) in releaseNote.messages" :key="index" class="text-half">{{ message }}</li> | ||
</ul> | ||
</div> | ||
</q-scroll-area> | ||
</q-card-section> | ||
<q-card-actions align="right"> | ||
<q-btn color="primary" data-autofocus="true" flat :label="$t('ok')" :ripple="false" rounded @click="submitDialog" /> | ||
</q-card-actions> | ||
</q-card> | ||
</q-dialog> | ||
</template> | ||
|
||
<script> | ||
import semver from 'semver' | ||
export default { | ||
name: 'DialogWelcome', | ||
computed: { | ||
haveVersion: function () { | ||
return this.$store.state.application.version !== null | ||
}, | ||
releaseNotes: function () { | ||
let versions = semver.rsort(this.versions) | ||
if (this.$store.state.application.version !== null) { | ||
versions = versions.filter(version => semver.gt(version, this.$store.state.application.version)) | ||
} | ||
const releaseNotes = versions.reduce((accumulator, version) => { | ||
const key = `release_notes.${version.replaceAll('.', '_')}` | ||
if (this.$te(key)) { | ||
accumulator.push({ version, messages: this.$t(key) }) | ||
} | ||
return accumulator | ||
}, []) | ||
return releaseNotes | ||
}, | ||
versions: function () { | ||
return [ | ||
'1.0.0', | ||
'1.0.1', | ||
'1.0.2', | ||
'1.1.0', | ||
'1.2.0' | ||
] | ||
} | ||
}, | ||
methods: { | ||
cancelDialog: function () { | ||
this.hide() | ||
}, | ||
hide: function () { | ||
this.$refs.dialog.hide() | ||
}, | ||
hideDialog: function () { | ||
this.$emit('hide') | ||
}, | ||
show: function () { | ||
this.$refs.dialog.show() | ||
}, | ||
submitDialog: function () { | ||
this.$emit('ok') | ||
this.hide() | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
export default { | ||
namespaced: true, | ||
state () { | ||
return { | ||
schema: '1.0.0', | ||
version: null | ||
} | ||
}, | ||
mutations: { | ||
setSchema: function (state, payload) { | ||
state.schema = payload.schema | ||
}, | ||
setVersion: function (state, payload) { | ||
state.version = payload.version | ||
} | ||
}, | ||
actions: { | ||
setSchema: function (context, payload) { | ||
context.commit('setSchema', payload) | ||
}, | ||
setVersion: function (context, payload) { | ||
context.commit('setVersion', payload) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
export default function (storage) { | ||
storage.setItem('@@', 1) | ||
storage.removeItem('@@') | ||
|
||
const item = storage.getItem('vuex') | ||
|
||
if (item !== null) { | ||
let state = JSON.parse(item) | ||
|
||
if (state.application === undefined) { | ||
const newState = {} | ||
|
||
newState.application = { | ||
schema: '1.0.0', | ||
version: '1.0.0' | ||
} | ||
|
||
newState.configuration = state.configuration | ||
|
||
state = newState | ||
} | ||
|
||
storage.setItem('vuex', JSON.stringify(state)) | ||
} | ||
} |