import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex);

export default new Vuex.Store({
    state: {
        eqSn: "",
        remoteVersion: "",
        localVersion: "",
        // headapi: "",        
        wsUrl: "",
        shopName: "",
        bleState: false,    // BLE状态 false：关闭 true：开启
        bleDiscovery: false,// BLE设备搜索状态 false：关闭 true：开启
        wsState: false,     // webSocket状态 false：关闭 true：开启
        classOn: 0,         // 上课状态 0: 下课 1：团课/私教 2：竞技课2PK 3：竞技课3pk
        curTime: "",
        curDay: "",
        curWeek: "",
    },
    mutations: {
        setEqSn(state, eqSn) {
            state.eqSn = eqSn;
            console.log("[setEqSn] state.eqSn = " + eqSn);
        },
        setRemoteVersion(state, remoteVersion) {
            state.remoteVersion = remoteVersion;
            console.log("[setRemoteVersion] state.remoteVersion = " + remoteVersion);
        },
        setLocalVersion(state, localVersion) {
            state.localVersion = localVersion;
            console.log("[setLocalVersion] state.localVersion = " + localVersion);
        },
        // setHeadapi(state, headapi) {
        //     state.headapi = headapi;
        //     console.log("[setHeadapi] state.headapi = " + headapi);
        // },
        setWsUrl(state, wsUrl) {
            state.wsUrl = wsUrl;
            console.log("[setWsUrl] state.wsUrl = " + wsUrl);
        },
        setShopName(state, shopName) {
            state.shopName = shopName;
            console.log("[setShopName] state.shopName = " + shopName);
        },
        setBleState(state, bleState) {
            state.bleState = bleState;
            console.log("[setBleState] state.bleState = " + bleState);
        },
        setBleDiscovery(state, bleDiscovery) {
            state.bleDiscovery = bleDiscovery;
            console.log("[setBleDiscovery] state.bleDiscovery = " + bleDiscovery);
        },
        setWsState(state, wsState) {
            state.wsState = wsState;
            console.log("[setWsState] state.wsState = " + wsState);
        },
        setClassOn(state, classOn) {
            if (state.classOn != classOn) {
                state.classOn = classOn;
                console.log("[setClassOn] state.classOn = " + classOn);
            }
        },
        setCurTime(state, curTime) {
            state.curTime = curTime;
            // console.log("[setCurTime] state.curTime = " + curTime);
        },
        setCurDay(state, curDay) {
            state.curDay = curDay;
            // console.log("[setCurDay] state.curDay = " + curDay);
        },
        setCurWeek(state, curWeek) {
            state.curWeek = curWeek;
            // console.log("[setCurWeek] state.curWeek = " + curWeek);
        },
    },
    actions: {
    },
    modules: {
    }
})
