Changeset View
Changeset View
Standalone View
Standalone View
src/resources/js/app.js
/** | /** | ||||
* First we will load all of this project's JavaScript dependencies which | * First we will load all of this project's JavaScript dependencies which | ||||
* includes Vue and other libraries. It is a great starting point when | * includes Vue and other libraries. It is a great starting point when | ||||
* building robust, powerful web applications using Vue and Laravel. | * building robust, powerful web applications using Vue and Laravel. | ||||
*/ | */ | ||||
require('./bootstrap') | require('./bootstrap') | ||||
import AppComponent from '../vue/App' | import AppComponent from '../vue/App' | ||||
import MenuComponent from '../vue/Widgets/Menu' | import MenuComponent from '../vue/Widgets/Menu' | ||||
import SupportForm from '../vue/Widgets/SupportForm' | import SupportForm from '../vue/Widgets/SupportForm' | ||||
import store from './store' | import store from './store' | ||||
import { loadLanguageAsync, i18n } from './locale' | |||||
const loader = '<div class="app-loader"><div class="spinner-border" role="status"><span class="sr-only">Loading</span></div></div>' | const loader = '<div class="app-loader"><div class="spinner-border" role="status"><span class="sr-only">Loading</span></div></div>' | ||||
let isLoading = 0 | let isLoading = 0 | ||||
// Lock the UI with the 'loading...' element | // Lock the UI with the 'loading...' element | ||||
const startLoading = () => { | const startLoading = () => { | ||||
isLoading++ | isLoading++ | ||||
Show All 27 Lines | if (to.matched.some(route => route.meta.requiresAuth) && !store.state.isLoggedIn) { | ||||
return | return | ||||
} | } | ||||
if (to.meta.loading) { | if (to.meta.loading) { | ||||
startLoading() | startLoading() | ||||
loadingRoute = to.name | loadingRoute = to.name | ||||
} | } | ||||
next() | loadLanguageAsync().then(() => next()) | ||||
}) | }) | ||||
window.router.afterEach((to, from) => { | window.router.afterEach((to, from) => { | ||||
if (to.name && loadingRoute === to.name) { | if (to.name && loadingRoute === to.name) { | ||||
stopLoading() | stopLoading() | ||||
loadingRoute = null | loadingRoute = null | ||||
} | } | ||||
// When changing a page remove old: | // When changing a page remove old: | ||||
// - error page | // - error page | ||||
// - modal backdrop | // - modal backdrop | ||||
$('#error-page,.modal-backdrop.show').remove() | $('#error-page,.modal-backdrop.show').remove() | ||||
}) | }) | ||||
const app = new Vue({ | const app = new Vue({ | ||||
el: '#app', | el: '#app', | ||||
components: { | components: { | ||||
AppComponent, | AppComponent, | ||||
MenuComponent, | MenuComponent, | ||||
}, | }, | ||||
i18n, | |||||
store, | store, | ||||
router: window.router, | router: window.router, | ||||
data() { | data() { | ||||
return { | return { | ||||
isAdmin: window.isAdmin, | isAdmin: window.isAdmin, | ||||
appName: window.config['app.name'], | appName: window.config['app.name'], | ||||
appUrl: window.config['app.url'], | appUrl: window.config['app.url'], | ||||
themeDir: '/themes/' + window.config['app.theme'] | themeDir: '/themes/' + window.config['app.theme'] | ||||
▲ Show 20 Lines • Show All 393 Lines • Show Last 20 Lines |