import cache from "@/utils/cache";

export default {
  state: () => ({
    detailQuery: cache.session.getJSON("detailQuery") || {}
  }),
  mutations: {
    ADD_QUERY: (state: any, query: any) => {
      state.detailQuery[query.path] = query.query;
      cache.session.setJSON("detailQuery", state.detailQuery);
    },
    DEL_QUERY: (state: any, path: string) => {
      delete state.detailQuery[path];
      cache.session.setJSON("detailQuery", state.detailQuery);
    },
    DEL_ALL_QUERY: (state: any) => {
      state.detailQuery = {};
      cache.session.setJSON("detailQuery", state.detailQuery);
    },
    DEL_OTHER_QUERY: (state: any, path: string) => {
      state.detailQuery = {
        [path]: state.detailQuery[path]
      };
      cache.session.setJSON("detailQuery", state.detailQuery);
    }
  }
};
