zhangxiaoxu123456
2022-04-14 626cabe8772d16c02584c8b324dd7c45e23002a6
src/store/modules/user.js
@@ -1,42 +1,31 @@
/**
 * 用户登录组件
 */
import {login} from '@/api/index'
import {getStore,setStore} from "../../libs/store";
const user = {
    state: {
        menus: [
            {
                icon: "sound",
                index: "/index",
                title: "视频管理",
                subs: [
                    {
                        icon: "area-chart",
                        index: "index",
                        title: "Dashboard",
                    },
                ],
            },
            {
                icon: "setting",
                index: "/wechat",
                title: "系统",
                subs: [
                    {
                        icon: "setting",
                        index: "admin_user",
                        title: "帐号管理",
                    },
                ],
            }
        ]
      token: getStore('token') || {}
    },
    mutations: {
        SET_MENUS: (state, action) => {
            // state.menus = !state.isCollapse
        },
      SET_TOKEN: (state, token) => {
        state.token = token
      }
    },
    actions: {
      login({commit}, userInfo) {
         return new Promise((resolve, reject) => {
           login(userInfo).then(response => {
             console.log('response----',response)
             commit('SET_TOKEN',response.obj.token)
             resolve()
           }).catch(error => {
             reject(error)
           })
         })
      }
    }
}
export default user;