mirror of
https://github.com/Lissy93/dashy.git
synced 2026-01-25 09:11:48 +01:00
👷 App.vue and router.js references the new Class structure of Accumalator
This commit is contained in:
parent
3dafc41933
commit
b4e2c42bda
2 changed files with 57 additions and 19 deletions
14
src/App.vue
14
src/App.vue
|
|
@ -11,8 +11,10 @@
|
|||
import Header from '@/components/PageStrcture/Header.vue';
|
||||
import Footer from '@/components/PageStrcture/Footer.vue';
|
||||
import LoadingScreen from '@/components/PageStrcture/LoadingScreen.vue';
|
||||
import Defaults, { localStorageKeys, splashScreenTime } from '@/utils/defaults';
|
||||
import { config, appConfig, pageInfo } from '@/utils/ConfigAccumalator';
|
||||
import { localStorageKeys, splashScreenTime, visibleComponents } from '@/utils/defaults';
|
||||
import ConfigAccumulator from '@/utils/ConfigAccumalator';
|
||||
|
||||
const Accumulator = new ConfigAccumulator();
|
||||
|
||||
export default {
|
||||
name: 'app',
|
||||
|
|
@ -22,14 +24,14 @@ export default {
|
|||
LoadingScreen,
|
||||
},
|
||||
provide: {
|
||||
config,
|
||||
config: Accumulator.config(),
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
showFooter: Defaults.visibleComponents.footer,
|
||||
showFooter: visibleComponents.footer,
|
||||
isLoading: true,
|
||||
appConfig,
|
||||
pageInfo,
|
||||
appConfig: Accumulator.appConfig(),
|
||||
pageInfo: Accumulator.pageInfo(),
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
|
|
|
|||
|
|
@ -6,13 +6,51 @@ import Login from '@/views/Login.vue';
|
|||
import Workspace from '@/views/Workspace.vue';
|
||||
import DownloadConfig from '@/views/DownloadConfig.vue';
|
||||
import { isLoggedIn } from '@/utils/Auth';
|
||||
import { appConfig, pageInfo, sections } from '@/utils/ConfigAccumalator';
|
||||
import ConfigAccumulator from '@/utils/ConfigAccumalator';
|
||||
import { metaTagData } from '@/utils/defaults';
|
||||
|
||||
Vue.use(Router);
|
||||
|
||||
const Accumulator = new ConfigAccumulator();
|
||||
const config = {
|
||||
appConfig: Accumulator.appConfig(),
|
||||
pageInfo: Accumulator.pageInfo(),
|
||||
sections: Accumulator.sections(),
|
||||
};
|
||||
|
||||
const capitalize = (s) => {
|
||||
if (typeof s !== 'string') return '';
|
||||
return s.charAt(0).toUpperCase() + s.slice(1);
|
||||
};
|
||||
|
||||
/* Create routes for any additional config files */
|
||||
const makeRoutesForAdditionalPages = () => {
|
||||
const additionalPages = config.appConfig.additionalConfigFiles || [];
|
||||
const additionalRoutes = [];
|
||||
// For each additional page, create a route
|
||||
additionalPages.forEach((additionalConfig) => {
|
||||
const additionalAccumulator = new ConfigAccumulator(additionalConfig);
|
||||
const routeName = additionalConfig.split('.')[0];
|
||||
additionalRoutes.push({
|
||||
path: `/home/${routeName}`,
|
||||
name: `home-${routeName}`,
|
||||
component: Home,
|
||||
props: {
|
||||
appConfig: additionalAccumulator.appConfig(),
|
||||
pageInfo: additionalAccumulator.pageInfo(),
|
||||
sections: additionalAccumulator.sections(),
|
||||
},
|
||||
meta: {
|
||||
title: capitalize(routeName) || 'Home Page',
|
||||
metaTags: metaTagData,
|
||||
},
|
||||
});
|
||||
});
|
||||
return additionalRoutes;
|
||||
};
|
||||
|
||||
const isAuthenticated = () => {
|
||||
const users = appConfig.auth;
|
||||
const users = config.appConfig.auth;
|
||||
return (!users || isLoggedIn(users));
|
||||
};
|
||||
|
||||
|
|
@ -21,14 +59,11 @@ const router = new Router({
|
|||
{
|
||||
path: '/',
|
||||
name: 'home',
|
||||
alias: '/home',
|
||||
component: Home,
|
||||
props: {
|
||||
appConfig,
|
||||
pageInfo,
|
||||
sections,
|
||||
},
|
||||
props: config,
|
||||
meta: {
|
||||
title: pageInfo.title || 'Home Page',
|
||||
title: config.pageInfo.title || 'Home Page',
|
||||
metaTags: metaTagData,
|
||||
},
|
||||
},
|
||||
|
|
@ -36,9 +71,9 @@ const router = new Router({
|
|||
path: '/workspace',
|
||||
name: 'workspace',
|
||||
component: Workspace,
|
||||
props: { appConfig, pageInfo, sections },
|
||||
props: config,
|
||||
meta: {
|
||||
title: pageInfo.title || 'Dashy Workspace',
|
||||
title: config.pageInfo.title || 'Dashy Workspace',
|
||||
metaTags: metaTagData,
|
||||
},
|
||||
},
|
||||
|
|
@ -47,7 +82,7 @@ const router = new Router({
|
|||
name: 'login',
|
||||
component: Login,
|
||||
props: {
|
||||
appConfig,
|
||||
appConfig: config.appConfig,
|
||||
},
|
||||
beforeEnter: (to, from, next) => {
|
||||
if (isAuthenticated()) router.push({ path: '/' });
|
||||
|
|
@ -63,12 +98,13 @@ const router = new Router({
|
|||
path: '/download',
|
||||
name: 'download',
|
||||
component: DownloadConfig,
|
||||
props: { appConfig, pageInfo, sections },
|
||||
props: config,
|
||||
meta: {
|
||||
title: pageInfo.title || 'Download Dashy Config',
|
||||
title: config.pageInfo.title || 'Download Dashy Config',
|
||||
metaTags: metaTagData,
|
||||
},
|
||||
},
|
||||
...makeRoutesForAdditionalPages(),
|
||||
],
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue