Files
autoAiWorkSys/app/store/modules/config.js
张成 e17d5610f5 1
2025-12-22 16:26:59 +08:00

73 lines
1.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 应用配置状态管理
* 统一管理所有配置,不再使用 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
}
};