This commit is contained in:
2024-03-30 13:24:39 +01:00
parent c8f53c2f06
commit d05579c5ee
13 changed files with 113 additions and 125 deletions
+27 -31
View File
@@ -34,11 +34,12 @@
</template>
<script lang="ts">
import { defineComponent, watch } from 'vue';
import { defineComponent } from 'vue';
import axios from 'axios';
import { version } from '.././package.json';
import { useMainStore } from './store/mainStore';
import popupMixin from './mixins/popupMixin';
import Clock from './components/App/Clock.vue';
import StatusIndicator from './components/App/StatusIndicator.vue';
@@ -48,7 +49,6 @@ import StorageManager from './managers/storageManager';
import PopUp from './components/PopUp/PopUp.vue';
import { useApiStore } from './store/apiStore';
import { Status } from './typings/common';
import { usePopupStore } from './store/popupStore';
const STORAGE_VERSION_KEY = 'app_version';
@@ -61,11 +61,12 @@ export default defineComponent({
PopUp
},
mixins: [popupMixin],
data: () => ({
VERSION: version,
store: useMainStore(),
apiStore: useApiStore(),
popupStore: usePopupStore(),
currentLang: 'pl',
releaseURL: '',
@@ -83,33 +84,7 @@ export default defineComponent({
this.apiStore.fetchActiveData();
});
// popup handling
window.addEventListener('mousemove', (e: MouseEvent) => {
const targetEl = e
.composedPath()
.find((p) => p instanceof HTMLElement && p.getAttribute('data-popup-key'));
if (!targetEl || !(targetEl instanceof HTMLElement)) {
if (this.popupStore.currentPopupComponent != null) this.popupStore.onPopUpHide();
return;
}
const popupComponentKey = targetEl.getAttribute('data-popup-key');
const popupContent = targetEl.getAttribute('data-popup-content');
if (popupComponentKey && popupContent)
this.popupStore.onPopUpShow(e, popupComponentKey, popupContent);
else if (this.popupStore.currentPopupComponent != null) this.popupStore.onPopUpHide();
});
watch(
() => this.store.blockScroll,
(value) => {
if (value) document.body.classList.add('no-scroll');
else document.body.classList.remove('no-scroll');
}
);
window.addEventListener('mousemove', (e: MouseEvent) => this.handlePopUpEvents(e));
},
methods: {
@@ -162,6 +137,27 @@ export default defineComponent({
this.apiStore.connectToAPI();
},
handlePopUpEvents(e: MouseEvent) {
const targetEl = e
.composedPath()
.find((p) => p instanceof HTMLElement && p.getAttribute('data-popup-key'));
if (!targetEl || !(targetEl instanceof HTMLElement)) {
if (this.store.popUpData.key != null) this.hidePopUp();
return;
}
const popupComponentKey = targetEl.getAttribute('data-popup-key');
const popupContent = targetEl.getAttribute('data-popup-content');
if (popupComponentKey && popupContent) this.showPopUp(e, popupComponentKey, popupContent);
else if (this.store.popUpData.key != null) this.hidePopUp();
this.store.mousePos.x = e.pageX;
this.store.mousePos.y = e.pageY;
},
changeLang(lang: string) {
this.$i18n.locale = lang;
this.currentLang = lang;
@@ -241,7 +237,7 @@ export default defineComponent({
grid-template-columns: 100%;
min-height: 100vh;
position: relative;
overflow: hidden;
}
.app_main {