mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-12 20:36:45 +08:00
feat:增加获取用户信息以及token失效跳到登录页
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user