Merge pull request 'rebase-to-store' (#6) from rebase-to-store into master
Some checks are pending
Gitea Actions / Build and deploy (push) Waiting to run

Reviewed-on: http://gitea.dhaverd.ru/Dhaverd/New-site/pulls/6
This commit is contained in:
Dhaverd 2024-04-20 11:14:03 +03:00
commit 7615ca7605
8 changed files with 94 additions and 52 deletions

View File

@ -1,5 +1,6 @@
import './js/bootstrap';
import {createApp} from 'vue'
import { createPinia } from 'pinia'
import App from './views/basya/Basya.vue'
import { createVuetify } from 'vuetify'
import { mdi } from "vuetify/iconsets/mdi";
@ -8,9 +9,11 @@ import * as components from 'vuetify/components'
import * as directives from 'vuetify/directives'
import '@mdi/font/css/materialdesignicons.css'
const pinia = createPinia();
const vuetify = createVuetify({
components,
directives
})
createApp(App).use(vuetify).mount("#app")
createApp(App).use(vuetify).use(pinia).mount("#app")

View File

@ -1,15 +0,0 @@
import {defineStore} from "pinia";
export const useScheduleStore = defineStore('Schedule', {
state: () => ({
fetchingDates: true,
fetchingTable: true,
fetchingLinks: true
}),
getters: {
},
actions: {
},
})

20
resources/stores/basya.js Normal file
View File

@ -0,0 +1,20 @@
import {defineStore} from "pinia";
import axios from "axios";
export const useBasyaStore = defineStore('basya', {
state: () => ({
phrases: Object
}),
getters: {
},
actions: {
async getPhrases(){
await axios
.get('/api/v1/phrases')
.then((response) => {
this.phrases = response.data;
});
}
},
})

View File

@ -0,0 +1,37 @@
import {defineStore} from "pinia";
import axios from "axios";
export const useScheduleStore = defineStore('schedule', {
state: () => ({
dates: Object,
links: Object,
schedules: Object
}),
getters: {
},
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;
})
}
},
})

View File

@ -10,33 +10,30 @@
</template>
<script>
import axios from "axios";
import ScheduleTable from "./Schedule/ScheduleTable.vue";
import Links from "./Schedule/Links.vue";
import {ref} from "vue";
import {useScheduleStore} from '../stores/schedule.js';
export default {
name: "Schedule",
components: {Links, ScheduleTable},
data: () => ({
dates: [],
dates: ref(),
scheduleStore: useScheduleStore(),
fetching: true
}),
methods: {
parseDate(date){
let dateArr = date.split("-");
return dateArr[2] + "." + dateArr[1];
},
async getDates(){
await axios
.get('/api/v1/dates')
.then(response => {
this.dates = response.data;
this.fetching = false;
});
}
},
mounted() {
this.getDates();
this.scheduleStore.getDates().then(()=>{
this.dates = this.scheduleStore.dates;
this.fetching = false;
});
}
}
</script>

View File

@ -1,22 +1,22 @@
<script>
import axios from "axios";
import {ref} from "vue";
import {useScheduleStore} from '../../stores/schedule.js';
export default {
name: "Links",
data: () => ({
links: [],
links: ref(),
fetching: true,
scheduleStore: useScheduleStore(),
windowHeight: document.documentElement.clientHeight,
windowWidth: document.documentElement.clientWidth,
isWide: window.innerWidth >= 460
}),
mounted() {
axios
.get('/api/v1/links')
.then(response => {
this.links = response.data;
this.fetching = false;
});
this.scheduleStore.getLinks().then(()=>{
this.links = this.scheduleStore.links;
this.fetching = false;
});
this.myEventHandler();
window.addEventListener("resize", this.myEventHandler, { passive: true });
},

View File

@ -1,10 +1,12 @@
<script>
import axios from "axios";
import {useScheduleStore} from '../../stores/schedule.js';
import {ref} from "vue";
export default {
name: "ScheduleTable",
data: () => ({
schedules: [],
schedules: ref(),
scheduleStore: useScheduleStore(),
fetching: true
}),
methods: {
@ -14,12 +16,10 @@
}
},
mounted() {
axios
.get('/api/v1/schedules')
.then(response => {
this.schedules = response.data;
this.fetching = false;
});
this.scheduleStore.getSchedules().then(()=>{
this.schedules = this.scheduleStore.schedules;
this.fetching = false;
});
}
}
</script>

View File

@ -34,7 +34,8 @@
<script>
import {ref} from 'vue';
import axios from "axios";
import {useBasyaStore} from "../../stores/basya.js";
export default {
name: "Basya",
data: () => ({
@ -44,7 +45,8 @@ export default {
currentPhrase: ref(),
winWidth: ref(document.documentElement.clientWidth),
// size: ref(),
isLess: false
isLess: false,
basyaStore: useBasyaStore()
}),
methods: {
reloadPhrase(){
@ -61,13 +63,11 @@ export default {
}
},
mounted() {
axios
.get('/api/v1/phrases')
.then(response => {
this.phrases = response.data;
this.reloadPhrase();
this.fetching = false;
});
this.basyaStore.getPhrases().then(()=>{
this.phrases = this.basyaStore.phrases;
this.reloadPhrase();
this.fetching = false;
})
this.isLess = ref(this.winWidth.value <= 600 ? 'flex-column' : '');
/*
this.size = this.winWidth <= 600 ? 'x-small' :