mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-11-21 09:56:54 +08:00
smart-admin-h5
This commit is contained in:
21
smart-admin-h5/src/store/index.js
Normal file
21
smart-admin-h5/src/store/index.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import Vue from 'vue';
|
||||
import Vuex from 'vuex';
|
||||
|
||||
import user from './module/user';
|
||||
|
||||
Vue.use(Vuex);
|
||||
|
||||
export default new Vuex.Store({
|
||||
state: {
|
||||
//
|
||||
},
|
||||
mutations: {
|
||||
//
|
||||
},
|
||||
actions: {
|
||||
//
|
||||
},
|
||||
modules: {
|
||||
user
|
||||
}
|
||||
});
|
||||
41
smart-admin-h5/src/store/module/user.js
Normal file
41
smart-admin-h5/src/store/module/user.js
Normal file
@@ -0,0 +1,41 @@
|
||||
import cookie from '@/lib/cookie.js';
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
token: cookie.getToken(),
|
||||
// session 信息
|
||||
sessionInfo: {},
|
||||
// 是否获取了session
|
||||
isHaveGotSessionInfo: false,
|
||||
// 权限集合
|
||||
privilegeKeySet: new Set()
|
||||
|
||||
},
|
||||
mutations: {
|
||||
clearSession() {
|
||||
state.token = null;
|
||||
state.sessionInfo = null;
|
||||
state.privilegeKeySet = new Set();
|
||||
},
|
||||
updateSession(state, userLoginInfo) {
|
||||
state.isHaveGotSessionInfo = true;
|
||||
state.sessionInfo = userLoginInfo;
|
||||
if (userLoginInfo.privilegeList) {
|
||||
state.privilegeKeySet = new Set(userLoginInfo.privilegeList.map(e => e.key));
|
||||
}
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
// 用户菜单权限
|
||||
privilegeKeySet: state => state.privilegeKeySet,
|
||||
isSuperMan: state => state.sessionInfo.isSuperMan,
|
||||
actualName: state => state.sessionInfo.actualName,
|
||||
loginUserId: state => state.sessionInfo.id
|
||||
},
|
||||
actions: {
|
||||
// 登录
|
||||
handleLogin({ commit }, params) {
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user