js实现十分钟内在页面无任何操做,页面跳转至登录页

    // 若是10分钟没有操做,退出到登陆页
    var timer;
    function startTimer(){
        clearTimeout(timer);
        timer=setTimeout(function(){
            // 清空缓存和token
            $cookies.remove("access_token", { path: "/" });
            $cookies.remove("userName", { path: "/" });
            $cookies.remove("userId", { path: "/" });
            $cookies.remove("roleName", { path: "/" });
            $cookies.remove("userCount", { path: "/" });
            window.location.href = "/index.html"
        },10*60*1000);
    }
    document.onmousemove=document.onmousedown=startTimer
相关文章
相关标签/搜索