Запилил стор для расписания стримов
This commit is contained in:
parent
d128e6f90a
commit
e04bc5ba98
|
@ -1,15 +1,37 @@
|
||||||
import {defineStore} from "pinia";
|
import {defineStore} from "pinia";
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
export const useScheduleStore = defineStore('Schedule', {
|
export const useScheduleStore = defineStore('Schedule', {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
fetchingDates: true,
|
dates: Object,
|
||||||
fetchingTable: true,
|
links: Object,
|
||||||
fetchingLinks: true
|
schedules: Object
|
||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
|
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
|
async getDates(){
|
||||||
|
await axios
|
||||||
|
.get('/api/v1/dates')
|
||||||
|
.then((response) => {
|
||||||
|
this.dates = response.data;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
async getLinks(){
|
||||||
|
await axios
|
||||||
|
.get('/api/v1/links')
|
||||||
|
.then((response)=>{
|
||||||
|
this.links = response.data;
|
||||||
|
})
|
||||||
|
},
|
||||||
|
async getSchedules(){
|
||||||
|
await axios
|
||||||
|
.get('/api/v1/schedules')
|
||||||
|
.then((response)=>{
|
||||||
|
this.schedules = response.data;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -10,33 +10,30 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import axios from "axios";
|
|
||||||
import ScheduleTable from "./Schedule/ScheduleTable.vue";
|
import ScheduleTable from "./Schedule/ScheduleTable.vue";
|
||||||
import Links from "./Schedule/Links.vue";
|
import Links from "./Schedule/Links.vue";
|
||||||
|
import {ref} from "vue";
|
||||||
|
import {useScheduleStore} from '../stores/schedule.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Schedule",
|
name: "Schedule",
|
||||||
components: {Links, ScheduleTable},
|
components: {Links, ScheduleTable},
|
||||||
data: () => ({
|
data: () => ({
|
||||||
dates: [],
|
dates: ref(),
|
||||||
|
scheduleStore: useScheduleStore(),
|
||||||
fetching: true
|
fetching: true
|
||||||
}),
|
}),
|
||||||
methods: {
|
methods: {
|
||||||
parseDate(date){
|
parseDate(date){
|
||||||
let dateArr = date.split("-");
|
let dateArr = date.split("-");
|
||||||
return dateArr[2] + "." + dateArr[1];
|
return dateArr[2] + "." + dateArr[1];
|
||||||
},
|
|
||||||
async getDates(){
|
|
||||||
await axios
|
|
||||||
.get('/api/v1/dates')
|
|
||||||
.then(response => {
|
|
||||||
this.dates = response.data;
|
|
||||||
this.fetching = false;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.getDates();
|
this.scheduleStore.getDates().then(()=>{
|
||||||
|
this.dates = this.scheduleStore.dates;
|
||||||
|
this.fetching = false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
<script>
|
<script>
|
||||||
import axios from "axios";
|
import {ref} from "vue";
|
||||||
|
import {useScheduleStore} from '../../stores/schedule.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Links",
|
name: "Links",
|
||||||
data: () => ({
|
data: () => ({
|
||||||
links: [],
|
links: ref(),
|
||||||
fetching: true,
|
fetching: true,
|
||||||
|
scheduleStore: useScheduleStore(),
|
||||||
windowHeight: document.documentElement.clientHeight,
|
windowHeight: document.documentElement.clientHeight,
|
||||||
windowWidth: document.documentElement.clientWidth,
|
windowWidth: document.documentElement.clientWidth,
|
||||||
isWide: window.innerWidth >= 460
|
isWide: window.innerWidth >= 460
|
||||||
}),
|
}),
|
||||||
mounted() {
|
mounted() {
|
||||||
axios
|
this.scheduleStore.getLinks().then(()=>{
|
||||||
.get('/api/v1/links')
|
this.links = this.scheduleStore.links;
|
||||||
.then(response => {
|
this.fetching = false;
|
||||||
this.links = response.data;
|
});
|
||||||
this.fetching = false;
|
|
||||||
});
|
|
||||||
this.myEventHandler();
|
this.myEventHandler();
|
||||||
window.addEventListener("resize", this.myEventHandler, { passive: true });
|
window.addEventListener("resize", this.myEventHandler, { passive: true });
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
<script>
|
<script>
|
||||||
import axios from "axios";
|
import {useScheduleStore} from '../../stores/schedule.js';
|
||||||
|
import {ref} from "vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "ScheduleTable",
|
name: "ScheduleTable",
|
||||||
data: () => ({
|
data: () => ({
|
||||||
schedules: [],
|
schedules: ref(),
|
||||||
|
scheduleStore: useScheduleStore(),
|
||||||
fetching: true
|
fetching: true
|
||||||
}),
|
}),
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -14,12 +16,10 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
axios
|
this.scheduleStore.getSchedules().then(()=>{
|
||||||
.get('/api/v1/schedules')
|
this.schedules = this.scheduleStore.schedules;
|
||||||
.then(response => {
|
this.fetching = false;
|
||||||
this.schedules = response.data;
|
});
|
||||||
this.fetching = false;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue