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