管道基础大数据平台系统开发-【前端】-新系統界面
surprise
2024-04-22 3ffbf14664836032438b1fd496aefbd99187e2c9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<template>
  <div id="app">
    <router-view />
  </div>
</template>
<script>
import { rotate } from 'ol/transform';
import router from './router';
export default {
  name: "App",
  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 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>