feat:增加获取用户信息以及token失效跳到登录页

This commit is contained in:
lixg
2022-11-25 15:13:20 +08:00
parent 1dd90d9b1e
commit 762dbf90a7
8 changed files with 81 additions and 13 deletions

View File

@@ -31,7 +31,7 @@
"
src="../assets/images/img.jpg"
/>
<div>李玉冰</div>
<div>{{ username }}</div>
</div>
<div
class="signOutMain"
@@ -59,6 +59,7 @@
<script>
import { reactive, toRefs } from "vue";
import DownLoad from "../components/drawers/DownLoad";
import * as api from "../api/index1";
export default {
name: "NavTop",
components: {
@@ -67,6 +68,7 @@ export default {
setup() {
const state = reactive({
selectRole: "管理员",
username: "",
roleList: [
{
id: 1,
@@ -91,6 +93,21 @@ export default {
state.visible = true;
console.log("点击下载", state.visible);
};
const getUser = () => {
api
.getUser()
.then((res) => {
console.log("获取登录信息成功", res);
if (res.data.code === 200) {
state.username = res.data.data.realName;
}
})
.catch((err) => {
console.log("获取登录信息失败", err);
});
};
getUser();
return {
...toRefs(state),
changeRole,