2020-06-06 20:03:55 +02:00
|
|
|
import Vue from 'vue';
|
|
|
|
import Buefy from 'buefy';
|
2020-07-05 14:05:05 +02:00
|
|
|
import humps from 'humps';
|
2020-12-19 11:55:52 +01:00
|
|
|
import VueI18n from 'vue-i18n';
|
2020-06-06 20:03:55 +02:00
|
|
|
|
|
|
|
import App from './App.vue';
|
|
|
|
import router from './router';
|
|
|
|
import store from './store';
|
|
|
|
import * as api from './api';
|
2020-07-08 13:00:14 +02:00
|
|
|
import { models } from './constants';
|
2021-01-26 17:27:27 +01:00
|
|
|
import Utils from './utils';
|
2020-06-06 20:03:55 +02:00
|
|
|
|
2020-12-19 11:55:52 +01:00
|
|
|
// Internationalisation.
|
|
|
|
Vue.use(VueI18n);
|
|
|
|
const i18n = new VueI18n();
|
|
|
|
|
2020-06-06 20:03:55 +02:00
|
|
|
Vue.use(Buefy, {});
|
|
|
|
Vue.config.productionTip = false;
|
|
|
|
|
2021-01-26 17:27:27 +01:00
|
|
|
// Globals.
|
|
|
|
const ut = new Utils(i18n);
|
|
|
|
Vue.mixin({
|
|
|
|
computed: {
|
|
|
|
$utils: () => ut,
|
|
|
|
$api: () => api,
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
$reloadServerConfig: () => {
|
|
|
|
// Get the config.js <script> tag, remove it, and re-add it.
|
|
|
|
let s = document.querySelector('#server-config');
|
|
|
|
const url = s.getAttribute('src');
|
|
|
|
s.remove();
|
|
|
|
|
|
|
|
s = document.createElement('script');
|
|
|
|
s.setAttribute('src', url);
|
|
|
|
s.setAttribute('id', 'server-config');
|
|
|
|
s.onload = () => {
|
|
|
|
store.commit('setModelResponse',
|
|
|
|
{ model: models.serverConfig, data: humps.camelizeKeys(window.CONFIG) });
|
|
|
|
};
|
|
|
|
document.body.appendChild(s);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2020-09-20 13:01:24 +02:00
|
|
|
|
2020-07-05 14:05:05 +02:00
|
|
|
// window.CONFIG is loaded from /api/config.js directly in a <script> tag.
|
2020-07-08 13:00:14 +02:00
|
|
|
if (window.CONFIG) {
|
|
|
|
store.commit('setModelResponse',
|
|
|
|
{ model: models.serverConfig, data: humps.camelizeKeys(window.CONFIG) });
|
2020-12-19 11:55:52 +01:00
|
|
|
|
|
|
|
// Load language.
|
|
|
|
i18n.locale = window.CONFIG.lang['_.code'];
|
|
|
|
i18n.setLocaleMessage(i18n.locale, window.CONFIG.lang);
|
2020-07-08 13:00:14 +02:00
|
|
|
}
|
2020-07-05 14:05:05 +02:00
|
|
|
|
2020-06-06 20:03:55 +02:00
|
|
|
new Vue({
|
|
|
|
router,
|
|
|
|
store,
|
2020-12-19 11:55:52 +01:00
|
|
|
i18n,
|
2020-06-06 20:03:55 +02:00
|
|
|
render: (h) => h(App),
|
|
|
|
}).$mount('#app');
|