import { createStore } from 'vuex';

export default createStore({
  state: {
    isAuthenticated: JSON.parse(localStorage.getItem('isAuthenticated')) || false,
  },
  mutations: {
    setAuthenticated(state, value) {
      state.isAuthenticated = value;
      localStorage.setItem('isAuthenticated', JSON.stringify(value));
    },
  },
  actions: {
    login({ commit }, credentials) {
      // 在这里进行登录请求，并在成功后设置认证状态
      // 例如，假设登录成功：
      commit('setAuthenticated', true);
    },
    logout({ commit }) {
      commit('setAuthenticated', false);
    },
  },
  modules: {},
});
