mirror of
https://github.com/dborth/vbagx.git
synced 2024-11-25 20:16:53 +01:00
Replace object to string on change theme
This commit is contained in:
parent
f3057ca59b
commit
6971466c39
@ -13,8 +13,7 @@ import themes from './js/stores/theme.js';
|
|||||||
export default (props, { $f7, $, $update, $onMounted }) => {
|
export default (props, { $f7, $, $update, $onMounted }) => {
|
||||||
|
|
||||||
$onMounted(async () => {
|
$onMounted(async () => {
|
||||||
const selector = '#app';
|
await themes.dispatch('initTheme', '#app');
|
||||||
await themes.dispatch('initTheme', { selector });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return $render;
|
return $render;
|
||||||
|
@ -7,18 +7,20 @@ const theme = createStore({
|
|||||||
name: 'theme-dark',
|
name: 'theme-dark',
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
|
//Mutations
|
||||||
changeTheme({ state }, name) {
|
changeTheme({ state }, name) {
|
||||||
state.name = name;
|
state.name = name;
|
||||||
},
|
},
|
||||||
async checkTheme({ state, dispatch }, { selector }){
|
//End mutations
|
||||||
|
async checkTheme({ state, dispatch }, selector){
|
||||||
let theme = await localForage.getItem('theme');
|
let theme = await localForage.getItem('theme');
|
||||||
if (theme != 'theme-dark'){ $(selector).removeClass('theme-dark'); }
|
if (theme != 'theme-dark'){ $(selector).removeClass('theme-dark'); }
|
||||||
dispatch('changeTheme', theme);
|
dispatch('changeTheme', theme);
|
||||||
},
|
},
|
||||||
async initTheme({state, dispatch}, { selector }){
|
async initTheme({state, dispatch}, selector){
|
||||||
let items = await localForage.length();
|
let items = await localForage.length();
|
||||||
if (items > 0){
|
if (items > 0){
|
||||||
await dispatch('checkTheme', { selector });
|
await dispatch('checkTheme', selector);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async setTheme({ state, dispatch }, name){
|
async setTheme({ state, dispatch }, name){
|
||||||
|
@ -140,8 +140,7 @@ export default (props, { $f7, $, $onMounted, $update, }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
$onMounted(async () => {
|
$onMounted(async () => {
|
||||||
const selector = '.panel-left';
|
await themes.dispatch('checkTheme', '.panel-left');
|
||||||
await themes.dispatch('checkTheme', { selector });
|
|
||||||
|
|
||||||
if (isLogged){
|
if (isLogged){
|
||||||
isCustomer = userRoles.includes(4); //Customer,
|
isCustomer = userRoles.includes(4); //Customer,
|
||||||
|
@ -74,8 +74,7 @@ export default (props, { $f7, $, $on, $onMounted, $update, $f7router }) => {
|
|||||||
|
|
||||||
$onMounted(async () => {
|
$onMounted(async () => {
|
||||||
$('#light-theme').prop('checked', (theme != 'theme-dark') ? true : false );
|
$('#light-theme').prop('checked', (theme != 'theme-dark') ? true : false );
|
||||||
const selector = '.panel-right'
|
await themes.dispatch('checkTheme', '.panel-right');
|
||||||
await themes.dispatch('checkTheme', { selector });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const logout = () => {
|
const logout = () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user