mirror of
https://github.com/Lissy93/dashy.git
synced 2025-07-30 09:05:35 +02:00
⚡ Implements a very very basic config store
This commit is contained in:
parent
c2e70dc07e
commit
8a8166bb47
26
src/App.vue
26
src/App.vue
@ -11,7 +11,7 @@
|
|||||||
import Header from '@/components/PageStrcture/Header.vue';
|
import Header from '@/components/PageStrcture/Header.vue';
|
||||||
import Footer from '@/components/PageStrcture/Footer.vue';
|
import Footer from '@/components/PageStrcture/Footer.vue';
|
||||||
import LoadingScreen from '@/components/PageStrcture/LoadingScreen.vue';
|
import LoadingScreen from '@/components/PageStrcture/LoadingScreen.vue';
|
||||||
import { componentVisibility } from '@/utils/ConfigHelpers';
|
// import { componentVisibility } from '@/utils/ConfigHelpers';
|
||||||
import ConfigAccumulator from '@/utils/ConfigAccumalator';
|
import ConfigAccumulator from '@/utils/ConfigAccumalator';
|
||||||
import { welcomeMsg } from '@/utils/CoolConsole';
|
import { welcomeMsg } from '@/utils/CoolConsole';
|
||||||
import ErrorHandler from '@/utils/ErrorHandler';
|
import ErrorHandler from '@/utils/ErrorHandler';
|
||||||
@ -23,8 +23,9 @@ import {
|
|||||||
} from '@/utils/defaults';
|
} from '@/utils/defaults';
|
||||||
|
|
||||||
const Accumulator = new ConfigAccumulator();
|
const Accumulator = new ConfigAccumulator();
|
||||||
const config = Accumulator.config();
|
const config2 = Accumulator.config();
|
||||||
const visibleComponents = componentVisibility(config.appConfig) || defaultVisibleComponents;
|
// const visibleComponents = componentVisibility(config.appConfig) || defaultVisibleComponents;
|
||||||
|
const visibleComponents = defaultVisibleComponents;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'app',
|
name: 'app',
|
||||||
@ -34,15 +35,13 @@ export default {
|
|||||||
LoadingScreen,
|
LoadingScreen,
|
||||||
},
|
},
|
||||||
provide: {
|
provide: {
|
||||||
config,
|
config: config2,
|
||||||
visibleComponents,
|
visibleComponents,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
isLoading: true, // Set to false after mount complete
|
isLoading: true, // Set to false after mount complete
|
||||||
showFooter: visibleComponents.footer,
|
showFooter: visibleComponents.footer,
|
||||||
appConfig: Accumulator.appConfig(),
|
|
||||||
pageInfo: Accumulator.pageInfo(),
|
|
||||||
visibleComponents,
|
visibleComponents,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -55,6 +54,21 @@ export default {
|
|||||||
shouldShowSplash() {
|
shouldShowSplash() {
|
||||||
return (this.visibleComponents || defaultVisibleComponents).splashScreen;
|
return (this.visibleComponents || defaultVisibleComponents).splashScreen;
|
||||||
},
|
},
|
||||||
|
config() {
|
||||||
|
return this.$store.state.config;
|
||||||
|
},
|
||||||
|
appConfig() {
|
||||||
|
return this.$store.getters.appConfig;
|
||||||
|
},
|
||||||
|
pageInfo() {
|
||||||
|
return this.$store.getters.pageInfo;
|
||||||
|
},
|
||||||
|
sections() {
|
||||||
|
return this.$store.getters.pageInfo;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.$store.dispatch('initializeConfig');
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
/* Injects the users custom CSS as a style tag */
|
/* Injects the users custom CSS as a style tag */
|
||||||
|
33
src/store.js
33
src/store.js
@ -1,17 +1,44 @@
|
|||||||
|
/* eslint-disable no-param-reassign */
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import Vuex from 'vuex';
|
import Vuex from 'vuex';
|
||||||
|
import Keys from '@/utils/StoreMutations';
|
||||||
|
import ConfigAccumulator from '@/utils/ConfigAccumalator';
|
||||||
|
|
||||||
Vue.use(Vuex);
|
Vue.use(Vuex);
|
||||||
|
|
||||||
|
const { UPDATE_CONFIG } = Keys;
|
||||||
|
|
||||||
const store = new Vuex.Store({
|
const store = new Vuex.Store({
|
||||||
state: {
|
state: {
|
||||||
count: 0,
|
config: {},
|
||||||
|
},
|
||||||
|
getters: {
|
||||||
|
config(state) {
|
||||||
|
return state.config;
|
||||||
|
},
|
||||||
|
pageInfo(state) {
|
||||||
|
return state.config.pageInfo || {};
|
||||||
|
},
|
||||||
|
appConfig(state) {
|
||||||
|
return state.config.appConfig || {};
|
||||||
|
},
|
||||||
|
sections(state) {
|
||||||
|
return state.config.sections || [];
|
||||||
|
},
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
increment(state) {
|
[UPDATE_CONFIG](state, config) {
|
||||||
state.count++;
|
state.config = config;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
actions: {
|
||||||
|
initializeConfig({ commit }) {
|
||||||
|
const Accumulator = new ConfigAccumulator();
|
||||||
|
const config = Accumulator.config();
|
||||||
|
commit(UPDATE_CONFIG, config);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
modules: {},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default store;
|
export default store;
|
||||||
|
9
src/utils/StoreMutations.js
Normal file
9
src/utils/StoreMutations.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// A list of mutation names
|
||||||
|
const KEY_NAMES = [
|
||||||
|
'UPDATE_CONFIG',
|
||||||
|
];
|
||||||
|
|
||||||
|
// Convert array of key names into an object, and export
|
||||||
|
const MUTATIONS = {};
|
||||||
|
KEY_NAMES.forEach((key) => { MUTATIONS[key] = key; });
|
||||||
|
export default MUTATIONS;
|
Loading…
x
Reference in New Issue
Block a user