今天在JEECG开发过程中,需要进行二开,对JAVA项目进行开发,现在用到要获取用户登录信息,可以使用以下方法进行获取
后端获取方法:
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); String userId = loginUser.getId(); String username = loginUser.getUsername();
前端获取方法:
1.首先引入store
import store from '@/store'
2.使用store
this.userInfo = store.getters.userInfo this.userId = store.getters.userInfo.id this.username = store.getters.userInfo.username