zoukankan      html  css  js  c++  java
  • 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); //点击登录的时候跳转这个地址
        }
      }
    
    }
    

      

  • 相关阅读:
    bzoj 1367
    codeforces 757F
    bzoj 3600
    比赛环境设置
    线段树合并
    BZOJ2105: 增强型LCP
    BZOJ3156: 防御准备
    BZOJ3252: 攻略
    BZOJ2464: 中山市选[2009]小明的游戏
    Beta Round #9 (酱油杯noi考后欢乐赛)乌鸦喝水
  • 原文地址:https://www.cnblogs.com/qianjin888/p/10616123.html
Copyright © 2011-2022 走看看