/*
 * @Author: yufan 56580223@qq.com
 * @Date: 2022-07-01 10:09:31
 * @LastEditors: yufan 56580223@qq.com
 * @LastEditTime: 2022-09-20 10:42:31
 * @FilePath: /book_pc/src/store/mutations.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
/** 一个封装常规 mutation 操作的常规方法  */
import Cookies from 'js-cookie';
import { setStore } from '@/utils/store';
export default {
  __set(state: any, msg: { key: string; val: any }) {
    state[msg.key] = msg.val;
  },
  // 设置 TOKEN
  SET_TOKEN(state, { tokenKey, token }) {
    Cookies.set(tokenKey, '1');
    const tokenCache = state.user.token;
    tokenCache[tokenKey] = token;
    state.token = tokenCache;
    setStore({ name: 'token', content: tokenCache });
  },
};
