dragonroll/plugins/dnd-5e/client/data.js

48 lines
879 B
JavaScript
Raw Normal View History

2024-10-11 22:35:06 +00:00
import { Api } from './main.js'
2024-10-11 17:33:28 +00:00
import Server from '@/services/Server'
import { reactive } from 'vue';
2024-10-11 22:35:06 +00:00
import { GetCampaign } from "@/services/Dragonroll";
2024-10-11 17:33:28 +00:00
let data = reactive({});
function InitData(){
data.value = {
2024-10-11 22:35:06 +00:00
concepts: []
2024-10-11 17:33:28 +00:00
};
}
function FetchConcepts(){
Server().get('/concept/list?campaign=' + GetCampaign()._id).then(response => {
data.value.concepts = response.data.data;
}).catch((err) => console.log(err));
}
function FetchData(){
FetchConcepts();
}
2024-10-12 09:20:10 +00:00
Api.socket.on('update-concepts', () => {
FetchConcepts();
});
/*
2024-10-11 17:33:28 +00:00
socket.on('update-concepts', () => {
FetchConcepts();
});
2024-10-12 09:20:10 +00:00
*/
2024-10-11 17:33:28 +00:00
let GetConcepts = () => data.value.concepts;
let GetConcept = (id) => Server().get('/concept/get?campaign=' + GetCampaign()._id + "&id=" + id)
export {
InitData,
FetchData,
FetchConcepts,
GetConcepts,
GetConcept,
}