mirror of
https://github.com/Spythere/station-manager-2.0.git
synced 2026-05-03 13:38:13 +00:00
Migracja projektu na Vite
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import { defineComponent } from 'vue';
|
||||
import { useStore } from '../store';
|
||||
import axios from 'axios';
|
||||
|
||||
export default defineComponent({
|
||||
setup() {
|
||||
return {
|
||||
store: useStore(),
|
||||
};
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
API_URL: import.meta.env.PROD ? 'https://stacjownik.eu-4.evennode.com' : import.meta.env.VITE_API_URL,
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
async loadData() {
|
||||
try {
|
||||
this.store.dataState = 'LOADING';
|
||||
|
||||
const data = (
|
||||
await axios.get(`${this.API_URL}/api/getSceneries?time=${Date.now()}`, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${this.store.token}`,
|
||||
},
|
||||
})
|
||||
).data;
|
||||
|
||||
this.store.backupList = JSON.stringify(data);
|
||||
this.store.stationList = data;
|
||||
this.store.unsavedChanges = false;
|
||||
this.store.changeList = [];
|
||||
this.store.changeBackupList = [];
|
||||
|
||||
this.store.dataState = 'LOADED';
|
||||
} catch (error) {
|
||||
this.store.dataState = 'ERROR';
|
||||
this.store.token = '';
|
||||
this.store.isAuthorized = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user