73 lines
1.7 KiB
JavaScript
73 lines
1.7 KiB
JavaScript
/**
|
||
* 应用配置状态管理
|
||
* 统一管理所有配置,不再使用 localStorage
|
||
*/
|
||
export default {
|
||
namespaced: true,
|
||
state: {
|
||
// 用户相关配置
|
||
email: '',
|
||
userLoggedOut: false,
|
||
rememberMe: false,
|
||
|
||
// 应用设置
|
||
appSettings: {
|
||
autoStart: false,
|
||
startOnBoot: false,
|
||
enableNotifications: true,
|
||
soundAlert: true
|
||
},
|
||
|
||
// 设备ID(客户端生成,需要持久化)
|
||
deviceId: null
|
||
},
|
||
mutations: {
|
||
SET_EMAIL(state, email) {
|
||
state.email = email;
|
||
},
|
||
SET_USER_LOGGED_OUT(state, value) {
|
||
state.userLoggedOut = value;
|
||
},
|
||
SET_REMEMBER_ME(state, value) {
|
||
state.rememberMe = value;
|
||
},
|
||
SET_APP_SETTINGS(state, settings) {
|
||
state.appSettings = { ...state.appSettings, ...settings };
|
||
},
|
||
UPDATE_APP_SETTING(state, { key, value }) {
|
||
state.appSettings[key] = value;
|
||
},
|
||
SET_DEVICE_ID(state, deviceId) {
|
||
state.deviceId = deviceId;
|
||
}
|
||
},
|
||
actions: {
|
||
setEmail({ commit }, email) {
|
||
commit('SET_EMAIL', email);
|
||
},
|
||
setUserLoggedOut({ commit }, value) {
|
||
commit('SET_USER_LOGGED_OUT', value);
|
||
},
|
||
setRememberMe({ commit }, value) {
|
||
commit('SET_REMEMBER_ME', value);
|
||
},
|
||
updateAppSettings({ commit }, settings) {
|
||
commit('SET_APP_SETTINGS', settings);
|
||
},
|
||
updateAppSetting({ commit }, { key, value }) {
|
||
commit('UPDATE_APP_SETTING', { key, value });
|
||
},
|
||
setDeviceId({ commit }, deviceId) {
|
||
commit('SET_DEVICE_ID', deviceId);
|
||
}
|
||
},
|
||
getters: {
|
||
email: state => state.email,
|
||
userLoggedOut: state => state.userLoggedOut,
|
||
rememberMe: state => state.rememberMe,
|
||
appSettings: state => state.appSettings,
|
||
deviceId: state => state.deviceId
|
||
}
|
||
};
|
||
|