| | |
| | | <template> |
| | | <router-view /> |
| | | <div id="app"> |
| | | <router-view /> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import Index from "./components/index"; |
| | | import { rotate } from 'ol/transform'; |
| | | import router from './router'; |
| | | export default { |
| | | name: "App", |
| | | components: { |
| | | Index, |
| | | computed: {}, |
| | | components: {}, |
| | | data() { |
| | | return {}; |
| | | }, |
| | | created() { |
| | | |
| | | }, |
| | | 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> |
| | | <style lang="less" scoped> |
| | | // #app { |
| | | // font-family: Avenir, Helvetica, Arial, sans-serif; |
| | | // -webkit-font-smoothing: antialiased; |
| | | // -moz-osx-font-smoothing: grayscale; |
| | | // text-align: center; |
| | | // color: #2c3e50; |
| | | // } |
| | | #app { |
| | | /*三角箭头的颜色*/ |
| | | scrollbar-arrow-color: #fff; |
| | | /*滚动条滑块按钮的颜色*/ |
| | | scrollbar-face-color: #dfebff; |
| | | /*滚动条整体颜色*/ |
| | | scrollbar-track-color: #536c97; |
| | | } |
| | | </style> |