登录后获取信息,用于判断登录后是否过期
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", '');
|
||||
|
||||
Reference in New Issue
Block a user