CS: eslint

parent 0cbafba0
require('./bootstrap'); require('./bootstrap');
import Vue from 'vue' import Vue from 'vue';
import VueI18n from 'vue-i18n' import VueI18n from 'vue-i18n';
import VueRouter from 'vue-router' import VueRouter from 'vue-router';
import ElementUI from 'element-ui' import ElementUI from 'element-ui';
import DataTables from 'vue-data-tables' import DataTables from 'vue-data-tables';
import VueEvents from 'vue-events' import VueEvents from 'vue-events';
import locale from 'element-ui/lib/locale/lang/en' import locale from 'element-ui/lib/locale/lang/en';
import VueSimplemde from 'vue-simplemde' import VueSimplemde from 'vue-simplemde';
Vue.use(ElementUI, { locale }); Vue.use(ElementUI, { locale });
Vue.use(DataTables, { locale }); Vue.use(DataTables, { locale });
Vue.use(VueI18n); Vue.use(VueI18n);
Vue.use(VueRouter); Vue.use(VueRouter);
Vue.use(require('vue-shortkey'), { prevent: ['input', 'textarea'] }); Vue.use(require('vue-shortkey'), { prevent: ['input', 'textarea'] });
Vue.use(VueEvents); Vue.use(VueEvents);
Vue.use(VueSimplemde); Vue.use(VueSimplemde);
require('./mixins'); require('./mixins');
...@@ -24,62 +25,63 @@ Vue.component('DeleteButton', require('../../../Modules/Core/Assets/js/component ...@@ -24,62 +25,63 @@ Vue.component('DeleteButton', require('../../../Modules/Core/Assets/js/component
Vue.component('TagsInput', require('../../../Modules/Tag/Assets/js/components/TagInput.vue')); Vue.component('TagsInput', require('../../../Modules/Tag/Assets/js/components/TagInput.vue'));
Vue.component('SingleMedia', require('../../../Modules/Media/Assets/js/components/SingleMedia.vue')); Vue.component('SingleMedia', require('../../../Modules/Media/Assets/js/components/SingleMedia.vue'));
Vue.component('MediaManager', require('../../../Modules/Media/Assets/js/components/MediaManager.vue')); Vue.component('MediaManager', require('../../../Modules/Media/Assets/js/components/MediaManager.vue'));
import PageRoutes from '../../../Modules/Page/Assets/js/PageRoutes'; import PageRoutes from '../../../Modules/Page/Assets/js/PageRoutes';
import MediaRoutes from '../../../Modules/Media/Assets/js/MediaRoutes'; import MediaRoutes from '../../../Modules/Media/Assets/js/MediaRoutes';
const currentLocale = window.AsgardCMS.currentLocale; const currentLocale = window.AsgardCMS.currentLocale;
const adminPrefix = window.AsgardCMS.adminPrefix; const adminPrefix = window.AsgardCMS.adminPrefix;
const router = new VueRouter({ const router = new VueRouter({
mode: 'history', mode: 'history',
base: makeBaseUrl(), base: makeBaseUrl(),
routes : [ routes: [
...PageRoutes, ...PageRoutes,
...MediaRoutes, ...MediaRoutes,
], ],
}); });
function makeBaseUrl() { function makeBaseUrl() {
if (window.AsgardCMS.hideDefaultLocaleInURL == 1) { if (window.AsgardCMS.hideDefaultLocaleInURL == 1) {
return adminPrefix; return adminPrefix;
} }
return `${currentLocale}/${adminPrefix}`; return `${currentLocale}/${adminPrefix}`;
} }
let messages = { const messages = {
[currentLocale]: window.AsgardCMS.translations, [currentLocale]: window.AsgardCMS.translations,
}; };
const i18n = new VueI18n({ const i18n = new VueI18n({
locale: currentLocale, locale: currentLocale,
messages, messages,
}); });
const app = new Vue({ const app = new Vue({
el: '#app', el: '#app',
router, router,
i18n, i18n,
}); });
window.axios.interceptors.response.use(null, function(error) { window.axios.interceptors.response.use(null, (error) => {
if (error.response === undefined) { if (error.response === undefined) {
console.log(error); console.log(error);
return; return;
} }
if (error.response.status === 403) { if (error.response.status === 403) {
app.$notify.error({ app.$notify.error({
title: app.$t('core.unauthorized'), title: app.$t('core.unauthorized'),
message: app.$t('core.unauthorized-access'), message: app.$t('core.unauthorized-access'),
}); });
window.location = route('dashboard.index'); window.location = route('dashboard.index');
} }
if (error.response.status === 401) { if (error.response.status === 401) {
app.$notify.error({ app.$notify.error({
title: app.$t('core.unauthenticated'), title: app.$t('core.unauthenticated'),
message: app.$t('core.unauthenticated-message'), message: app.$t('core.unauthenticated-message'),
}); });
window.location = route('login'); window.location = route('login');
} }
return Promise.reject(error); return Promise.reject(error);
}); });
...@@ -29,28 +29,28 @@ window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; ...@@ -29,28 +29,28 @@ window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
* a simple convenience so we don't have to attach every token manually. * a simple convenience so we don't have to attach every token manually.
*/ */
let token = document.head.querySelector('meta[name="csrf-token"]'); const token = document.head.querySelector('meta[name="csrf-token"]');
if (token) { if (token) {
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content; window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
} else { } else {
console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token'); console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
} }
let userApiToken = document.head.querySelector('meta[name="user-api-token"]'); const userApiToken = document.head.querySelector('meta[name="user-api-token"]');
if (userApiToken) { if (userApiToken) {
window.axios.defaults.headers.common['Authorization'] = 'Bearer ' + userApiToken.content; window.axios.defaults.headers.common.Authorization = `Bearer ${userApiToken.content}`;
} else { } else {
console.error('User API token not found in a meta tag.'); console.error('User API token not found in a meta tag.');
} }
let currentLocale = document.head.querySelector('meta[name="current-locale"]'); const currentLocale = document.head.querySelector('meta[name="current-locale"]');
if (currentLocale) { if (currentLocale) {
window.AsgardCMS.currentLocale = currentLocale.content; window.AsgardCMS.currentLocale = currentLocale.content;
} else { } else {
console.error('Current locale token not found in a meta tag.'); console.error('Current locale token not found in a meta tag.');
} }
......
import Vue from 'vue' import Vue from 'vue';
import TranslationHelper from '../../../Modules/Core/Assets/js/mixins/TranslationHelper' import TranslationHelper from '../../../Modules/Core/Assets/js/mixins/TranslationHelper';
Vue.mixin(TranslationHelper); Vue.mixin(TranslationHelper);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment