const jwt = require('jsonwebtoken');
export const setUser = (state, payload) => {
  let res = true;
  // 登陆时;
  if (payload) {
    state.user = payload;
  } else {
    //已经登陆,切换路由时取出用户信息放在总store中
    let token = sessionStorage.getItem('token');
    if (token) {
      state.user = jwt.decode(token);
    }
  }
  return res;
};
export const deleteUser = (state, payload) => {
  state.user = {};
  localStorage.removeItem('user');
};
