Untitled

 avatar
unknown
plain_text
a month ago
635 B
3
Indexable
import { createStore } from "vuex";
import authModule from "./modules/auth"; // Importă modulul de autentificare

const store = createStore({
  modules: {
    auth: authModule, // Adaugă modulul de autentificare
  },
});

// Reîncarcă starea din localStorage (dacă este cazul)
if (localStorage.getItem("state")) {
  const state = JSON.parse(localStorage.getItem("state"));
  store.replaceState(Object.assign(store.state, state));
}

// Ascultă modificările în store pentru a salva starea în localStorage
store.subscribe((mutation, state) => {
  localStorage.setItem("state", JSON.stringify(state));
});

export default store;
Leave a Comment