37 lines
795 B
JavaScript
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
|
|
};
|