| | |
| | | created() { |
| | | |
| | | }, |
| | | beforeDestroy() {}, |
| | | mounted() { |
| | | window.addEventListener('beforeunload', e => { |
| | | sessionStorage.setItem('beforeunload', 1); |
| | | }); |
| | | |
| | | // 监听页面刷新 |
| | | if (sessionStorage.getItem('beforeunload') == 1) { |
| | | let name = sessionStorage.getItem("routerName"); |
| | | |
| | | if (name) { |
| | | this.$nextTick(function () { |
| | | this.$router.push({ path: name }); //如果sessionStorage存在路由,去缓存的路由 |
| | | }) |
| | | } else { |
| | | this.$nextTick(function () { |
| | | this.$router.push({ path: '/' }); //不存在存储,去主页 |
| | | }) |
| | | } |
| | | } |
| | | |
| | | this.addListenerExpire(); |
| | | }, |
| | | methods: { |
| | | addListenerExpire() { |
| | | var timeViewer = setInterval((res) => { |
| | | if (this.$store.state.listenTime && window.localStorage.getItem("LFToken")) { |
| | | var result = JSON.parse(window.localStorage.getItem("LFToken")) |
| | | var time = this.$store.state.listenTime + (parseInt(result.autoLogOut) * 60 * 1000); |
| | | var timeire = new Date().getTime(); |
| | | var token_time = result.expire; |
| | | |
| | | if (timeire >= token_time) { |
| | | router.push('/login') |
| | | localStorage.removeItem("LFToken"); |
| | | clearInterval(timeViewer) |
| | | } |
| | | if (timeire >= time) { |
| | | router.push('/login') |
| | | localStorage.removeItem("LFToken"); |
| | | clearInterval(timeViewer) |
| | | } |
| | | } |
| | | }, 5000) |
| | | } |
| | | }, |
| | | |
| | | }; |
| | | </script> |
| | | <style lang="less"> |
| | | <style lang="less" scoped> |
| | | // #app { |
| | | // font-family: Avenir, Helvetica, Arial, sans-serif; |
| | | // -webkit-font-smoothing: antialiased; |
| | |
| | | /*滚动条整体颜色*/ |
| | | scrollbar-track-color: #536c97; |
| | | } |
| | | // ::-webkit-scrollbar-thumb { |
| | | // //滑块部分 |
| | | // background-color: #dfebff; |
| | | // } |
| | | // ::-webkit-scrollbar-track { |
| | | // //轨道部分 |
| | | // box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2); |
| | | // background: #536c97; |
| | | // } |
| | | </style> |