mirror of
https://github.com/Spythere/pragotron-td2.git
synced 2026-05-03 13:38:14 +00:00
chore: options in local storage
This commit is contained in:
+23
-4
@@ -19,23 +19,42 @@ import { defineComponent } from 'vue';
|
|||||||
import packageInfo from '../package.json';
|
import packageInfo from '../package.json';
|
||||||
import { useApiStore } from './stores/apiStore';
|
import { useApiStore } from './stores/apiStore';
|
||||||
import Navbar from './components/Navbar.vue';
|
import Navbar from './components/Navbar.vue';
|
||||||
|
import { useMainStore } from './stores/mainStore';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: { Navbar },
|
components: { Navbar },
|
||||||
|
|
||||||
data: () => ({
|
data: () => ({
|
||||||
version: packageInfo.version,
|
version: packageInfo.version,
|
||||||
apiStore: useApiStore()
|
apiStore: useApiStore(),
|
||||||
|
mainStore: useMainStore()
|
||||||
}),
|
}),
|
||||||
|
|
||||||
async mounted() {
|
methods: {
|
||||||
this.apiStore.fetchSceneriesData();
|
loadLocalSettings() {
|
||||||
|
const settingsStorage = window.localStorage.getItem('settings');
|
||||||
|
|
||||||
|
if (settingsStorage != null) {
|
||||||
|
const settingsObj = JSON.parse(settingsStorage) as Record<string, any>;
|
||||||
|
|
||||||
|
Object.keys(settingsObj).forEach((key) => {
|
||||||
|
(this.mainStore.filters as any)[key] = settingsObj[key];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
created() {
|
||||||
|
this.apiStore.fetchSceneriesData();
|
||||||
this.apiStore.fetchActiveData();
|
this.apiStore.fetchActiveData();
|
||||||
|
|
||||||
|
this.loadLocalSettings();
|
||||||
|
},
|
||||||
|
|
||||||
|
mounted() {
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
this.apiStore.fetchActiveData();
|
this.apiStore.fetchActiveData();
|
||||||
}, 30000);
|
}, 20000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -9,7 +9,15 @@
|
|||||||
<h3>Opcje</h3>
|
<h3>Opcje</h3>
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
<div style="margin: 0.5em 0">
|
<div
|
||||||
|
style="
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 0.5em;
|
||||||
|
margin: 0.5em 0;
|
||||||
|
"
|
||||||
|
>
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" v-model="store.filters.nonPassenger" />
|
<input type="checkbox" v-model="store.filters.nonPassenger" />
|
||||||
Relacje niepasażerskie
|
Relacje niepasażerskie
|
||||||
@@ -19,9 +27,14 @@
|
|||||||
<input type="checkbox" v-model="store.filters.terminating" />
|
<input type="checkbox" v-model="store.filters.terminating" />
|
||||||
Relacje kończące bieg
|
Relacje kończące bieg
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" v-model="store.filters.soundsEnabled" />
|
||||||
|
Dźwięki
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="isPragotronOpen">
|
<div v-if="isPragotronOpen" style="margin: 0.5em 0">
|
||||||
<label for="checkpoint">
|
<label for="checkpoint">
|
||||||
Posterunek:
|
Posterunek:
|
||||||
<select id="checkpoint" v-model="store.selectedCheckpointName">
|
<select id="checkpoint" v-model="store.selectedCheckpointName">
|
||||||
@@ -51,6 +64,15 @@ export default defineComponent({
|
|||||||
isPragotronOpen() {
|
isPragotronOpen() {
|
||||||
return this.$route.path == '/board';
|
return this.$route.path == '/board';
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
watch: {
|
||||||
|
'store.filters': {
|
||||||
|
deep: true,
|
||||||
|
handler(filters: typeof this.store.filters) {
|
||||||
|
window.localStorage.setItem('settings', JSON.stringify(filters));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@@ -65,7 +87,6 @@ h3 {
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.dropdown-bg {
|
.dropdown-bg {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
|||||||
@@ -25,7 +25,9 @@ export const useMainStore = defineStore('main', {
|
|||||||
optionsOpen: false,
|
optionsOpen: false,
|
||||||
filters: {
|
filters: {
|
||||||
nonPassenger: true,
|
nonPassenger: true,
|
||||||
terminating: true
|
terminating: true,
|
||||||
|
timetableMode: 'departures' as 'departures' | 'arrivals',
|
||||||
|
soundsEnabled: false
|
||||||
},
|
},
|
||||||
selectedStationName: '',
|
selectedStationName: '',
|
||||||
selectedCheckpointName: ''
|
selectedCheckpointName: ''
|
||||||
|
|||||||
@@ -220,7 +220,10 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
animatingStatus(val: typeof this.animatingStatus) {
|
animatingStatus(val: typeof this.animatingStatus) {
|
||||||
if (val == 'running') (this.$refs['audio'] as HTMLAudioElement).play();
|
if (val == 'running' && this.mainStore.filters.soundsEnabled)
|
||||||
|
(this.$refs['audio'] as HTMLAudioElement).play().catch((err) => {
|
||||||
|
console.error('Dźwięk nie mógł zostać odtworzony:', err);
|
||||||
|
});
|
||||||
else {
|
else {
|
||||||
(this.$refs['audio'] as HTMLAudioElement).currentTime = 0;
|
(this.$refs['audio'] as HTMLAudioElement).currentTime = 0;
|
||||||
(this.$refs['audio'] as HTMLAudioElement).pause();
|
(this.$refs['audio'] as HTMLAudioElement).pause();
|
||||||
|
|||||||
Reference in New Issue
Block a user