mirror of
https://github.com/Lissy93/dashy.git
synced 2024-12-29 20:11:53 +03:00
🔥 Implements lazy loading for alternate views
This commit is contained in:
parent
1bc978b704
commit
28ff522a61
@ -11,9 +11,6 @@ import ProgressBar from 'rsup-progress';
|
|||||||
|
|
||||||
// Import views, that are not lazy-loaded
|
// Import views, that are not lazy-loaded
|
||||||
import Home from '@/views/Home.vue';
|
import Home from '@/views/Home.vue';
|
||||||
import Login from '@/views/Login.vue';
|
|
||||||
import Workspace from '@/views/Workspace.vue';
|
|
||||||
import Minimal from '@/views/Minimal.vue';
|
|
||||||
import ConfigAccumulator from '@/utils/ConfigAccumalator';
|
import ConfigAccumulator from '@/utils/ConfigAccumalator';
|
||||||
|
|
||||||
// Import helper functions, config data and defaults
|
// Import helper functions, config data and defaults
|
||||||
@ -52,9 +49,8 @@ const getStartingView = () => appConfig.startingView || startingView;
|
|||||||
const getStartingComponent = () => {
|
const getStartingComponent = () => {
|
||||||
const usersPreference = getStartingView();
|
const usersPreference = getStartingView();
|
||||||
switch (usersPreference) {
|
switch (usersPreference) {
|
||||||
case 'default': return Home;
|
case 'minimal': return () => import('./views/Minimal.vue');
|
||||||
case 'minimal': return Minimal;
|
case 'workspace': return () => import('./views/Workspace.vue');
|
||||||
case 'workspace': return Workspace;
|
|
||||||
default: return Home;
|
default: return Home;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -93,19 +89,19 @@ const router = new Router({
|
|||||||
{ // Workspace view page
|
{ // Workspace view page
|
||||||
path: routePaths.workspace,
|
path: routePaths.workspace,
|
||||||
name: 'workspace',
|
name: 'workspace',
|
||||||
component: Workspace,
|
component: () => import('./views/Workspace.vue'),
|
||||||
meta: makeMetaTags('Workspace'),
|
meta: makeMetaTags('Workspace'),
|
||||||
},
|
},
|
||||||
{ // Minimal view page
|
{ // Minimal view page
|
||||||
path: routePaths.minimal,
|
path: routePaths.minimal,
|
||||||
name: 'minimal',
|
name: 'minimal',
|
||||||
component: Minimal,
|
component: () => import('./views/Minimal.vue'),
|
||||||
meta: makeMetaTags('Start Page'),
|
meta: makeMetaTags('Start Page'),
|
||||||
},
|
},
|
||||||
{ // The login page
|
{ // The login page
|
||||||
path: routePaths.login,
|
path: routePaths.login,
|
||||||
name: 'login',
|
name: 'login',
|
||||||
component: Login,
|
component: () => import('./views/Login.vue'),
|
||||||
beforeEnter: (to, from, next) => {
|
beforeEnter: (to, from, next) => {
|
||||||
// If the user already logged in + guest mode not enabled, then redirect home
|
// If the user already logged in + guest mode not enabled, then redirect home
|
||||||
if (isAuthenticated() && !isGuestAccessEnabled()) router.push({ path: '/' });
|
if (isAuthenticated() && !isGuestAccessEnabled()) router.push({ path: '/' });
|
||||||
|
Loading…
Reference in New Issue
Block a user