export const setUser = (state, payload) => {
  state.user = payload;
  // let res = true;
  // //登陆时
  // if (payload) {
  //   state.token = payload;
  // } else {
  //   //已经登陆,切换路由时取出客户信息放在总store中
  //   let token = localStorage.getItem('token');
  //   if (token && token !== 'guest') {
  //     state.user = jwt.decode(token);
  //   } else if (token && token == 'guest') {
  //     let user = localStorage.getItem('user');
  //     state.user = JSON.parse(user);
  //   } else {
  //     let timestamp = new Date().getTime();
  //     let user = {
  //       // id: `guest${timestamp}`,
  //       name: `游客${timestamp}`,
  //     };
  //     state.user = user;
  //     localStorage.setItem('token', 'guest');
  //     localStorage.setItem('user', JSON.stringify(user));
  //     console.warn('游客身份');
  //   }
  // }
  // return res;
};

export const deleteUser = (state, payload) => {
  state.user = {};
  state.menuList = [];
  state.isLoadMenu = false;
  sessionStorage.removeItem('token');
};

export const addMenu = (state, payload) => {
  state.menuList = payload;
  state.isLoadMenu = true;
};
