const storageSetting = JSON.parse(localStorage.getItem("layout-setting")) || "";
const state = {
  title: "",
  theme: storageSetting.theme || "#409EFF",
  loading: false,
};
const mutations = {
  CHANGE_SETTING: (state, { key, value }) => {
    if (state.hasOwnProperty(key)) {
      state[key] = value;
    }
  },
  changeLoading(state, { key, value }) {
    state.loading = value;
  },
};

const actions = {
  // 修改布局设置
  changeSetting({ commit }, data) {
    commit("CHANGE_SETTING", data);
  },

  // 设置网页标题
  setTitle({ commit }, title) {
    state.title = title;
  },
};

export default {
  namespaced: true,
  state,
  mutations,
  actions,
};
