43 lines
989 B
JavaScript
43 lines
989 B
JavaScript
import Vue from "vue";
|
|
import Vuex from "vuex";
|
|
import createPersistedState from "vuex-persistedstate";
|
|
|
|
Vue.use(Vuex);
|
|
|
|
export default new Vuex.Store({
|
|
plugins: [createPersistedState()],
|
|
state: {
|
|
authenticated: false,
|
|
apiUrl: "http://localhost:7575/api/v8.0/",
|
|
apiToken: "NOT-AUTHENTICATED",
|
|
userId: 0,
|
|
roles: 0,
|
|
localeText: {},
|
|
navItems: []
|
|
},
|
|
mutations: {
|
|
login(state, data) {
|
|
// mutate state
|
|
state.authenticated = data.authenticated;
|
|
state.userId = data.userId;
|
|
state.roles = data.roles;
|
|
state.apiToken = data.apiToken;
|
|
},
|
|
logout(state) {
|
|
state.apiToken = "NOT-AUTHENTICATED";
|
|
state.authenticated = false;
|
|
state.userId = 0;
|
|
state.roles = 0;
|
|
state.navItems = [];
|
|
state.localeText = {};
|
|
},
|
|
addNavItem(state, data) {
|
|
state.navItems.push(data);
|
|
},
|
|
addLocaleText(state, data) {
|
|
state.localeText[data.key] = data.value;
|
|
}
|
|
},
|
|
actions: {}
|
|
});
|