JEECG 获取前后端登录用户信息

今天在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

如果是VUE3那么:

页面获取登录人信息/获取urlIP地址和端口号信息如下:

import { useUserStore } from '/@/store/modules/user';
const userStore = useUserStore();
const UserName = (userStore.getUserInfo.username);
console.log(userStore.getUserInfo)打印出来是

 获取IP和端口号信息:

import { useGlobSetting } from '/@/hooks/setting';
const globSetting = useGlobSetting();
console.log(globSetting,"preview");
var urlpdf =globSetting.domainUrl
posted @ 2023-02-03 16:07  智昕  阅读(601)  评论(0编辑  收藏  举报