import AuthDao from "@/dao/auth";

const user = {
  state: {
    menu: []
  },
  actions: {
    // 登录
    async QUERY_MENU({ state }) {
      const parentId = map_config.SYS_ID;
      const resp = await AuthDao.queryMenu({
        params: {
          parentId,
          isRecursion: true
        }
      });
      const {
        data: { status, content, message }
      } = resp;
      if (status === "success") {
        state.menu = content;
        state.menu.forEach(v => {
          if (v.parentId === parentId) {
            v.parentId = null;
          }
        });
      }
    }
  }
};
export default user;
