mirror of
https://github.com/dborth/vbagx.git
synced 2024-11-26 04:24:16 +01:00
-Min refactor
-Fix unauth access -not tested -Fix initial them setting
This commit is contained in:
parent
a3bef880a0
commit
68d3b0fcc3
@ -15,12 +15,13 @@ export default (props, { $f7, $, $update, $onMounted }) => {
|
||||
|
||||
let theme = themes.getters.Name.value;
|
||||
|
||||
$onMounted(() => {
|
||||
localForage.getItem('theme').then( (value) => {
|
||||
theme = value;
|
||||
if (value != 'theme-dark'){ $("#app").removeClass("theme-dark"); }
|
||||
$onMounted(async () => {
|
||||
const items = await localForage.length();
|
||||
if (items > 0){
|
||||
theme = await localForage.getItem('theme');
|
||||
if (theme != 'theme-dark'){ $("#app").removeClass("theme-dark"); }
|
||||
themes.dispatch('changeTheme', theme);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return $render;
|
||||
|
@ -19,6 +19,9 @@ import http from './api/config.js';
|
||||
// Import main app component
|
||||
import App from '../app.f7.html';
|
||||
|
||||
// Import user store
|
||||
import user from './stores/user.js';
|
||||
|
||||
var device = getDevice();
|
||||
var app = new Framework7({
|
||||
name: 'Comida Cab', // App name
|
||||
@ -69,7 +72,7 @@ var app = new Framework7({
|
||||
http.interceptors.response.use(undefined, function (err) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
if (err.status === 401 && err.config && !err.config.__isRetryRequest) {
|
||||
//user.dispatch('logout'); //To fix
|
||||
user.dispatch('logOut').then( () => { } ); //Untested
|
||||
}
|
||||
throw err;
|
||||
});
|
||||
|
@ -32,8 +32,8 @@ const user = createStore({
|
||||
logOut({ state, dispatch }){
|
||||
return new Promise((resolve, reject) => {
|
||||
dispatch('logout');
|
||||
localStorage.removeItem('token')
|
||||
http.defaults.headers.common['Authorization'];
|
||||
localStorage.removeItem('token');
|
||||
delete http.defaults.headers.common['Authorization'];
|
||||
resolve();
|
||||
});
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user