You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.3 KiB
49 lines
1.3 KiB
import Vue from 'vue';
|
|
import Vuex from 'vuex';
|
|
import messages from './messages/index';
|
|
import project from './project/index';
|
|
import socket from './socket/index';
|
|
import user from './user/index';
|
|
|
|
// 不属于具体模块的 应用级的 store内容
|
|
const state = {
|
|
networkConnected: true, // 网络是否连接
|
|
forceUseStorage: false, // 强制启用storage
|
|
systemInfo: null, // 系统设备信息
|
|
};
|
|
|
|
const getters = {
|
|
// 是否启用本地存储
|
|
// 设置了强制启用本地存储 或者 没有网络连接的时候
|
|
useStorage({ networkConnected, forceUseStorage }) {
|
|
return forceUseStorage || !networkConnected;
|
|
},
|
|
|
|
// 是不是微信平台
|
|
isWeChat({ systemInfo }) {
|
|
return !(!systemInfo || !systemInfo.host || systemInfo.host.env !== 'WeChat');
|
|
},
|
|
};
|
|
|
|
const mutations = {
|
|
/**
|
|
* 设置网络是否连接的变量
|
|
* @param {*} state
|
|
* @param {boolean} networkConnected
|
|
*/
|
|
setNetworkConnected(state, networkConnected) {
|
|
state.networkConnected = networkConnected;
|
|
},
|
|
|
|
/**
|
|
* 设置系统信息的数据
|
|
* @param {object} state
|
|
* @param {object | null} data 获取到的数据
|
|
*/
|
|
setSystemInfo(state, data) {
|
|
state.systemInfo = data;
|
|
},
|
|
};
|
|
|
|
Vue.use(Vuex);
|
|
export default new Vuex.Store({ state, getters, mutations, modules: { user, messages, socket, project } });
|
|
|