import Vue from 'vue' import Vuex from 'vuex' import actions from './actions.js' Vue.use(Vuex) export default new Vuex.Store({ // state: 存储基本数据 state: { user: { age: "1", aud_id: "", email: "", gender: "", head_pic: "", height: 0, is_use_set_kcal: "", nickname: "", set_kcal: "", tel: "", token: "", weight: 0, birthday: "" }, // 配置 configInfo: { banner_data: [], search_guess: { cookbook: [], food_data: [] }, search_history: { cookbook: [], food: [] }, business_cooperation: {} }, // 计食器 countFoodInfo: { date: "", home_food_count: {}, list: [], remaining_kcal: "", suggestion: { kcal: "", carbohydrate: "", protein: "", fat: "" }, today_intake: {} }, isConnected: false, isBluetoothTyle: false, }, // mutations: Store中更改state数据状态的唯一方法(必须是同步函数) mutations: { /* 用户信息 */ changeUserInfo(state, newData) { state.user = newData }, //蓝牙状态 changeBluetooth(state, newData) { state.isBluetoothTyle = newData }, // 蓝牙连接状态 changeConnected(state, newData) { state.isConnected = newData }, changeConfig(state, newData) { state.configInfo = newData }, // 计食器 changeCountFoodInfo(state, newData) { state.countFoodInfo = newData }, }, // 模块化vuex modules: {}, actions })