|
@@ -1,12 +1,55 @@
|
|
|
<template>
|
|
|
- <div id="app">
|
|
|
+ <div id="app" @click="handleClick">
|
|
|
<router-view />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import { getToken, setToken } from '@/utils/auth';
|
|
|
export default {
|
|
|
name: 'App',
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ lastTime: null,
|
|
|
+ currentTime: null,
|
|
|
+ timeOut: 1 * 60 * 1000,
|
|
|
+ token: '',
|
|
|
+ timer: '',
|
|
|
+ };
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.lastTime = new Date().getTime();
|
|
|
+ this.token = getToken();
|
|
|
+ setTimeout(() => {
|
|
|
+ this.handleClick();
|
|
|
+ }, 1000);
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ handleClick() {
|
|
|
+ if (this.$route.path.includes('/hospital')) {
|
|
|
+ this.timer = setInterval(this.isTimeOut, 10000);
|
|
|
+ } else {
|
|
|
+ clearInterval(this.timer);
|
|
|
+ this.lastTime = new Date().getTime();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ isTimeOut() {
|
|
|
+ this.currentTime = new Date().getTime();
|
|
|
+ // 判断上次最后一次点击的时间和这次点击的时间间隔是否大于30分钟
|
|
|
+ if (this.currentTime - this.lastTime > this.timeOut) {
|
|
|
+ if (null != this.token) {
|
|
|
+ // 是否是登录状态
|
|
|
+ this.$message.info('30分钟内无操作,请重新登录。');
|
|
|
+ setToken('');
|
|
|
+ sessionStorage.removeItem('route');
|
|
|
+ this.$router.push(`/login`);
|
|
|
+ clearInterval(this.timer);
|
|
|
+ } else {
|
|
|
+ this.lastTime = new Date().getTime();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
};
|
|
|
</script>
|
|
|
|
|
@@ -153,7 +196,7 @@ export default {
|
|
|
justify-content: space-between;
|
|
|
margin: 10px 0px;
|
|
|
}
|
|
|
-.dashboard-container{
|
|
|
+.dashboard-container {
|
|
|
padding: 0;
|
|
|
margin: 16px !important;
|
|
|
}
|