登录后获取信息,用于判断登录后是否过期
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { getUserInfo } from "@/utils/user";
|
||||||
export default {
|
export default {
|
||||||
name: "ChatPage",
|
name: "ChatPage",
|
||||||
props: {},
|
props: {},
|
||||||
@@ -28,6 +29,14 @@ export default {
|
|||||||
password: "",
|
password: "",
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
created() {
|
||||||
|
getUserInfo().then(response => {
|
||||||
|
this.username = response.data.username;
|
||||||
|
}).catch(error => {
|
||||||
|
console.error(error);
|
||||||
|
this.$message.error("登录过期,请重新登录");
|
||||||
|
})
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleLogout() {
|
handleLogout() {
|
||||||
this.$store.commit("REMOVE_TOKEN", '');
|
this.$store.commit("REMOVE_TOKEN", '');
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ export function login(data) {
|
|||||||
// 获取用户信息
|
// 获取用户信息
|
||||||
export function getUserInfo() {
|
export function getUserInfo() {
|
||||||
return request({
|
return request({
|
||||||
url: '/user/info',
|
url: '/userInfo',
|
||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user