OfficeApp/store/modules/config.js
weipengfei f1d1f2a76c 更新
2023-08-30 11:19:26 +08:00

37 lines
795 B
JavaScript

import Cache from '@/utils/cache';
import { getConfig } from "@/api/config.js";
const state = {
eyeType: Cache.get('eyeType') || true, // 小眼睛
request: Cache.get('request') || true, // 网络请求
config: JSON.parse(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', JSON.stringify(state.config));
}
};
const actions = {
async initConfig({ state, commit }) {
let res = await getConfig();
commit('SET_CONFIG', res.data);
}
};
export default {
state,
mutations,
actions
};