1
1
mirror of https://github.com/Fabio286/antares.git synced 2025-06-05 21:59:22 +02:00

feat: in-app last release changelog

This commit is contained in:
2021-04-11 12:35:16 +02:00
parent 8735a0c5f9
commit 1e938adc5d
6 changed files with 155 additions and 40 deletions

View File

@ -74,6 +74,7 @@
"electron-updater": "^4.3.5", "electron-updater": "^4.3.5",
"faker": "^5.3.1", "faker": "^5.3.1",
"keytar": "^7.3.0", "keytar": "^7.3.0",
"marked": "^2.0.2",
"moment": "^2.29.1", "moment": "^2.29.1",
"mssql": "^6.2.3", "mssql": "^6.2.3",
"mysql2": "^2.2.5", "mysql2": "^2.2.5",

View File

@ -58,6 +58,7 @@ export default {
}, },
mounted () { mounted () {
ipcRenderer.send('check-for-updates'); ipcRenderer.send('check-for-updates');
this.checkVersionUpdate();
const Menu = remote.Menu; const Menu = remote.Menu;
@ -100,7 +101,8 @@ export default {
}, },
methods: { methods: {
...mapActions({ ...mapActions({
showNewConnModal: 'application/showNewConnModal' showNewConnModal: 'application/showNewConnModal',
checkVersionUpdate: 'application/checkVersionUpdate'
}) })
} }
}; };

View File

@ -37,6 +37,14 @@
> >
<a class="c-hand" :class="{'badge badge-update': hasUpdates}">{{ $t('word.update') }}</a> <a class="c-hand" :class="{'badge badge-update': hasUpdates}">{{ $t('word.update') }}</a>
</li> </li>
<li
v-if="updateStatus !== 'disabled'"
class="tab-item"
:class="{'active': selectedTab === 'changelog'}"
@click="selectTab('changelog')"
>
<a class="c-hand">{{ $t('word.changelog') }}</a>
</li>
<li <li
class="tab-item" class="tab-item"
:class="{'active': selectedTab === 'about'}" :class="{'active': selectedTab === 'about'}"
@ -210,6 +218,9 @@
<div v-if="selectedTab === 'update'" class="panel-body py-4"> <div v-if="selectedTab === 'update'" class="panel-body py-4">
<ModalSettingsUpdate /> <ModalSettingsUpdate />
</div> </div>
<div v-if="selectedTab === 'changelog'" class="panel-body py-4">
<ModalSettingsChangelog />
</div>
<div v-if="selectedTab === 'about'" class="panel-body py-4"> <div v-if="selectedTab === 'about'" class="panel-body py-4">
<div class="text-center"> <div class="text-center">
@ -233,6 +244,7 @@
import { mapActions, mapGetters } from 'vuex'; import { mapActions, mapGetters } from 'vuex';
import localesNames from '@/i18n/supported-locales'; import localesNames from '@/i18n/supported-locales';
import ModalSettingsUpdate from '@/components/ModalSettingsUpdate'; import ModalSettingsUpdate from '@/components/ModalSettingsUpdate';
import ModalSettingsChangelog from '@/components/ModalSettingsChangelog';
import BaseTextEditor from '@/components/BaseTextEditor'; import BaseTextEditor from '@/components/BaseTextEditor';
const { shell } = require('electron'); const { shell } = require('electron');
@ -240,6 +252,7 @@ export default {
name: 'ModalSettings', name: 'ModalSettings',
components: { components: {
ModalSettingsUpdate, ModalSettingsUpdate,
ModalSettingsChangelog,
BaseTextEditor BaseTextEditor
}, },
data () { data () {
@ -394,11 +407,15 @@ ORDER BY
<style lang="scss"> <style lang="scss">
#settings { #settings {
.modal-container {
position: absolute;
top: 17.5vh;
.modal-body { .modal-body {
overflow: hidden; overflow: hidden;
.panel-body { .panel-body {
height: calc(70vh - 70px); min-height: calc(25vh - 70px);
overflow: auto; overflow: auto;
.theme-block { .theme-block {
@ -444,4 +461,5 @@ ORDER BY
} }
} }
} }
}
</style> </style>

View File

@ -0,0 +1,78 @@
<template>
<div class="p-relative">
<BaseLoader v-if="isLoading" />
<div
id="changelog"
class="container"
v-html="changelog"
/>
<div v-if="isError" class="empty">
<div class="empty-icon">
<i class="mdi mdi-48px mdi-alert-outline" />
</div>
</div>
</div>
</template>
<script>
import marked from 'marked';
import BaseLoader from '@/components/BaseLoader';
export default {
name: 'ModalSettingsChangelog',
components: {
BaseLoader
},
data () {
return {
changelog: '',
isLoading: true,
error: '',
isError: false
};
},
created () {
this.getChangelog();
},
methods: {
async getChangelog () {
try {
const apiRes = await fetch('https://api.github.com/repos/Fabio286/antares/releases/latest', {
method: 'GET'
});
const { body } = await apiRes.json();
const markdown = body.substr(0, body.indexOf('### Download'));
const renderer = {
link (href, title, text) {
return text;
},
listitem (text) {
return `<li>${text.replace(/ *\([^)]*\) */g, '')}</li>`;
}
};
marked.use({ renderer });
this.changelog = marked(markdown);
}
catch (err) {
this.error = err.message;
this.isError = true;
}
this.isLoading = false;
}
}
};
</script>
<style lang="scss">
#changelog {
h3 {
font-size: 1rem;
}
li {
margin-top: 0;
}
}
</style>

View File

@ -103,7 +103,8 @@ module.exports = {
processes: 'Processes', processes: 'Processes',
database: 'Database', database: 'Database',
scratchpad: 'Scratchpad', scratchpad: 'Scratchpad',
array: 'Array' array: 'Array',
changelog: 'Changelog'
}, },
message: { message: {
appWelcome: 'Welcome to Antares SQL Client!', appWelcome: 'Welcome to Antares SQL Client!',

View File

@ -1,10 +1,14 @@
'use strict'; 'use strict';
import Store from 'electron-store';
const persistentStore = new Store({ name: 'settings' });
export default { export default {
namespaced: true, namespaced: true,
strict: true, strict: true,
state: { state: {
app_name: 'Antares - SQL Client', app_name: 'Antares - SQL Client',
app_version: process.env.PACKAGE_VERSION || 0, app_version: process.env.PACKAGE_VERSION || 0,
cached_version: persistentStore.get('cached_version', 0),
is_loading: false, is_loading: false,
is_new_modal: false, is_new_modal: false,
is_setting_modal: false, is_setting_modal: false,
@ -19,6 +23,7 @@ export default {
isLoading: state => state.is_loading, isLoading: state => state.is_loading,
appName: state => state.app_name, appName: state => state.app_name,
appVersion: state => state.app_version, appVersion: state => state.app_version,
cachedVersion: state => state.cached_version,
getBaseCompleter: state => state.base_completer, getBaseCompleter: state => state.base_completer,
getSelectedConnection: state => state.selected_conection, getSelectedConnection: state => state.selected_conection,
isNewModal: state => state.is_new_modal, isNewModal: state => state.is_new_modal,
@ -54,6 +59,10 @@ export default {
HIDE_SCRATCHPAD (state) { HIDE_SCRATCHPAD (state) {
state.is_scratchpad = false; state.is_scratchpad = false;
}, },
CHANGE_CACHED_VERSION (state) {
state.cached_version = state.app_version;
persistentStore.set('cached_version', state.cached_version);
},
CHANGE_UPDATE_STATUS (state, status) { CHANGE_UPDATE_STATUS (state, status) {
state.update_status = status; state.update_status = status;
}, },
@ -62,6 +71,12 @@ export default {
} }
}, },
actions: { actions: {
checkVersionUpdate ({ getters, commit, dispatch }) {
if (getters.appVersion !== getters.cachedVersion) {
dispatch('showSettingModal', 'changelog');
commit('CHANGE_CACHED_VERSION');
}
},
setLoadingStatus ({ commit }, payload) { setLoadingStatus ({ commit }, payload) {
commit('SET_LOADING_STATUS', payload); commit('SET_LOADING_STATUS', payload);
}, },