2023-07-21 15:35:53 +08:00
|
|
|
import Cache from '@/utils/cache';
|
2023-08-26 18:41:06 +08:00
|
|
|
import { getConfig } from "@/api/config.js";
|
|
|
|
|
2023-07-21 15:35:53 +08:00
|
|
|
const state = {
|
2023-08-11 13:51:58 +08:00
|
|
|
eyeType: Cache.get('eyeType') || true, // 小眼睛
|
|
|
|
request: Cache.get('request') || true, // 网络请求
|
2023-08-30 11:19:26 +08:00
|
|
|
config: JSON.parse(Cache.get('config')||'{}')
|
2023-07-21 15:35:53 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const mutations = {
|
|
|
|
SET_EYE_TYPE(state){
|
|
|
|
state.eyeType=!state.eyeType;
|
|
|
|
Cache.set('eyeType', state.eyeType);
|
2023-08-05 15:16:05 +08:00
|
|
|
},
|
|
|
|
SET_REQUEST(state, data=true){
|
|
|
|
state.request = data;
|
|
|
|
Cache.set('request', state.request);
|
2023-08-11 13:51:58 +08:00
|
|
|
},
|
2023-08-26 18:41:06 +08:00
|
|
|
SET_CONFIG(state, data){
|
2023-08-29 14:18:28 +08:00
|
|
|
state.config = {...data};
|
2023-08-30 11:19:26 +08:00
|
|
|
Cache.set('config', JSON.stringify(state.config));
|
2023-07-21 15:35:53 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const actions = {
|
2023-08-26 18:41:06 +08:00
|
|
|
async initConfig({ state, commit }) {
|
|
|
|
let res = await getConfig();
|
|
|
|
commit('SET_CONFIG', res.data);
|
2023-08-11 13:51:58 +08:00
|
|
|
}
|
2023-07-21 15:35:53 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
export default {
|
|
|
|
state,
|
|
|
|
mutations,
|
|
|
|
actions
|
|
|
|
};
|