CS: eslint

parent 0cbafba0
require('./bootstrap');
import Vue from 'vue'
import VueI18n from 'vue-i18n'
import VueRouter from 'vue-router'
import ElementUI from 'element-ui'
import DataTables from 'vue-data-tables'
import VueEvents from 'vue-events'
import locale from 'element-ui/lib/locale/lang/en'
import VueSimplemde from 'vue-simplemde'
import Vue from 'vue';
import VueI18n from 'vue-i18n';
import VueRouter from 'vue-router';
import ElementUI from 'element-ui';
import DataTables from 'vue-data-tables';
import VueEvents from 'vue-events';
import locale from 'element-ui/lib/locale/lang/en';
import VueSimplemde from 'vue-simplemde';
Vue.use(ElementUI, { locale });
Vue.use(DataTables, { locale });
Vue.use(VueI18n);
Vue.use(VueRouter);
Vue.use(require('vue-shortkey'), { prevent: ['input', 'textarea'] });
Vue.use(VueEvents);
Vue.use(VueSimplemde);
require('./mixins');
......@@ -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('SingleMedia', require('../../../Modules/Media/Assets/js/components/SingleMedia.vue'));
Vue.component('MediaManager', require('../../../Modules/Media/Assets/js/components/MediaManager.vue'));
import PageRoutes from '../../../Modules/Page/Assets/js/PageRoutes';
import MediaRoutes from '../../../Modules/Media/Assets/js/MediaRoutes';
const currentLocale = window.AsgardCMS.currentLocale;
const currentLocale = window.AsgardCMS.currentLocale;
const adminPrefix = window.AsgardCMS.adminPrefix;
const router = new VueRouter({
mode: 'history',
base: makeBaseUrl(),
routes : [
...PageRoutes,
...MediaRoutes,
],
mode: 'history',
base: makeBaseUrl(),
routes: [
...PageRoutes,
...MediaRoutes,
],
});
function makeBaseUrl() {
if (window.AsgardCMS.hideDefaultLocaleInURL == 1) {
return adminPrefix;
}
return `${currentLocale}/${adminPrefix}`;
if (window.AsgardCMS.hideDefaultLocaleInURL == 1) {
return adminPrefix;
}
return `${currentLocale}/${adminPrefix}`;
}
let messages = {
[currentLocale]: window.AsgardCMS.translations,
const messages = {
[currentLocale]: window.AsgardCMS.translations,
};
const i18n = new VueI18n({
locale: currentLocale,
messages,
locale: currentLocale,
messages,
});
const app = new Vue({
el: '#app',
router,
i18n,
el: '#app',
router,
i18n,
});
window.axios.interceptors.response.use(null, function(error) {
if (error.response === undefined) {
console.log(error);
return;
}
if (error.response.status === 403) {
app.$notify.error({
title: app.$t('core.unauthorized'),
message: app.$t('core.unauthorized-access'),
});
window.location = route('dashboard.index');
}
if (error.response.status === 401) {
app.$notify.error({
title: app.$t('core.unauthenticated'),
message: app.$t('core.unauthenticated-message'),
});
window.location = route('login');
}
return Promise.reject(error);
window.axios.interceptors.response.use(null, (error) => {
if (error.response === undefined) {
console.log(error);
return;
}
if (error.response.status === 403) {
app.$notify.error({
title: app.$t('core.unauthorized'),
message: app.$t('core.unauthorized-access'),
});
window.location = route('dashboard.index');
}
if (error.response.status === 401) {
app.$notify.error({
title: app.$t('core.unauthenticated'),
message: app.$t('core.unauthenticated-message'),
});
window.location = route('login');
}
return Promise.reject(error);
});
......@@ -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.
*/
let token = document.head.querySelector('meta[name="csrf-token"]');
const token = document.head.querySelector('meta[name="csrf-token"]');
if (token) {
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
} 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) {
window.axios.defaults.headers.common['Authorization'] = 'Bearer ' + userApiToken.content;
window.axios.defaults.headers.common.Authorization = `Bearer ${userApiToken.content}`;
} 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) {
window.AsgardCMS.currentLocale = currentLocale.content;
window.AsgardCMS.currentLocale = currentLocale.content;
} 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 TranslationHelper from '../../../Modules/Core/Assets/js/mixins/TranslationHelper'
import Vue from 'vue';
import TranslationHelper from '../../../Modules/Core/Assets/js/mixins/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