4
0
mirror of https://github.com/AzuraCast/AzuraCast.git synced 2024-06-14 05:06:37 +00:00
AzuraCast/frontend/vue/base.js
2022-12-29 14:48:00 -06:00

48 lines
1.3 KiB
JavaScript

import {createApp, h} from "vue";
import installBootstrapVue from "./vendor/bootstrapVue";
import installSweetAlert from "./vendor/sweetalert";
import installAxios from "~/vendor/axios";
import {installPinia} from '~/vendor/pinia';
import {useNotifyBus} from "~/vendor/events";
import {installTranslate} from "~/vendor/gettext";
export default function (component) {
const vueApp = createApp({
mounted() {
// Workaround to use BootstrapVue toast notifications in Vue 3 composition API.
const notifyBus = useNotifyBus();
notifyBus.on((event, payload) => {
if (event === 'show') {
this.$bvToast.toast(payload.message, payload.options);
} else if (event === 'hide') {
this.$bvToast.hide(payload.id);
}
});
},
render() {
return h(component, this.$appProps)
},
});
/* Gettext */
installTranslate(vueApp);
/* Axios */
installAxios(vueApp);
/* Pinia */
installPinia(vueApp);
/* Bootstrap Vue */
installBootstrapVue(vueApp);
/* SweetAlert */
installSweetAlert(vueApp);
return function (el, props) {
vueApp.config.globalProperties.$appProps = props;
vueApp.mount(el);
};
}