chore: added changelog for update modal

This commit is contained in:
2025-07-07 18:00:07 +02:00
parent 43b0dc9fa0
commit 5b9b86248f
8 changed files with 228 additions and 4 deletions
+37 -3
View File
@@ -1,17 +1,20 @@
<template>
<div id="app_wrapper">
<UpdateCard />
<router-view />
<transition name="slide-anim">
<div v-if="needRefresh" class="update-prompt" @click="updateServiceWorker(true)">
Nowa wersja GeneraTORa dostępna!
<u>Kliknij, aby odświeżyć aplikację!</u>
{{ $t('update.update-available-text') }}
<u>{{ $t('update.update-available-underline') }}</u>
</div>
</transition>
<footer>
&copy; <a href="https://td2.info.pl/profile/?u=20777">Spythere</a>
{{ new Date().getUTCFullYear() }} | v.{{ appVersion }}
{{ new Date().getUTCFullYear() }} |
<button class="g-button text" @click="store.updateCardOpen = true">v.{{ appVersion }}</button>
</footer>
</div>
</template>
@@ -23,8 +26,14 @@ import packageInfo from '../package.json';
import { useStore } from './store/store';
import orderStorageMixin from './mixins/orderStorageMixin';
import StorageManager from './managers/storageManager';
import axios from 'axios';
import UpdateCard from './components/UpdateCard.vue';
const STORAGE_VERSION_KEY = 'app_version';
export default defineComponent({
components: { UpdateCard },
mixins: [orderStorageMixin],
setup() {
@@ -43,6 +52,7 @@ export default defineComponent({
methods: {
init() {
this.checkAppVersion();
this.loadLang();
this.loadSettings();
this.handleQueries();
@@ -63,6 +73,30 @@ export default defineComponent({
}
},
async checkAppVersion() {
const storageVersion = StorageManager.getStringValue(STORAGE_VERSION_KEY);
try {
const releaseData = await (
await axios.get('https://api.github.com/repos/Spythere/genera-tor/releases/latest')
).data;
if (!releaseData) return;
this.store.appUpdateData.version = this.appVersion;
this.store.appUpdateData.changelog = releaseData.body;
this.store.appUpdateData.releaseURL = releaseData.html_url;
this.store.updateCardOpen =
(storageVersion != '' && storageVersion != this.appVersion) ||
import.meta.env.VITE_UPDATE_TEST === 'test';
} catch (error) {
console.error(`Wystąpił błąd podczas pobierania danych z API GitHuba: ${error}`);
}
StorageManager.setStringValue(STORAGE_VERSION_KEY, this.appVersion);
},
changeLang(lang: string) {
this.$i18n.locale = lang;
this.store.currentAppLocale = lang;
+145
View File
@@ -0,0 +1,145 @@
<template>
<div class="update-card" v-if="store.updateCardOpen" @toggle-card="toggleCard(false)">
<div class="card-background"></div>
<div class="card-content">
<h1 style="margin-bottom: 0.5em">🚀 {{ $t('update.title') }}</h1>
<div class="changelog" v-if="htmlChangelog != ''" v-html="htmlChangelog"></div>
<div class="no-features" v-else>{{ $t('update.no-data') }}</div>
<button class="g-button action btn-confirm" ref="confirmButtonEl" @click="toggleCard(false)">
{{ $t('update.confirm') }}
</button>
<p class="bottom-info">
{{ $t('update.info-1') }}
<br />
<span v-html="$t('update.info-2')"></span>
</p>
</div>
</div>
</template>
<script lang="ts" setup>
import { computed, defineComponent, ref, watch } from 'vue';
import { Converter } from 'showdown';
import { useStore } from '../store/store';
const converter = new Converter();
const store = useStore();
const confirmButtonEl = ref<HTMLButtonElement | null>(null);
watch(
computed(() => store.updateCardOpen),
(val) => {
console.log(val, confirmButtonEl);
if (val) {
confirmButtonEl.value?.focus();
}
}
);
const htmlChangelog = computed(() => {
if (store.appUpdateData.changelog == '') return '';
return converter.makeHtml(store.appUpdateData.changelog);
});
function toggleCard(value: boolean) {
store.updateCardOpen = value;
}
</script>
<style lang="scss" scoped>
// Converter styles
::v-deep(h1) {
text-align: center;
color: var(--clr-primary);
}
::v-deep(h2) {
padding: 0.25em 0;
border-bottom: 1px solid #aaa;
}
::v-deep(ul) {
list-style: disc;
padding: 1em;
line-height: 1.5em;
text-align: justify;
}
.update-card {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 200;
display: flex;
justify-content: center;
align-items: center;
}
.card-background {
position: absolute;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
z-index: 250;
cursor: pointer;
background-color: rgba(0, 0, 0, 0.55);
}
.card-content {
display: grid;
grid-template-rows: auto 1fr auto;
gap: 0.5em;
margin: 1em;
max-height: 95vh;
max-height: 95dvh;
background-color: #1a1a1a;
box-shadow: 0 0 15px 10px #0e0e0e;
border-radius: 1em;
overflow: auto;
padding: 1em;
min-height: 700px;
overflow: auto;
max-width: 700px;
z-index: 300;
}
.no-features {
text-align: center;
}
.changelog {
text-align: left;
}
button.btn-confirm {
padding: 0.5em 0.75em;
font-size: 1.1em;
}
p.bottom-info {
text-align: center;
color: #ccc;
}
a {
text-decoration: underline;
}
</style>
+9
View File
@@ -8,6 +8,15 @@
"order-list": "SAVED ORDERS",
"order-train-picker": "TRAINS"
},
"update": {
"update-available-text": "New GeneraTOR version is available!",
"update-available-underline": "Click here to update!",
"title": "Stacjownik update!",
"confirm": "ROGER THAT!",
"no-data": "No changelog available!",
"info-1": "This changelog will be available to see once again after clicking the version number in the footer",
"info-2": "The full app changelog available on <a href='https://github.com/Spythere/genera-tor' target='_blank'>the project's GitHub</a>"
},
"order-message": {
"title": "Message to display in the simulator's chatbox:",
"info": "Copy or save the content of the generated train order using buttons below:",
+9
View File
@@ -3,6 +3,15 @@
"pl": "POLSKI",
"en": "ANGIELSKI"
},
"update": {
"update-available-text": "Nowa wersja GeneraTORa dostępna!",
"update-available-underline": "Kliknij, aby odświeżyć aplikację!",
"title": "Aktualizacja GeneraTORa!",
"no-data": "Brak dostępnego changelogu!",
"confirm": "Przyjąłem!",
"info-1": "Ten changelog będzie zawsze dostępny po kliknięciu numeru wersji w stopce strony",
"info-2": "Pełny changelog dostępny na <a href='https://github.com/Spythere/genera-tor' target='_blank'>GitHubie projektu</a>"
},
"navbar": {
"order-message": "TREŚĆ ROZKAZU",
"order-list": "ZAPISANE ROZKAZY",
+7
View File
@@ -11,6 +11,13 @@ export const useStore = defineStore('store', {
return {
currentAppLocale: 'pl',
appUpdateData: {
version: '',
changelog: '',
releaseURL: ''
},
updateCardOpen: false,
helperModalOpen: false,
orderDarkMode: false,