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
相關文章
相關標籤/搜索