import Cache from '@/utils/cache'; import { getConfig } from "@/api/config.js"; const state = { eyeType: Cache.get('eyeType') || true, // 小眼睛 request: Cache.get('request') || true, // 网络请求 config: Cache.get('config') || {} }; const mutations = { SET_EYE_TYPE(state){ state.eyeType=!state.eyeType; Cache.set('eyeType', state.eyeType); }, SET_REQUEST(state, data=true){ state.request = data; Cache.set('request', state.request); }, SET_CONFIG(state, data){ state.config = {...data}; Cache.set('config', state.config); } }; const actions = { async initConfig({ state, commit }) { let res = await getConfig(); commit('SET_CONFIG', res.data); } }; export default { state, mutations, actions };