import Vue from 'vue' import Vuex from 'vuex' import actions from './actions.js' Vue.use(Vuex) export default new Vuex.Store({ // state: 存储基本数据 state: { user: { headimg: "../../static/dan.png", name: "季总蛋先生", weight: 68, age: 26, height: 178, sex: 1, id: "", mage: "", iszan: false, zan: 0 }, isedit: false, isLogout: true, isConnected: false, isBluetoothTyle: false, }, // mutations: Store中更改state数据状态的唯一方法(必须是同步函数) mutations: { /* 用户信息 */ changePetInfo(state, newData) { state.user = newData }, // 手动添加 changeEdit(state, newData) { state.isedit = newData }, //蓝牙状态 changeBluetooth(state, newData) { state.isBluetoothTyle = newData }, // 蓝牙连接状态 changeConnected(state, newData) { state.isConnected = newData }, // 退出登录 changeLogout(state, newData) { if (newData == false) { state.user = { headimg: null, name: "", weight: 0, birthday: "", height: 0, sex: 0, id: "", mage: "", iszan: false, zan: 0 } } state.isLogout = newData }, }, // 模块化vuex modules: {}, actions })