• vue页面无操作10分钟内调转到登录页面


    https://blog.csdn.net/lbPro0412/article/details/83864454

    页面在设定时间内无任何操作(鼠标的点击、滑动、路由的切换、是否请求接口等),跳转到登录页,在跳转前把url存起来,点击登录的时候用。

    <template>
      <div id="app" @mouseover="OperatingWebsite()">
        <router-view/>
      </div>
    </template>
    <script>
    export default {
      data() {
        return {
          currentTime: new Date().getTime() 
        };
      },
      methods: {
        OperatingWebsite() {
          let currentTime = this.currentTime;
          console.log(currentTime, "currentTime");
          let lastTime = new Date().getTime();
          console.log(lastTime, "lastTime");
          let timeOut = 10 * 60 * 1000; //设置时间 10分钟
          if (lastTime - currentTime > timeOut) {
            // 未操作页面,跳转登录页面
            this.currentTime = new Date().getTime(); 
            const fullPath = this.$route.fullPath;
            const query = this.$Base64.encode(fullPath);
            this.$router.push({
              path: "/user",
              query: {
                type: query
              }
            });
          } else {
            this.currentTime = new Date().getTime(); 
          }
     
          // const truthPathQuery = this.$route.query.type;
          // const truthPath = this.$Base64.decode(truthPathQuery); //点击登录的时候跳转这个地址
        }
      }
    
    }
    

      

  • 相关阅读:
    CodeForces 459D Pashmak and Parmida's problem
    cf 459c Pashmak and Buses
    hdu 1006 Tick and Tick 有技巧的暴力
    hdu 1005 Number Sequence
    hdu 1004 Let the Balloon Rise
    c++ 单引号和双引号
    c++一些总结
    剑指offer23 从上往下打印二叉树
    E: Unable to locate package
    vector
  • 原文地址:https://www.cnblogs.com/qianjin888/p/10616123.html
Copyright © 2020-2023  润新知