dashy/src/App.vue

100 lines
2.5 KiB
Vue
Raw Normal View History

2019-07-19 16:07:26 +02:00
<template>
<div id="dashy" data-theme="dark">
<Header :pageInfo="pageInfo" />
<router-view />
<Footer v-if="showFooter" :text="getFooterText()" />
2019-07-19 16:07:26 +02:00
</div>
</template>
2019-07-20 22:50:29 +02:00
<script>
2021-04-13 13:36:31 +02:00
import Header from '@/components/PageStrcture/Header.vue';
import Footer from '@/components/PageStrcture/Footer.vue';
import Defaults, { localStorageKeys } from '@/utils/defaults';
import conf from '../public/conf.yml';
2019-07-20 22:50:29 +02:00
export default {
name: 'app',
components: {
Header,
2019-09-01 14:38:13 +02:00
Footer,
},
data: () => ({
// pageInfo: this.getPageInfo(conf.pageInfo),
showFooter: Defaults.visibleComponents.footer,
}),
computed: {
2021-05-31 16:17:54 +02:00
pageInfo() {
return this.getPageInfo(conf.pageInfo);
},
appConfig() {
if (localStorage[localStorageKeys.APP_CONFIG]) {
return JSON.parse(localStorage[localStorageKeys.APP_CONFIG]);
} else if (conf.appConfig) {
return conf.appConfig;
} else {
return Defaults.appConfig;
}
},
},
methods: {
/* Returns either page info from the config, or default values */
getPageInfo(pageInfo) {
2021-04-16 16:36:30 +02:00
const defaults = Defaults.pageInfo;
let localPageInfo;
try {
localPageInfo = JSON.parse(localStorage[localStorageKeys.PAGE_INFO]);
} catch (e) {
localPageInfo = {};
}
if (pageInfo) {
return {
title: localPageInfo.title || pageInfo.title || defaults.title,
description: localPageInfo.description || pageInfo.description || defaults.description,
navLinks: localPageInfo.navLinks || pageInfo.navLinks || defaults.navLinks,
footerText: localPageInfo.footerText || pageInfo.footerText || defaults.footerText,
};
}
return defaults;
},
getFooterText() {
if (this.pageInfo && this.pageInfo.footerText) {
return this.pageInfo.footerText;
}
return '';
},
2021-05-31 16:17:54 +02:00
injectCustomStyles(usersCss) {
const style = document.createElement('style');
style.textContent = usersCss;
document.head.append(style);
},
},
mounted() {
if (this.appConfig.customCss) {
const cleanedCss = this.appConfig.customCss.replace(/<\/?[^>]+(>|$)/g, '');
this.injectCustomStyles(cleanedCss);
}
},
2019-09-01 14:38:13 +02:00
};
2019-07-20 22:50:29 +02:00
</script>
2019-07-19 16:07:26 +02:00
<style lang="scss">
2021-04-15 20:30:30 +02:00
@import '@/styles/global-styles.scss';
@import '@/styles/color-palette.scss';
@import '@/styles/color-themes.scss';
@import '@/styles/typography.scss';
2019-07-20 22:50:29 +02:00
body {
background: var(--background);
margin: 0;
padding: 0;
}
2019-07-19 16:07:26 +02:00
#app {
2019-07-20 22:50:29 +02:00
.footer {
text-align: center;
2019-07-19 16:07:26 +02:00
}
}
2019-07-20 22:50:29 +02:00
2019-07-19 16:07:26 +02:00
</style>